- Home /
transform.position relative motion
Hi,
I'm somewhat new to unity 3d. What is the code in javascript to make transform.position Script function move an object a certain distance, but not setting the exact location?
Let me know if you don't get it
Thank You
Answer by aldonaletto · Feb 23, 2012 at 11:39 PM
If you want to define a world position relative to the player, use transform.TransformPoint:
// pos is 1 unit in front of the object:
var pos: Vector3 = transform.TransformPoint(0, 0, 1);
If you want a world direction relative to the player, use transform.TransformDirection:
// dir is a vector pointing the object's forward direction:
var dir: Vector3 = transform.TransformDirection(Vector3.forward);
Your answer
Follow this Question
Related Questions
transforming position to the location of a variable 1 Answer
Swap texture2D on enemy sprite once reached a certain point 1 Answer
Alternative to using transform.translate and transform.position for moving objects exact values? 1 Answer
Issues with randomly moving a cube 3 Answers
can i let the sphere follow a point(x.y. or.z) on plane? 1 Answer