The follower is supposed to be following the mouse-controlled player but suffers from glitches.
Glitch 1
The follower does not move vertically. That is, it does not move up and down regardless of where the player is.
Glitch 2
The follower only follows you to the right if you are below it.
Glitch 3
The follower only follows you to the left if you are above it.
If you are on the same vertical plane, it does not do anything.
Where to look
Code: Select all
for p,v in ipairs(Spawned_Units) do
local speed = 150
if v.x > follow.x then
v.x = v.x - (speed*dt)
end
if v.x < follow.x then
v.x = v.x + (speed*dt)
end
if v.y > follow.y then
v.x = v.x - (speed*dt)
end
if v.y < follow.y then
v.x = v.x + (speed*dt)
end
end
In the unit control section.
It could be a problem with my 'end' commands, stopping the program from completing other tasks
Whole code