Godot: 2D Root Motion?

Created on 29 Mar 2019  路  5Comments  路  Source: godotengine/godot

Godot version: 3.1

Issue description:
I know that Godot 3.1 has Root Motion feature for 3D. But how should I implement something similar in 2D? I would like to move character quite arbitrarily. Simple motion (like running) is controlled from script, but I want the character to be able to move by means of animation as well (for instance, parabolic dashes / rolls / whatever), though, with right physics processing. The character is controlled via KinematicBody2D.

What I have tried (and still trying):

  • Adjusted values of track keys responsible for position property. Then dynamically switch sync_to_physics option of KinematicBody2Don before animation start and off after it is finished. That results in a strange glitch with camera, but that is not the main problem. This approach does not support collisions (I managed to pass through walls).
  • Again adjusted values of keys, then dynamically calculated velocity necessary to move from key1 to key2, key2 to key3, etc. Turned off the position track so that not to affect position directly. Motion is performed with move_and_slide so physics is taken into the account. But the results are not stable: the result position differs quite significantly from what is expected (currently it is like there is one unexpected extra frame so the character sometimes moves further), though, the velocity is constant and delta is constant too (I call move_and_slide inside physics_process)

Anyway, both approaches do not seem like something completely right to me. Maybe, there's something else out there that influences motion and introduces some undesired variations. I think, I will check it out on a clean minimal project later.

The question is: how should I achieve root motion in 2D? Are the approaches above acceptable or just silly hacks? How do you implement both simple and complex motion in your games?

Examples of how I do it:
Approach 1
repro_root_motion_sync_to_physics.tar.gz

Approach 2
repro_root_motion.tar.gz

Hit Run and see position printed in the console. Press space to play animation, move with left/right arrows

archived feature proposal core physics

Most helpful comment

The issue can be interpreted as a valid feature proposal (perhaps needs to be reworded accordingly so it doesn't come off as a pure question).

According to my little research, not many game engines have root motion for 2D, but we know Godot is unique so it makes sense to implement it!

All 5 comments

The issue tracker is not a place for questions. You should use an appropriate channel for this(such as IRC, Discord, forums etc) see https://godotengine.org/community. Sorry but closed.

@Chaosus thanks a lot) I have asked the question in Q&A. Here's a link: https://godotengine.org/qa/42831/root-motion-in-2d (probably, still being moderated)

The issue can be interpreted as a valid feature proposal (perhaps needs to be reworded accordingly so it doesn't come off as a pure question).

According to my little research, not many game engines have root motion for 2D, but we know Godot is unique so it makes sense to implement it!

Alright

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings