Hi,
I am implementing a Wander behaviour. In the book I am studying (AI for games), the author uses a 2.5D world.
So what he does is:
Set a circle around the player and put a target that moves on edge of the circle. Then use Seek behaviour to get to it.
The problem is that I am in full 3D, so I need something more than a circle. I (naturally) tried a sphere, but I want to be able to define different rotation angles (i.e I want the character to rotate more left/right thatn up/down).
As a sphere is defined by two angles (theta and phi), I tried to use a larger value for one of the two to see what happens. But the position of the target depends on both the two angles, so it didn't turn up like I wanted to.
This is what I am currently doing:
public SteeringOutput GetSteering()
{
SteeringOutput steering = new SteeringOutput();
// set linear velocity at the direction we are moving
steering.linearVel = character.Transform().forward;
// the velocity is along this direction, at full speed
steering.linearVel.Normalize();
steering.linearVel *= maxAcceleration;
theta += Util.RandomBinomial() * maxAngle;
phi += Util.RandomBinomial() * maxAngle ;
var pos = character.Transform().position;
pos.x += circleRadius * Mathf.Cos(theta * Mathf.Deg2Rad) * Mathf.Sin(phi * Mathf.Deg2Rad);
pos.y += circleRadius * Mathf.Sin(theta * Mathf.Deg2Rad) * Mathf.Sin(phi * Mathf.Deg2Rad);
pos.z += circleRadius * Mathf.Cos(phi * Mathf.Deg2Rad);
target.Transform().position = pos;
steering = seek.GetSteering();
return steering;
}
What can I do to get the effect I want?