0 votes

how to check who collide with object in moveandslide?
like if i want check who i collide with in moveandcollide , i can just do like this moveandcollide(motion).collider. but i dont know how to do it with moveandslide.

and why moveandslide didn't need *delta?

var right = Input.is_action_pressed("ui_right")
var left = Input.is_action_pressed("ui_left")
var up = Input.is_action_pressed("ui_up")
var down = Input.is_action_pressed("ui_down")

movement.x = int(right) - int(left)
movement.y = int(down) - int(up)

var motion = movement.normalized()*move_speed*delta
move_and_collide(motion)

var collision = move_and_collide(motion)
if collision:
    var collider = collision.collider
    if collider.is_in_group("wall"):
        queue_free()
    if collider.name == "enemy":
        if scale <= Vector2(10,10):
            scale += Vector2(1,1)
        else:
            scale = Vector2(1,1)
in Engine by (272 points)

1 Answer

0 votes
velocity = move_and_slide(velocity)

    var slide_count = get_slide_count()
    if slide_count:
        var collision = get_slide_collision(slide_count - 1)
        var collider = collision.collider

move_and_slide doesn't require you to multiply the velocity by delta because it already does it for you (https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#move-and-slide).

by (156 points)

can i know why i get this error picture link

enter image description here

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 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 webmaster@godotengine.org with your username.

Categories