|Topic was automatically imported from the old Question2Answer platform.
About collisions, how to know from which group are 2d objects when using move_and_collide instead of move_and_slide when is colliding with multiple objects?
it only detects one object
var collision = move_and_collide(velocity * delta)
move_and_collide internally. It just calls
move_and_collide again once collision is occurred until there is no movement left or
max_slides calls of
move_and_collide used. If you want to replace
move_and_collide, then you need to use same approach. After each collision you can get remain velocity (it is returned by
move_and_collide function) and call
move_and_collide again adjusting velocity along collision’s normal. Do it until remaining velocity is not zero (or at least close to zero) or max calls per frame is reached (you need to limit it too, because it might collide multiple hundreds times at some cases, freezing game).