Forum rules - please read before posting.

Player switching - object: visibility:invisible not working on Player

Hi,
I'm making a 2d game with AC 1.71.4 on Unity 2018.1.0f2
I had been making good use of Object:Visibility - Invisible (with Affect children ticked) to hide my Player Character to perform various fiddles and tricks. (for example hiding the Player Character near the edge of the screen and using this position to produce the 'offscreen' dialogue)

I recently enabled Player Switching and now I find that this is no longer working as I was expecting. i.e. it seems not to be working. I have to Object:Teleport the Player Character to another marker if I want to hide their sprite.

Perhaps I am doing something wrong or have the wrong setting selected.
Here are my Inspector settings for the Player Character

https://imgur.com/WI0Ye75

and its Sprite:

https://imgur.com/06lTdGi

I know I (still) have the animator set up on the Player Sprite and not on the root object. Could it be that?

In a similar but seemingly related problem, when I start a new scene, the Player Character does not seem to want to spawn to the correct marker. I followed suggestions on another thread to set up a marker for each Player Character - which I first turned into a prefab and then assigned to the Player Character in the Settings: Character Settings: Edit start data - but the Player Character still wants to spawn to my generic PlayerStart2D marker. (I have also assigned my marker in Scene - Scene Settings.)

Any ideas? Thanks :)

(Project Update - I'm steadily building up to a first sharing of my game's Prologue, with scrappy graphics still in place but playable...! Quite excited about that...)

Comments

  • I know I (still) have the animator set up on the Player Sprite and not on the root object. Could it be that?

    Shouldn't be. Does the character begin invisible if the Remember Visibility component's Visibility on start field is set to Off?

    What of the Action you're using to control it? Be sure to keep any Player characters out of the scene file itself when relying on the player-switching system - they should all be spawned in automatically via the Settings Manager.

    set up a marker for each Player Character - which I first turned into a prefab and then assigned to the Player Character in the Settings: Character Settings: Edit start data - but the Player Character still wants to spawn to my generic PlayerStart2D marker.

    When you say "new scene", are you beginning the game from this scene, or transitioning to it from another?

    Player prefab "Start data" will only apply to non-default Players. The active one will still rely on the same PlayerStart that they would without player-switching - i.e. the PlayerStart with the correct "Previous scene" configuration, or the scene's Default PlayerStart if none better was found.

  • OK.

    What of the Action you're using to control it? Be sure to keep any Player characters out of the scene file itself when relying on the player-switching system - they should all be spawned in automatically via the Settings Manager.

    I think that's it. I'll have a look through and report back in more depth soon, but I'm pretty sure that's the source of my problems. I hadn't realised that was how to do it. Thankyou.

  • I came back to this problem. I have removed Player Characters from the scene itself and am relying on them spawning in from their prefabs.

    I am not able to change the Visibility of my Player Characters now that I have Player Switching enabled. I am also struggling to change their Order in Layer using the Character - Change Rendering action.

    I am having this difficulty on the very first cutscene of the first scene and also when I return to the scene later. Any suggestions welcome.

  • edited August 1

    What issue specifically are you having? Screenshots showing your setup would help clarify the situation.

    When it comes to affecting Player characters in Actions, don't assign the prefab directly.

    If you check an Action's Is Player? field - player-switching is enabled - the Action will let you choose to either affect the active player, or a specific one listed in the Settings Manager. At runtime, the Action should then locate the referenced Player character - even if they aren't currently being controlled by the user - provided that they are present in the active scene at the time.

    Be aware, though, that changes made to such inactive Players are carried with them when they change scene - so you'll need to undo such rendering locks if you only want these locks to be felt for this scene.

  • Back on this problem...

    https://imgur.com/xdJ6BMN

    Here is the relevant Action List and here the result.

    The bathtub cables are on the default Sorting Layer with an Order in Layer of 5.
    The PC should appear in front of the cables (see 'set to Order in Layer = 6' in Action List) but he is not.
    The Action List begins with a Player Switch command that switches to the relevant player.

    Any ideas most welcome. I have stared at and fiddled with it in vain for some time now...

  • Was the new Player that this ActionList switches to in the same scene as the original?

    The Action looks fine - though there's no need for a second one. Again, if you want to affect a specific Player character, check Is Player? and then change the Active Player to the Player you want to affect.

    What of the Player's Sprite Renderer component? What is their Sorting Order value set to? Do they make use of a Follow Sorting Map component?

  • This is the original player.
    I have tried it with both Active Player and the Specific Player selected, neither makes a difference.

    The player's sorting value is set to 0. They are using a Follow Sorting Map component, which has Follow Default Sorting Map and Also Effect Chlidren checked.

  • This is the original player.

    Why the Player: Switch Action beforehand then? I'm not clear on the exact scenario here.

    There should be no issue based only on the details you've given - it's likely some small detail or factor that would be too hard to spot just based on questions like this. If you can create a cut-down project that shows the issue in a single scene / ActionList, you can PM it to me and I'll take a look.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.