How to set character invisible and visible

Kirshor

Member
Hi,
In my game, I need to set the character become invisible for a while, then set it visible after some tasks, I used setActive(false) but it has many errors. I don't want to set it invisible by using material. Help me please.
 
It worked. But when I set the active state=true again (after I set it=false), Character appear and the camera not keep it's current rotation. The camera is set at new rotation automatically. I want to keep the last camera rotation, how should I do?
 
I'm unable to reproduce this issue within the demo scene - are you able to test it there, using the example script in the page Justin linked? Are you getting any errors or warning messages?
 
I used the example script in the page Justin linked.
I did it step by step as below:
1/Camera: Third person, View type: Adventure
2/ control the character to make it has the "LookDirection" not the same with the camera's "LookDirection". For example: the angle between the character's "LookDirection" and the camera's "LookDirection" is 45 degree.
3/characterLocomotion.SetActive(false);
4/ characterLocomotion.SetActive(true)
5/ Now the angle between character's "LookDirection" and camera's "LookDirection" is Zero.
I want to keep the angle is 45 degree as it had before I change the character active state.

There are not any warnings or errors.

Thanks for your help!
 
Last edited:
When SetActive is called the camera will reset and right now there isn't an option to prevent that. Instead of setting the character GameObject as deactivated you could instead deactivate the mesh for your character, and then send the OnEnableGameplayInput event.
 
Top