Question by
NetkicksDev · Oct 18, 2019 at 12:09 PM ·
gameobjectphysicsspeedspeed issues
Calculated GameObject speed not consistent, why?
Hi there,
This is a networked game, so the object positions are calculated on server side (C# console program) and sent to clients at a specific send rate.
The objects have no rigidbodies and I need to calculate their speeds based on their positions.
I have tried to implement the classic speed calc script, but the speed is erratic, it keeps floating even when the object's movement is consistent.
speed = (transform.position - lastPosition).magnitude / timeFactor;
lastPosition = transform.position;
For the time factor, I've tried different things, such as putting this code on Update, LateUpdate, FixedUpdate and using fixedDeltaTime etc, using the server's send rate, etc. But no luck so far.
Any clues?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612213611im_/https://answers.unity.com/themes/thub/images/avi.jpg)