![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | wyy2 |
Hello,
I’m started learning godot & I have a question. I found script which returns collided object name. But it works only when moving left or right. For example if you jump and gravity pulls you down on the floor, there is no collision response.
motion.y += GRAVITY
if Input.is_action_pressed("ui_right"):
motion.x = SPEED
elif Input.is_action_pressed("ui_left"):
motion.x = -SPEED
else:
motion.x = 0
if is_on_floor():
#print("On floor")
if Input.is_action_just_pressed("ui_up"):
motion.y = JUMP_HEIGHT
else:
print("Not on floor")
for i in range(get_slide_count() - 1):
var collision = get_slide_collision(i)
print(collision.collider.name)
motion = move_and_slide(motion, UP)