Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Transform.TransformPoint Query

Discussion in 'Scripting' started by jtok4j, Dec 7, 2018.

  1. jtok4j


    Dec 6, 2013
    I've got a script which run a single line in Update(), that looks at a target object continuously:
    Code (CSharp):
    1. transform.LookAt(thisisthequestarrowtarget.transform);
    this seems to work fine, except when I have an object with transform.position which is ultimately written in the Inspector as: 0,0,0 .... I understand this to be a position in local space, since this is a child object's position. However, the line of code above seems to understand 0,0,0 as world space, and points in the completely wrong direction.

    I thought I might use: transform.transformpoint to convert the 0,0,0 from local space to it's position in world space, (and accomplish the same thing as above) with this line of code:
    Code (CSharp):
    1. transform.LookAt(transform.TransformPoint(thisisthequestarrowtarget.transform.position));
    This compiles with no errors, but results in the arrow (pointing at it's target) spinning wildly and eventually coming into a tight spin around "some" point in outer space... :p

    What am I doing wrong? Any thoughts?