- Home /
How does one call a script method on the object you've collided with?
//obj 1's collision code function OnTriggerEnter( Otherobject : Collider) {
//how can I make this work?
//i want the other object to do something internally when it's hit by obj1
Otherobject.gameObject.dosomething();
}
//other object
static function dosomething() {
Gameobject.danceAround();
}
Comment
Best Answer
Answer by whydoidoit · May 13, 2013 at 06:20 PM
You don't want the other dosomething function to be static.
You can then do this:
Otherobject.GetComponent(NameOfOtherScript).dosomething();
Your answer
![](https://koobas.hobune.stream/wayback/20220613102144im_/https://answers.unity.com/themes/thub/images/avi.jpg)