Collision 2D madness

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Serenade
:warning: Old Version Published before Godot 3 was released.

Hey!
I made player and enemy object as Kinematic2D bodies, when player jumps and stands on enemy, it shakes, sometimes a bit, sometimes, it shakes quite a lot, though both of them are standing perfectly still…
How can i fix this?
Here is how my physics code looks like (in idea) …

var gravity = 1000
var vel = Vector2()
...
func _fixed_process(delta):
var force = Vector2(0,gravity)
...
vel += force * delta
var motion =vel*delta
motion = move(motion)

I also used clamp to fix falling speed, where it doesnt go higher then 100~, but without it, it still twitches…

:bust_in_silhouette: Reply From: eons

Kinematic characters are meant to be controlled by code, if you don’t want it to shake, don’t shake it! :stuck_out_tongue:


With this little information I can imagine that your problem is the gravity pushing your character down, during move the engine tries to fix the overlap, collision margin may affect this too.

Some ways to manage that, if the character is idle, stop adding gravity, sometimes you can avoid using gravity until the jump or fall state is triggered (or slopes/cliff detected), depends a lot on the mechanics.

Thanks, ill see how these things u mentioned works…! :slight_smile:

Serenade | 2017-04-18 11:14