Hi, I'm stuck on this problem, since I can't really see what I'm doing wrong.
I hope it's not a silly thing, here is the code:
var velocity = Vector2.ZERO
var chase_speed = 100
var player = null
velocity = (player.position - position).normalized() * chase_speed
player = body
print("Eu vejo você")
player = null
I really hope this hasn't been answered before, I'm searching for this for hours, and sometimes we just can't find the right words to search for.
The detection works as planned, pretty simple, but somehow to enemy just keeps drifting away from the player towards the LEFT always.
If I make velocity negative, it drifts towards the RIGHT instead, but never follows the player.
Edit: So I printed the values like this:
print("Velocity: ",velocity,"\n","PosiPlayer: ", player.global_position, "\n", "PosiEnemy: ", global_position)
Velocity: (-97.145355, -23.722973)
PosiPlayer: (375.452332, -109.84481)
PosiEnemy: (1157.895752, 81.2285)
So again, just chaging velocity by multiplying it to -1 or itself to -, simply changes the position it slides instead of left, it slides right.
The Player Node is on Layer 1, Mask 1.
The enemy is on Layer 3, Mask 1.
Putting them on the same layer does nothing different aswell.
To illustrate here what happens:
Another new edit here, I started a new clean project on the same engine version, I still get the same bug.