- Home /
2D Motion Jerky using RigidBody2D [Video]
Hi,
Yes this is yet another jerky motion question but all the others dont seem to solve it so here goes.
I am using a RigidBody2D to control the movement of my main character but for some reason the movement is not smooth, the player jumps around a lot, I have tried the various Interpolate methods and Extrapolate seems to smooth things out but it seems to have a large performance hit on mobile.
See the video to see what is going on: https://www.youtube.com/watch?v=lFuuiQ2r8gM&feature=youtu.be
Does anyone have any idea how to go about fixing this?
Mike
@hypnoticmeteor not true. Angry Bird uses Box2D physics, on mobile, and it works perfectly. Bad Piggies is all about physics.
I saw it on Unity somewhere it is not good to use physics. I have tried it myself reduces the main thread dramatically. Its not that you cannot use physics but if you have a low end phone it causes lag which could be a reason why OP thinks it has a jerky motion.
Yeah you are right they use physics but you cannot control them once you shoot them into the air. In this case OP is controlling them with physics which is not a good idea.
Try the physics option in Project setting and try to change Bounce Threshold it might solve your problem.
Answer by Xeong-Hu · Mar 10, 2015 at 09:17 AM
If you're using Unity3d 5.0 Try checking off "Apply Root Motion" in your Animator of the game object, and see if that helps.
Btw nice game man.
Thanks. Im using 4.6 and have now ticked it off and the problem persists :(
@hexagonius its going to be quite tricky to create a simple example to show you. Basically its just a Rigid2DBody thats moving. If I remove the forward velocity code and just leave the jump logic (simple adding a force) then the problem still persists.
Changing the Fixed Time Step value in Time$$anonymous$$anager settings helps it. So too does setting the interpolate value on RigidBody2D to Extrapolate but both increase the performance cost :(
From what you're showing in the video there's no reason to change physics settings, there is not nearly enough stuff happening. The problem must be something else. Just some considerations:
$$anonymous$$ake changes to the rigidbody's velocity in FixedUpdate()
If adding forces continuously and using Force$$anonymous$$ode.Force, also use FixedUpdate()
Use interpolation mode on the rigidbody2d
Add a Physics$$anonymous$$aterial to the Collider with no friction at all
Adjust CameraPosition in LateUpdate();
@hexagonius Thanks again for all those tips.
I am continuously applying force in FixedUpdate but I was not using Force$$anonymous$$ode.Force, I am now doing so.
I didnt want to use interpolation mode due to the performance cost but I guess I may have to.
I have no friction on the Physics$$anonymous$$aterial.
I do adjust camera in LateUpdate already