So I'm trying to do the following:
1) Activate a CollisionShape2D
2) If it collides with an object, move the player object up one unit at a time until there is no more collision
But even after I move the object for multiple loops, the collide()-function still detects a collision and it becomes an endless loop. Can anybody tell me what I'm doing wrong? Is there a better way of moving an object upwards on collision?
func _on_FloorDetect_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
if body is TileMap:
var tilemap = body as TileMap
var coordinate: Vector2 = Physics2DServer.body_get_shape_metadata(body_rid, body_shape_index)
var tileid = tilemap.get_cellv(coordinate)
var shape = shapes[0]["shape"]
var otherTrans = shapes[0]["shape_transform"]
if IdleCollision.disabled:
IdleCollision.disabled = false
var colliding = false
while true:
var trans = IdleCollision.transform
colliding = IdleCollision.get_shape().collide(IdleCollision.transform, shape, otherTrans)
if colliding:
global_position.y-=1
else:
break