I am sure this is easy, but I have been having an extremely hard time making this happen. I have been trying to make it so that I can shoot a bullet which I have instanciated. Then when it hits the wall, I want it to send a message to an object telling it to move to the position when the bullet hit. I have tried multiple ways of doing this, but I always get a null reference exception as an error. Here was my first code:
function OnCollisionEnter(col : Collision)
{
transform.position = bulletPosition;
if(col.gameObject.CompareTag("Wall1"))
{
var go = GameObject.Find("object");
go.transform.Translate(bulletPosition);
}
}
I also tried for that last bit
go.transform.position = bulletPosition
But I always get NULL REFERENCE EXCEPTION.
What should I do?
thanks