cak3_lover
cak3_lover

Reputation: 1948

How to change the speed of only a single node?

I have a enemy KinematicBody2D and I want to slow down both it's movement & animation

I tried Engine.time_scale but it slows down the entire game,
so is there a way to slow down only a single node without effecting the others ?

Upvotes: 1

Views: 936

Answers (1)

Theraot
Theraot

Reputation: 40285

There is no API to do that.


For your KinematicBody2D you could do something like this:

export var speed_factor := 1.0

func _process(delta:float) -> void:
    delta *= speed_factor
    #...

func _physics_process(delta:float) -> void:
    delta *= speed_factor
    #...

And for your AnimationPlayer you can set playback_speed (which you can also specify when you call play).

Alternatively you can set playback_process_mode to ANIMATION_PROCESS_MANUAL and then call advance and seek (in _process, for example) to make it advance.

Upvotes: 1

Related Questions