- Home /
how do i send and receive messages in a game object?
i have done a colloion detection , and it sends the damage amount via
collision.gameObject.SendMessageUpwards("ApplyDamage", m_damage,
SendMessageOptions.DontRequireReceiver);
and this works well. i want to send a differnt type of message within a gameobject to get a waypoint and then recive the waypoint. but i not know how to do this
collision.gameObject.SendMessageUpwards("ApplyDamage", m_damage,
SendMessageOptions.RequireReceiver);
i would want to sent the message, and receive the data and a check to see if i receive the data ,
how is this done ?
Answer by ScroodgeM · Aug 05, 2012 at 01:48 PM
SendMessage method group is for one-way data transferring, usually in situations you don't know anything about receivers.
in your case the best way is to call methods directly. this will be better in performance reason, have a return type and compiler will not compile your project if something wrong in receiving/sending, so you will be sure in that basically all is correct. to call a method of another object just make this method as public or internal
Your answer
Follow this Question
Related Questions
Send Message On Collision 1 Answer
Send messages to different gameobjects 1 Answer
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
display message on touch 0 Answers