Wander Steering Not Working Properly

I'm trying to make my enemies(aka movers) to just wander around the screen. I've been following a tutorial but can't seem to get any where near the same out come. It's in action - script.It's the only one I can find that doesn't produce a twitchy wanderer.No matter what I do, my guy just quickly zig - zags from the top of the screen to the bottom, and repeats.The tutorial is very short, and lacking in certain areas of explanation.

Here's a link to the short tutorial for reference:
http://gamedevelopment.tutsplus.com/tutorials/understanding-steering-behaviors-wander--gamedev-1624

here is what I wrote is accordance to the action - script example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Vector2D WanderSteering::getRandomWanderForce()
{
	Vector2D circleCenter;
	circleCenter = mpMover->getOrientationAsVector();
	circleCenter.normalize();
	circleCenter * mCircleDistance;

	float randX = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
	float randY = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
	Vector2D displacement(randX, randY);
	displacement * mCircleRadius;

	float length = displacement.getLength();
	displacement.setX(cos(mWanderAngle) * length);
	displacement.setY(sin(mWanderAngle) * length);

	mWanderAngle += (rand() % 1) - (mAngleChange * .5);

	Vector2D wanderForce;
	wanderForce = circleCenter + displacement;
	return wanderForce;
}

Steering* WanderSteering::getSteering()
{
	mLinear = getRandomWanderForce() * mpMover->getMaxVelocity();
	mAngular = mpMover->getOrientation() * mWanderAngle;
	return this;
}
Last edited on
Topic archived. No new replies allowed.