- Home /
how to transform position of player to parented object?
What I'm having problem on is that when my Player detects the "EdgeDetect" it will go in an edge hanging animation but sometimes my player doesn't get the right position.
so I put an "EdgePos" as seen in the picture below. But I tried this code but gets error.
charPlayer.transform.position = transform.FindChild("EdgePos");
the other thing is that I can't make a Transform variable where you can drag the "EdgePos" object to the Transform slot because I'll be making multiple edges to hang from.
"I tried this code but gets error." -> Whats error it gets?
Is EdgePos in your charPlayer hierarchy?
this one....
Assets/TestField/Scripts/EdgeDetect.js(14,68): BCE0022: Cannot convert 'UnityEngine.Transform' to 'UnityEngine.Vector3'.
Answer by Zaeran · Nov 29, 2014 at 07:49 AM
You're trying to set a Vector as a Transform.
Try this:
charPlayer.transform.position = transform.FindChild("EdgePos").position;
FindChild gives you the transform of an object. You need to specify the position to get the Vector.
Thanks alot dude, its works :D
this was just what I've been lookin for
Your answer
![](https://koobas.hobune.stream/wayback/20220613172722im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Best Way to make a character move 1 Answer
How to make the player turn left or right only in desired places o edges and not everywhere ???? 0 Answers
clamp limit variables trouble 1 Answer
have array target person of most priority/stick with top prior 0 Answers
Simple Instantiate gameObject problem 3 Answers