- Home /
Question by
sona.viswam · Jul 11, 2013 at 10:13 AM ·
gameobjecttriggerdirectiontransformdirection
Trigger enter issue
I have 2 moving gameobjects with same script attached to it.
In script trigger enter function i written
By touching each other both have to move in different direction.
direction is same in script.
by giving
dirX*= -1;
dirY*= -1;
direction = transform.TransformDirection(new Vector3(dirX,dirY,0));
both gameobject collide and moving
I have to make one object in another direction
How can i do it
Comment
Best Answer
Answer by talklittle · Jul 12, 2013 at 07:46 AM
function OnCollisionEnter(other : Collision) {
direction = other.contacts[0].normal;
}
More examples: http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html