Topic was automatically imported from the old Question2Answer platform.
Asked By
Kinev
i’ve working in a 2d plataformer in coop with a friend, so i started watching the tutorials made by umai pixel, everything was fine until i reach the part when he code the dead parameters, so in the tutorial he corrected the thing that is happening to me but it’s seen to be changes in the godot program lenguage since then because it didn’t work to me, so when my character is in idle he doesn’t die but when i move or fall in an enemy hitbox then he die and is sent back to the title screen.
here is the part i’m in the tutorial, i watched every coment section but i still don’t find any solution.
func _physics_process(delta):
if is_dead == false:
velocity.x = SPEED * direction
if direction == 1:
$AnimatedSprite.flip_h = false
else:
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("walk")
velocity.y += GRAVITY
velocity = move_and_slide(velocity, FLOOR)
if is_on_wall():
direction = direction * -1
$RayCast2D.position.x *= -1
if $RayCast2D.is_colliding() == false:
direction = direction * -1
$RayCast2D.position.x *= -1
if get_slide_count() > 0:
for i in range (get_slide_count()):
if "Player" in get_slide_collision(i).collider.name:
get_slide_collision(i).collider.dead()
$CollisionShape2D.call_deferred("set_disabled", true)