transform.position is a frame behind

I’m drawing trails onto my fast moving blades, the position of the trails is chosen based where a transform pivot is on the blade.
All well and good except the position of the transform is from where it was last frame.


I tried extrapolating to where its expected to be but thats also not good.

So Im doing this
void Update()
{
query transform.position
construct trail mesh
}

Any suggestions?

you might want to do this within LateUpdate instead of regular Update, that way you can ensure everything else has already had its update run before doing this work

1 Like

Update happens before the animation moves the object, so that your scripts can affect animations for that frame.

Bookmark this, it will save your sanity

Look at the “Game Logic” big gray block in particular. You can see Update is right up at the top there, and LateUpate at the bottom. In between is all the Animation related stuff, which is what’s moving your character’s sword.

tldr: use LateUpdate

1 Like

Thanks guys, Though I did try that (FWIW the above screenshot is done with LateUpdate)

edit OK tested with LateUpdate vs Update

Red = lateUpdate, Blue = Update

LateUpdate is better but its still either 1 or 2 frames behind