Page 1 of 1

Follower units have a following glitch

Posted: Mon Oct 02, 2017 8:26 am
by HedgeHog builder
What is supposed to happen:
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
Guesses where/what it might be wrong
In the unit control section.
It could be a problem with my 'end' commands, stopping the program from completing other tasks

Whole code

Re: Follower units have a following glitch

Posted: Mon Oct 02, 2017 9:19 am
by Tjakka5
In the snippet you posted your vertical checking if's are changing the 'x' values. Swap these to 'y' and it should fix all your issues.