- Home /
Question by
Stolfy · Mar 16, 2017 at 08:34 PM ·
c#vector3localpositionteleportinginversetransformpoint
Adding a local position with InverseTransformPoint works in z axis, but inverts in x axis
I'm working on a teleporting script that teleports the player in a direction relative to where the player is standing.
void TPDirection ()
{
axisV = Input.GetAxisRaw ("Vertical"); //FB Z
axisH = Input.GetAxisRaw ("Horizontal"); //LR X
axisE = Input.GetAxisRaw ("Elevation"); //UD Y
tpDirection = player.InverseTransformPoint(player.position +
new Vector3 (axisH *10, axisE *10, axisV *10));
}
public void Teleport()
{
player.position = player.position + tpDirection;
}
When playing, it works as I wanted when I face positive or negative in the z-axis, but when I face the x-axis I teleport in the opposite direction form what I wanted (except from the y-axis, wich works fine).
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Locking gameobject to rotating floor 0 Answers
Distribute terrain in zones 3 Answers
How can i change a childs local position with a variable? 1 Answer
Fix Position of gameobject. 0 Answers