I’m trying to make 2 RayCasts2D to check, but my coding skills are kinda bad so it lags alot and also doesn’t work well
In this picture, there’re a few Slimes stacked on top of each other, i just need to move circle around them and they will be stacked like that
I want to make it like this, so no matter where i go, it’ll not be stacked on top of each other
func Move(delta):
if(Global.world.localPlayer != null):
if(currentHealth > 0):
if rayCasts.get_child(0).is_colliding() == false:
direction = Global.world.localPlayer.global_position - global_position
else:
if rayCasts.get_child(1).is_colliding() == false:
direction = rayCasts.get_child(1).target_position
else:
rayCasts.get_child(1).rotation_degrees = rayCasts.get_child(1).rotation_degrees + directionIncreaseRayCast
if rayCasts.get_child(1).rotation_degrees >= maxDirectionIncreaseRayCast:
direction = Global.world.localPlayer.global_position - global_position
rayCasts.get_child(0).rotation = direction.angle()
if (direction.length() > attackRange):
global_position += direction.normalized() * delta * speed