Forum rules - please read before posting.

Toggling visibility issue

When I move the player character indoors in one of my scenes and switch from one camera to another I want to hide some outdoor object sand unhide some indoor objects that occlusion culling does not take care of for me due to some windows in the walls. Because of this I want to toggle their visibility in an actionlist for performance reasons. I start outside in this scene so the objects indoors are already invisible from the start. When moving inside the objects outside switch to invisible as expected, but the objects inside remain hidden. When walking outside the objects outdoors became visible again (as expected) so I am somewhat confused.

Right now I solved the issue by turning the indoor objects off when starting the scene but I would like to know why this command seems not able to unhide invisible objects in the scene for better understanding. 

I use the object visibility command and make it affect all children. What I noticed is that AC adds an Constant ID to the objects that are already turned off in my hierarchy but does not do this to the objects that are visible from the start. 

Comments

  • Please post some images of the objects, components, and ActionLists involved, as well as let us know the version number.  Are your Actions placed in ActionList asset files, or in scene-based ones?  Without knowing more detail, there's not much advice we can give.

    If the Actions and components that work look similar to those that don't, check that the Actions are actually running.  You can insert an "ActionList: Comment" Action to send a message to the Console when appropriate to debug this.

    An object's initial visibility state should not affect the effect of Actions - though the "enabled" state of the GameObject itself will.


  • Hi Chris, thanks for answering! I will try to reproduce the situation later this week and post some screenshots as well. Nonetheless a quick answer to your questions for now: the action lists are scene based and both the hiding and unhiding takes place in the same action list somewhere in the middle of the action chain. 

  • Hi @ChrisIceBox !

    Because I didn't want to refactor the previous problem cause the work around I made works for now, although not nice and ideal, I created another case where I want to make an object visible that is turned invisible from the start of the scene. In this case a small lamp that I want to turn on and off. Due to the very simple style I am going for the light ray is basically a transparant sphere. So let me try to explain this (I took some screenshots this time!).

    So I have this lamp which I gave a hotspot. The hotspot looks like this in the inspector. And the object of the lamp with the hidden light source as a child looks like this in the hierarchy. I created a interaction for the hotspot within the scene itself. 

    At first I made this action list which checked for a local variable to see if the lamp was already on (true) or off (false) and let the list react accordingly as seen here. At first I thought that maybe local variables did not work as I would expect so I then made a global variable. But it didn't give any results as well. So then I made an extremely simple action list that just turns the light on. 

    When I assign an already hidden object to the action object:visibility action it gives it a constant ID. Which I till then associated with prefabs you spawn from the library or with game saving. But that is probably my very small knowledge of stuff ;)

    So, again I checked if the same workaround would work. So I set the lightray to visible in the scene and in the intro-scene actionlist one of my first actions is object:visibility in which I turn the lightray invisible. When I go to the lamp it works as expected (even with the local variables action list I made). 

    I feel like I am forgetting something but I can't figure out what I am doing wrong here. Please help! :)

  • Oh and I am using AC 1.56G and Unity 5.6.1
  • Constant ID values are used by AC to refer to scene objects from asset files as well as save games.  Depending on what Actions you're running etc, they may be added automatically as necessary - but you can assign them manually by attaching the "Constant ID" component to them.

    To save the visibility state of a mesh, however, you need a Remember Visibility component - see Section 9.2 of the Manual.

    You should find that a "save" icon appears next to any object with such a component in the Hierarchy - it doesn't appear to be the case here.

    However, you also have disabled the LightRay GameObject - which can cause problems as Unity has difficulty "finding" such objects again in code.  For this reason, don't disable GameObjects when unwanted, but instead move them out of the way or disable the components within them.
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.