Godot Version 4.3
Hi, is it possible to check 2D collisions in a call(able?) function? The inbuilt function can’t, I think.
context,
I did a custom move player script ('cuz fun), it uses a while-loop to shift in pixels the player until a collision occurs. Since the collision check occurs after the while loop is finished, the player frequently gets stuck in collision and unholy things happen
(yes, I took it from Celeste, no, looking at it likely won’t solve this problem unless you’re gonna tell me to rewrite it using the inbuilt physics)
Code:
func _moveX(direction: float):
remainder_distX += direction
var dist = _round(remainder_distX)
if dist != 0:
remainder_distX -= dist
var sign = sign(dist)
while dist != 0:
position.x += sign
if is_colliding: # modified by default collide/exit functions
position.x -= sign
break
dist -= sign