[ad_1]
I’ve some code that units my brokers vacation spot to a random level on a circles border, this circle originates from my brokers goal (the enemy). The objective being that my agent strikes across the enemy in a circle, randomly inside an angle vary, this works nice utilizing the next code:
void SetDestinationOnCircleBorder(Remodel goal)
{
// Random angle between 0-360 levels
float angle = Random.Vary(minAngle.Worth, maxAngle.Worth) * Mathf.Deg2Rad;
float x = Mathf.Sin(angle) * radius.Worth;
float z = Mathf.Cos(angle) * radius.Worth;
SetDestination(new Vector3(goal.place.x + x, 0, goal.place.z + z));
}
So the agent runs into “circle vary”, then decide a vacation spot on the circle border. The issue I’ve, is that the primary time the vacation spot on this circle border is about, the agent doesn’t account for its present place, so the agent can transfer “throughout” the circle to get to the vacation spot, which I dont need, since I would like it to maneuver forwards and backwards near its present place such as you would in fight when circling an enemy. Then from that time on it strikes as I would like it to between minAngle
and maxAngle
.
[ad_2]