0 votes

Hey there, I am currently working on an enemy, which inherits from a regular node. I wanted to use moveandcollide to create the movement, but as my enemy does not extend KinematicBody2D, I cannot use it. Does anybody maybe know an alternative to this?

Godot version 3.5
in Engine by (19 points)

Is there a reason it inherits from a regular node instead of KinematicBody2D? If not, I recommended changing its parent type to KinematicBody2D and that will let you use move_and_collide

2 Answers

+1 vote

Move the enemy manually by adjusting their position, and give them an Area2D to check for collisions.

by (1,053 points)
0 votes
# move_towards
func _process(delta):
    if (target - position).length() > 2:
        position = move_toward(target, delta * move_speed)

# lerp
func _process(delta):
    if (target - position).length() > 1:
        position = lerp(position, target, delta)
by (6,876 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.