- Home /
The question is answered, right answer was accepted
Setting an Object to a variable after collision
I'm currently working on a small Unity game, and have run into a problem. I have the player and the objects sending messages between each other on collision, but it only seems to work on the objects I had designates as the "CurrentCube". I tried to set the collided object to CurrentCube, but my current set-up(shown below), has it setting the player itself to current cube:
void OnCollisionEnter(Collision collision)
{
print ("Test");
if (collision.gameObject.tag == "Others")
{
CurrentCube = gameObject;//Find a way to set this object to Cube(currently makes the player becomecurrentCube and breaks the game)
CurrentCube.SendMessage("Checker",Size);
Debug.Log ("Are we sending");
}
}
Is there a way to the the object that I collided with to become the currentCube?
you mean make "others" = CurrentCube? collision.gameObject = CurrentCube?
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Editing a variable from another script on collision 3 Answers
Distribute terrain in zones 3 Answers
How to access Particle System Collision to change at runtime 1 Answer
Variables from one script to another. 3 Answers