godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.49k stars 21.07k forks source link

Bumpy issue when dealing with moving platforms and Animation Player #32158

Open raphaklaus opened 5 years ago

raphaklaus commented 5 years ago

Godot version: 3.1.1 stable

OS/device including version: Ubuntu 18.04.2 LTS

Issue description:

A bumpy player in moving Platform when using AnimationPlayer in CollisionShape2D.

Steps to reproduce:

Given the following Node2D Structure:

* Node2D
  * KinematicBody2D
    * Sprite
    * Animation Player
    * Collision Shape 2D

If we animate CollisionShape2D and Sprite up and down, simulating a vertical moving platform, we get a bump effect on the character.

But if we animate the KinematicBody2D up and down directly, it doesn't happen. It works, but some times it is not wanted since I don't want to mess the base location of that object.

Make sure to set Sync to Physics to on in your platform object.

Minimal reproduction project:

Clone this and hit play in your Godot: https://github.com/raphaklaus/animation-player-issue

Raphael2048 commented 5 years ago

I don't know the reason why it bumps, but I think you should animate the KinematicBody2D instead of its child nodes, and Sync_to_physics is a prepared for itself , not its child nodes. I tried it on my own, and it works fine.

raphaklaus commented 5 years ago

I don't know the reason why it bumps, but I think you should animate the KinematicBody2D instead of its child nodes, and Sync_to_physics is a prepared for itself , not its child nodes. I tried it on my own, and it works fine.

Animating the KB2D directly throw two issues:

1) Having to animate the global position, not the relative one. It talks by itself. 2) What if I just want to animate specific hitboxes to adjust for better collisions? I think it should be accurate in the same way.

Raphael2048 commented 5 years ago
  1. add a layer is a solution: Node2D -Node2D (Still parent node)
    • KB2D(To animate) 2 I'm trying to solve this
raphaklaus commented 5 years ago

Yes, number 1 works. Although a little bump at the end (when the platform is moving up again). You can simulate it in this branch: https://github.com/raphaklaus/animation-player-issue/tree/almost-good-branch

KoBeWi commented 4 years ago

Seems like it still happens in 3.2.3 rc6, but this is somewhat expected, because the character is a RigidBody2D and it keeps its speed from the platform. Not sure if there's other way to prevent the bump than using KinematicBody2D with move_and_slide_with_snap().