Hello.
I have two objects. Player, and statue. When the player collides with the statue, I want to be able to call a function that is on a script attached to the statue. There will be many statues in the game, so I want to only call the function on that one specific statue.
Currently I have the collision set up between the player and the statue, and it is all detected fine. I can get the statue gameobject from using collsion.gameObject. But I want to call the script that is on the statue, from another piece in the code (not the collision code). How would I call this script using the gameObject obtained from the collsiion.gameObject. Or is there another way to do this.? thanks
Edit : I may have found a way using
statueScript = collision.gameObject.GetComponent();
I am still testing this out, but think it is working. If anyone reading this knows if this should work could you please let me know.