Hi all,
When should we use SendMessage?
What is the difference between
currentDoor.SendMessage("DoorCheck")
and
currentDoor.DoorCheck
Thanks in advance
Hi all,
When should we use SendMessage?
What is the difference between
currentDoor.SendMessage("DoorCheck")
and
currentDoor.DoorCheck
Thanks in advance
SendMessage(), and methods like it… are used to invoke solely coupled behavior. For example, SendMessage() will call the indicated menthod on every component (that has it) on the object. BroadcastMessage() can send a message down the scene graph hiearchy so all children gameobjects can have their components respond to a method (optionally) and so on.
These are slower than calling a method directly. But for event-type things, this lose coupling can be very useful.
SendMessage should be avoided if possible since it is a LOT slower than just doing a direct call.
But sometimes it might be useful.
Thank you.