Forum rules - please read before posting.

Game object visibility in player prefab

edited August 2014 in Technical Q&A
Hi, I have my main char (the player) with a mask that has the remember visibility set on off at start. I apply that on the player prefab and remove it from the scene. At some point in the game, the mask should be showed on the player face, so i put an object visibility on the mask, but i cannot find the mask in the game object, because it's only in the player prefab under the resources folder...
How can i turn on the mask on the player face? >-)

Thanx all!

Comments

  • You shouldn't add Remember scripts to the player, it'll cause all kinds of crazy stuff.

    Instead, use multiple player prefabs.  Have one prefab with the mask, one without.

    In the Settings Manager, choose Player switching: Allow, allocate your prefabs, and set a default.  You can then use the Player: Switch Action mid-game when he puts the mask on.
  • Yes, I also thinked at the player switch but I didn't wanna use this for just a mask... but I think it's the only solution.

    Tx man! 
    :)
  • This is a very poor solution for a big feature lacking. I have a player that interacts with an incredible amount of objects, so the remember visibility was a good solution for this. But works half-way, sometimes makes "all kinds of crazy stuff" like you said. 

    But adding like 50 instances of the player to be able to switch player in realtime is not a solution, sounds more like a hack. Because the Player Switch function is intended for another thing. I'm sure this will make a lag, or a "blank moment" if you try to do it in the middle of gameplay.  

    Because in some cases it has to do with the player grabbing an object in the middle of an animation. So I should switch the player before playing an animation, so the object would appear before the moment, and then switch back to the original player? That's not going to work well at all. 

    Isn't another way around of this? most games deal with visibility when it comes to this matter. You export a player with a ton of transparent objects. And then in realtime you can turn on, alpha, or visibility to make it appear again. In the middle of an animation if it's necessary. 
  • Just for the record. I tried the alternate solution of Player switching, just to see how it worked, and it doesn't work either. It also "does all kinds of crazy stuff".
    For instance:

    * not removing the old player when it clearly says "remove player from scene" 
    * spawns the new player on another location, even when you manualy select the marker. 
    * In the best configuration of this feature you can see a blank spot, a micro moment when there is NO player at all. Which makes you blink for a moment and ask yourself what tha heck just happened. 

    I was thinking that maybe animating the object alpha channel of a prop would work,  is there an action for that? 
  • @Diego: Were the original post talking about 50 costume types I wouldn't have suggested player-switching.

    Any issues with the player-switching feature should be addressed, regardless.  If you can provide more details about your configration that can be used to recreate the issue, please post them in a separate thread so that I can look into it.

    However, for your case I would recommend using animation to control the transparency / visibility of your various body parts so that they can be controlled using the "Character: Animate" Action.

    What animation engine does your character makes use of?  The ideal way to do this would be to place such animations in your Animator controller as sub-layers controlled by parameters, and then control those parameters using the above Action.
  • Thanks Chris! 

    This could work well. 
    But anyways I've been working today on finding a work around on the object:visibility aproach and found a way that works very well so far. 

    I created a separate scene where I drop the player prefab like an asset. In there I added to each body part a "remember visibilty" component. And then I created "on File" action lists that have the "object : Visibility" action, to toggle on or off a sub-object. This way the engine creates the unique automatic ID number. And being an on-file action list I can call them from another scene. 

    Then I wen to the scene that needs this change and in-between the script I call for the action list that hides or shows a specific prop of the player and, up to this point at least, works like a charm. 


  • edited February 2022

    I've dug this up because I want to know if there's been any updates here.
    I have a similar situation where I use child objects attached to the player character, working as equipment/clothes and stuff.

    The reason I want to check with you again (instead of going with the animation method) is because when I control/check the visibility of one of these objects within the action list connected to the inventory item, it works fine, because it records constantID.

    However, recording the ID doesn't seem to be an option when I check the visibility within the scene, in a standard interaction.

    If this isn't possible I can live without it, but since it works perfectly in one case I'm just curious why it doesn't work in the other.

  • This thread is outdated, now. Remember scripts can since be added to the Player prefab.

    However, recording the ID doesn't seem to be an option when I check the visibility within the scene, in a standard interaction.

    If you want a scene-based object to refer to a prefab's child, how are you assigning it? By dragging the prefab into the scene and from there into the Action? That won't record an ID, as the Action considers the object to be a regular scene object, and not an asset file that requires one.

    What you can do, however, is move your Actions to an ActionList asset file and have your Interaction refer to this by setting its Actions source to Asset File.

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.