Topic was automatically imported from the old Question2Answer platform.
Asked By
SweetPie
I’m trying to understand why move_and_collide can return a collision that isn’t null while test_move returns false in the following code:
var collision = node.move_and_collide(Vector2(), true, true, true)
var test = node.test_move(node.transform, Vector2())
print("collision: ",collision,"; test: ",test)
This will print collision: [KinematicCollision2D:2797]; test: False, even though, as far as I can tell, both methods are not actually moving, and instead just checking if the node is already colliding with another object.
Did you check the results of the kinematicCollision2D that move_and_collide returns? it might say that there’s no collision!
test_move returns true or false, and move_and_collide returns a kinematicCollision2D object which stores the collision data (which might be that there’s no collision)
I’m not sure what you mean. If there’s no collision, move_and_collide returns a null collision, so the above code would output collision: [Object:null]; test: False. If you try to get the collider from the null KinematicCollision2D, you get an error.