Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED]Help, Vector problem

Discussion in 'Scripting' started by wtfiswiththisnamething, Jul 7, 2015.

  1. wtfiswiththisnamething

    wtfiswiththisnamething

    Joined:
    Jul 7, 2015
    Posts:
    5
    Hey, i wanned to draw a simple line, always pointing in the front of my "ship".
    This is what i got:
    222222222222.PNG

    I write the Debug.DrawLine and start it at transform.position, but it is not on the right position

    1111111111.PNG

    (direction is a vector that shows always into the right direction)
    the game is paused, as this problem only appears while beeing "far" away from (0,0,0),

    also, this problem only happens when the ship has a velocity, when its standing still, its drawing correct.

    sry4mybadenglish
     
    Last edited: Jul 7, 2015
  2. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    It looks like you are first drawing the line, then reposition your ship? It should be the other way around.
     
  3. wtfiswiththisnamething

    wtfiswiththisnamething

    Joined:
    Jul 7, 2015
    Posts:
    5
    nope:
    44444.PNG

    and here the result (nothing has changed; the vector still starts at the wrong location, only while the ship is moving)
    3333.PNG
     
  4. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,083
    I think @blizzy is correct, after FixedUpdate is complete Unity runs the physics update which will move your object (fixed update is just used to apply forces to be calculated in the next physics tick). You could try moving the debugLine to LateUpdate which should happen just before rendering.
     
  5. wtfiswiththisnamething

    wtfiswiththisnamething

    Joined:
    Jul 7, 2015
    Posts:
    5
    ty guys, it works when i put it in the late update <3
    ty very much :D