![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Major_Monkey_0720 |
I am working on a platformer, i’m currently trying to make a little blob guy follow you around, by ducking under platforms, and re apearing at your position, snapped to a tileset. However, if you land on the edge of a platform, his position gets rounded, and he apears off the edge. What I am trying to do is make it so he only pops up if he is colliding with the tileset. However, the body entered and exit signals only run once, and I can’t get it to work. Any ideas? `var collide = false
var targetY = 0
var targetX = 0
var squat = false
signal squat_anim
onready var player = $“…/KinematicBody2D”
func _physics_process(delta):
if position.distance_to(player.position) > 300 and !squat:
emit_signal(“squat_anim”)
if collide and !squat:
$Sprite.frame = move_toward($Sprite.frame, 0, 100 * delta)
else:
$Sprite.frame = move_toward($Sprite.frame, 8, 100 * delta)
func _on_demon_squat_anim():
squat = true
while $Sprite.frame != 8:
yield(get_tree(), “idle_frame”)
yield(player, “is_on_floor”)
position = player.position.snapped(Vector2(64, 0))
squat = false
func _on_demon_body_entered(body):
print(“enter”)
collide = true
func _on_demon_body_exited(body):
print(“exit”)
collide = false`