- Home /
Question by
$$anonymous$$ · Jun 27, 2013 at 09:08 AM ·
c#collisionthanks
Question about collision
I have an object with script that has a variable "number". And another object that has script and variable "num", so the question is how on collision of this objects I can equate number and num? Thanks!
Comment
Best Answer
Answer by $$anonymous$$ · Jul 01, 2013 at 12:38 PM
Found information at http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html .
This is my solution :) void OnCollisionEnter(Collision collider) { myName = collider.gameObject.GetComponent().name;
}
Answer by Oribow · Jun 27, 2013 at 01:03 PM
Maybe this works for you
//Put this in the num Script
void OnCollisionEnter(Collision col)
{
col.gameObject.SendMessage("equate",num,SendMessageOptions.DontRequireReceiver);
}
//Put this in the number Script
void equate(int num)
{
number = num;
}