Is there any way to remove control of a KinematicBody and then return it via AnimationPlayer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Friends-Games

I’m working on a project that has player control but heavily uses AnimationPlayer Nodes. Is there any way to remove the script while this animation plays and then return it at the end?

:bust_in_silhouette: Reply From: RedBlueCarrots

I believe this can only be done through a function or variable created manually under the kinematic body’s node.

Modify your input code so that the body only takes inputs when another variable is true.

The way I structure my projects s to have a function handle all the inputs on the player, so I would just adjust the code under _physics_process so look like:

if controllable:
  get_input()

Then if in the animation player you change the variable controllable between true and false, you should be able to add or remove control from the player, while also letting the rest of the necessary scripts run.

^This
If you export the variable you can even key it through the inspector.

Nairazak | 2020-07-11 17:18