- Home /
Instantiate with Transform.Find?
Okey so if I´m right you can´t have a Prefab with Transforms that are preset in the project folder? Well if so i need to find a way to do this if possible by only using script. I tried to use Transform.Find, Like this:
Network.Instantiate(Player, Transform.Find("SpawnPoint2").position, Transform.Find("SpawnPoint2").rotation, 0);
But i get errors:
Assets/Scripts/NetworkPlayerAlpha.cs(66,55): error CS0120: An object reference is required to access non-static member `UnityEngine.Transform.Find(string)'
Assets/Scripts/NetworkPlayerAlpha.cs(66,25): error CS1502: The best overloaded method match for `UnityEngine.Network.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion, int)' has some invalid arguments
Assets/Scripts/NetworkPlayerAlpha.cs(66,25): error CS1503: Argument `#2' cannot convert `object' expression to type `UnityEngine.Vector3'
Answer by fafase · Aug 17, 2013 at 10:14 AM
As the error states, Find is a member of an instance and should be used:
transform.Find();
with lowercase.
So you may have to find the object first or if you are looking into the Transform of the object this script is attached, just change the first letter.
Answer by chelnok · Aug 17, 2013 at 03:20 PM
Instantiate from project folder: http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html
Your answer
Follow this Question
Related Questions
Updating a variable on a script in an instanced object 1 Answer
Instantiate object 1 Answer
Prefab instantiated wrong scale on mobile 0 Answers
autolink to prefab? 0 Answers