Forum rules - please read before posting.

Object visibility, parented to player

Hi everyone, I'm having a weird issue.

I know to use the "remember visibility" component to hide and show objects during my game. And that I can set an initial visibility as either on and off. I've been using it for a while without issue.

The problem comes now that I'm trying to do this to an object that is part of the player character. As in, my fbx is composed of several different meshes that are all inside my "character" object in the heirarchy. I hope I'm explaining it right.

The object in question is something that the character carries in their hand, I've rigged it with actual bones so I don't think I can have it as separate. And I'd like to hide it for most of the game and then have the character "take it out". However, even though I have its initial visibility as "off", once the game starts it's back on, and I can't find any actions I have running that would be turning it on.

I tried including an actionlist that explicitly turns its visibility off in the initial cutscene, but still to no avail. I know that the actionlist itself works, because if I press "Run now" on it during the game, the object does disappear. I just can't seem to make it happen automatically at the beginning of the scene.

Does anyone know what I could be missing?

Comments

  • The upcoming v1.85.6 update will address an issue causes the Initiial visibility setting to be re-applied upon switching scene - but the "Off" state should still be respected when the game begins. Are you saying that it's being ignored from the start?

    Even so, an ActionList should be able to hide it at runtime. Since yours is a spawned prefab, however, the Action will need to reference the Renderer via Constant ID number. This should be automatic, but check that both the Action and the GameObject have the same ID. If not, drop the prefab into the scene, re-assign it in the Action, apply changes back to the prefab and remove.

    For completeness: the alternative way to handle this situation is to control mesh visibility using sub-layers in your Animator, and then controlling animation playback using the Character: Animate Action.

  • Hi, Chris, thanks for answering

    but the "Off" state should still be respected when the game begins. Are you saying that it's being ignored from the start?

    Yes, it's being ignored from the start. I tried doing the same with the character's head for comparison, which is expectedly also parented under it, and it's the same, the game starts and it's fully visible. If I do the same (adding the "remember visibility" component and setting it to off) to a random object, it works fine.

    I tried including an actionlist that explicitly turns its visibility off in the initial cutscene, but still to no avail. I know that the actionlist itself works, because if I press "Run now" on it during the game, the object does disappear. I just can't seem to make it happen automatically at the beginning of the scene.

    About this that I said, I'm not sure what exactly I changed but it's not working anymore even with the "Run Now" option. I tried adding a debug dialogue to the actionlist and it does run and do everything else it's supposed to, except hide my desired object. I also tried changing it to hide a random object and it does so without any trouble. So I assume the problem stems from my desired object being parented to the player character?

    check that both the Action and the GameObject have the same ID.

    Sorry, how do I check the ID in the action? For the GameObject I imagine it's the "constant ID number" under the Remember visibility component, right?

  • edited February 10

    Yes, it's the Constant ID number. That should be the same on both the child object, and the Action, for the two to be linked correctly.

    I cannot recreate the starting state issue - is the child object enabled by default, with Retain in prefab? checked in the Remember Visibility inspector?

  • I'm sorry, I still don't understand how to check for the ID in the Action 🥲 I don't see an ID number there anywhere there.

    Here is my character in the hierarchy: https://imgur.com/a/6QA6YhP
    CHAR_abigail is a prefab made from the fbx which is made of all those parts. "red unida" is the one I want to hide, but as I said I also tried with others and it's the same thing. Also, the "retain in prefab" option for the ID doesn't seem to make any difference whether it's on or off.

    I realized my CHAR_abigail had a "remember visibility" component too and I thought that might be the problem, but I removed it and the problem persists.

    I also realized that if I pause the game in Unity (not with ESC but with the pause icon next to play), and press Run Now on my actionlist, the object does disappear, but once I go back to play mode, it comes back, as if there's something constantly reactivating it.

  • Oh, if it's of any relevance: I also have a marker parented to the character, which I was using to track her position.

    It is my understanding that markers are not supposed to be visible while playing the game, and they usually aren't without me doing anything, however this one was visible no matter what I did. I had to set its mesh filter to "None" to be able to hide it.

    So maybe there's some sort of bug that doesn't allow the hiding of objects parented to the player?

  • If the Marker has a Marker component attached to it, it should hide itself on Awake.

    However, the main issue is the lack of the ID in the Action. This is likely because it wasn't aware that it needed to generate one.

    Rather than placing the Player into the scene, view them in Prefab Mode and then drag "red undia" into the Action's field. If it's detecting a value from a prefab / asset file, it should then understand that an ID value needs to be assigned.

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.