- Home /
The question is answered, right answer was accepted
Why is my ragdoll reacting differently depending on the framerate?
60 FPS reaction:
30 FPS reaction: (This is what I want to happen)
What's happening:
I'm shooting an object using "AddRelativeForce" with the "VelocityChange" force mode. When the object hits a bone of the character, it disables his "Animator" component and adds force to the bone's rigidbody.
The problem:
When the game is running at a high framerate the reaction to the collision becomes very weird.
So, how do I get more consistent results independently of the framerate?
Answer by Rugbug_Redfern · May 03, 2019 at 09:38 PM
Well, I would have to see your code to know for sure, but my best guess is that you are applying physics in the Update()
function instead of FixedUpdate()
. You should always run physics in FixedUpdate()
as it get's called (by default) every 0.02 seconds, regardless of framerate. Update()
gets called every frame.
So if you have any physics in an Update()
function, move it to FixedUpdate()
.
Only the character movement is in Update(), but I'm using CharacterController ins$$anonymous$$d of Rigidbody. Either way, I'll put the movement in FixedUpdate() and see what happens.
Like the answer said, use FixedUpdate since it's dependent on time ins$$anonymous$$d of framerate like Update is.So, how do I get more consistent results independently of the framerate?
Ok, so I tried to use FixedUpdate in the character movement, but unfortunately the results are still the same. So maybe there is something wrong with how I set up the ragdoll or how I'm applying force when the collision happens.
Answer by Kim-Nobre · May 06, 2019 at 05:34 PM
Well, I'm still not sure what exactly was happening there but, the solution that I found was to set the "IsKinematic" property of the bones' Rigidbody on or off whenever I activate or deactivate the Ragdoll. Now the collision reaction seems correct and consistent.