- Home /
How do i receive a message?
So what i want to do is, once the character touch the button, the tile changes, so my code is here
this is for the Button:
function OnCollisionEnter (myCollision : Collision) { if(myCollision.gameObject.name == "ButtonRed"){ SendMessage ("tileRedChanges"); } }
this is for the Tile:
**if ( something happened.. lol.... i don't' know what to write here and somewhere else to receive the message) { transform.localScale = Vector3(3,1,58.70655);
transform.position.x = -42.27357;
transform.position.y = 5.5;
transform.position.z = 134.2756;
}**
just wondering how can i write a receiver of the message it sent from the button?
(why the first part of script look like this..........)
Answer by DaveA · Sep 09, 2011 at 05:16 PM
The receiver of the message is a function you write that has the same exact name as the message, so make a function called tileRedChanges And read this: http://unity3d.com/support/documentation/ScriptReference/GameObject.SendMessage.html
Hmmmm, i get it, but do i put the function in the button, or the tile?
The script file. It's a function. It contains code to handle the message. Please see that link.
Your answer
Follow this Question
Related Questions
BroadcastMessage between children? 3 Answers
Flame Thrower - Particle Collision Help 1 Answer
Collision script 1 Answer
how do i send and receive messages in a game object? 1 Answer
Animation Event for different objects 0 Answers