Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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,077
    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