- Home /
Help with SendMessage
I have an object called Spawn and I want an object (a checkpoint) to call the respawn function that Spawn has. However, with the following code: Spawn.SendMessage("respawn", Transform.position+Vector3.up);
I get the error
Unknown Identifier: Spawn
I also tried using FindObjectsOfType(Spawn).SendMessage("respawn",Transform.position+Vector3.up)
and got the same problem but in a different place. Finally I tried FindObjectsOfType("Spawn").SendMessage("respawn",Transform.position+Vector3.up)
but got
The best overload for the method 'UnityEngine.Object.FindObjectsOfType(System.Type)' is not compatible with the argument list '(String)'.
Answer by Mike 3 · Dec 28, 2010 at 03:10 AM
You search for gameobjects by name with GameObject.Find:
GameObject.Find("Spawn").SendMessage(
Hi, looks good but here http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html it says that it can locate children and parents. $$anonymous$$y Spawn object is neither a child nor a parent of my checkpoint. Will this be a problem.
That's transform.Find, GameObject.Find is just by name, unrelated to the current hierachy
Your answer
![](https://koobas.hobune.stream/wayback/20220613092812im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Checkpoint script problem 1 Answer
Why doesnt my checkpoint system work? 1 Answer
Gameobject Respawn 1 Answer
Player Respawn After Death 1 Answer
Checkpoint with PlayerPrefs 0 Answers