06-12-2021, 11:15 AM
(This post was last modified: 06-12-2021, 11:30 AM by josemendez.)
Hi there!
You're passing 2 and 100 to the interpolate method, and you're calling it on FixedUpdate():
This makes no sense whatsoever and will most likely cause some very wonky behavior. Not sure if its the culprit but it is a pretty darn good candidate .
What Interpolate() does is take the physics states at the end of the previous frame and the current frame, and use the remaining render time to interpolate between the two. The resulting state is then rendered to the screen. Quoting the documentation for it:
As per the docs, Interpolate() must be called once all physics steps have been done: this is usually during LateUpdate(). Calling it in between physics updates like you're doing will yield strange results. Furthermore, the parameters you're passing just seem to be values chosen at random. The first parameter is the step time expressed in seconds, which in your case should be Time.fixedDeltaTime. The second parameter is the amount of time yet to be simulated which you don't seem to be keeping track of at all.
On a side note, you're adding both the timestep length (fixedDeltaTime) and the update time (Time.deltaTime) to _currentSimulationTime, which doesn't make any sense either. Then you're doing an extra Interpolate() call at the end of the frame, passing this incorrect value as the second parameter.
If you intend to keep track of the amount of time that needs to be simulated -which is definitely a good idea, as you need it for interpolation!- you need to add Time.deltaTime at the end of each Update call, and subtract Time.fixedDeltaTime at the end of each FixedUpdate() call.
You can use the ObiFixedUpdater component as reference on how to do this. Let me know if you need further help.
kind regards,
You're passing 2 and 100 to the interpolate method, and you're calling it on FixedUpdate():
Code:
void FixedUpdate()
{
//....//
Interpolate(2, 100);
}
This makes no sense whatsoever and will most likely cause some very wonky behavior. Not sure if its the culprit but it is a pretty darn good candidate .
What Interpolate() does is take the physics states at the end of the previous frame and the current frame, and use the remaining render time to interpolate between the two. The resulting state is then rendered to the screen. Quoting the documentation for it:
Quote:Finalizes the frame by performing physics state interpolation. This is usually used for mesh generation, rendering setup and other tasks that must take place after all physics steps for this frame are done.
As per the docs, Interpolate() must be called once all physics steps have been done: this is usually during LateUpdate(). Calling it in between physics updates like you're doing will yield strange results. Furthermore, the parameters you're passing just seem to be values chosen at random. The first parameter is the step time expressed in seconds, which in your case should be Time.fixedDeltaTime. The second parameter is the amount of time yet to be simulated which you don't seem to be keeping track of at all.
On a side note, you're adding both the timestep length (fixedDeltaTime) and the update time (Time.deltaTime) to _currentSimulationTime, which doesn't make any sense either. Then you're doing an extra Interpolate() call at the end of the frame, passing this incorrect value as the second parameter.
If you intend to keep track of the amount of time that needs to be simulated -which is definitely a good idea, as you need it for interpolation!- you need to add Time.deltaTime at the end of each Update call, and subtract Time.fixedDeltaTime at the end of each FixedUpdate() call.
You can use the ObiFixedUpdater component as reference on how to do this. Let me know if you need further help.
kind regards,