I have a set of 7 gameobjects. Whenever i am clicking the next button all gameobjects are moving in x direction, so only 1 gameobject is seen through the camera. And in the same position i have put a trigger. In that trigger it should detect which game object has entered the trigger. I am using this trigger script.
void OnTriggerEnter(Collider collider)
{
this.gameObject.renderer.material.name = collider.gameObject.name;
}
I dont know whether this is wrong or right but it is not even detecting the gameobject name.
To fire a trigger, an object has to have a rigidbody component, even if it's kinematic. Do your game objects have a rigidbody component attached?
– asafsitner"this." and both instances of "gameObject." are useless in your code.
– JessyI totally forgot to add rigidbody into it. Thanks its working fine now.
– united4life