How To refer to other Object's Components ?
So here's the thing,
I have a switch with an animator trigger called 'onOff' So I made it if it collides with the Player and I press 'E' the Switch Switches from On to Off Vice-versa. So far so great!
But I have a door. I wanna make when the Switch is Switched On. the door opens up and the Opposite The Door closes!
So I had this in :
void Update ()
{
if (Input.GetKeyDown (KeyCode.E))
{
if (playeron == true)
{
switchAnimator.SetTrigger ("Onoff");
sOn = !sOn;
}
}
}
sOn is just a try to refer to the door opened or not 'Failed' and 'Playeron' is to check whether the player is colliding with the switch or not.
So I want to control The Switch Script Propoties (Bools , Floats , Animator ...) from The Door's Script.
Your answer
Follow this Question
Related Questions
C# Unity dot syntax exercise correct solution? 1 Answer
item not adding to list correctly! 1 Answer
Script isn't working. Easy solutions to adding dialogue? Help ASAP - project due in a few days 1 Answer
How do I fix my UnityEngine Reference? 1 Answer
OnCollisonEnter2D Not Firing after checking collider 1 Answer