wander

Hello

I want to make my tank to wander in a certain area
My algo is

I generate a random point to use as a target
my tank moves to the target
when the tank is close to the target, an other random target is generated

If my tank is alone everything works fine
If my tank collides with an other tank then , from time to time ( not always) , it moves some pixels away then it starts rotating about the y axis for a few seconds then it stops for ever
The orientation of the tank is still ok

all the tanks have a CharacterController attached
I use the Move() function

What is the problem ?

Thanks in advance for your support

What is the problem?

you need to post script if you want answers to your problems.

It does not move anymore to the next target

Then we do need code indeed. Guessing won’t get us far

it is quite simple

function Update()
{
dist = (target.transform.position - transform.position).magnitude;
if(dist < radius) SetNewTargert();
TankMove();
}

function SetNewTarget()
{

target.transform.position.x = Random(Min,Max);
target.transform.position.z = Random(Min,Max);

}

function TankMove()
{
desiredVelocity = maxSpeed * ( target.transform.position - transform.position).normalized;
acceleration = maxAcceleration * ( desiredVelocity - currentVelocity).normalized;
currentVelocity += acceleration * Time.deltaTime;
transform.forward = currentVelocity.normalized;
tank.Move(currentVelocity * Time.deltaTime);
}

Thats not all the code…

anyway… might be your dist thing. Never tried to work out distance the way you have there… try

dist = Vector3.Distance (target.transform.position, transform.position);

if that fails put some debugging code in to see where its getting stuck

Well the magnitude of the vector is actually the distance between target and tank
The rest of the code is just the declaration of the variables
The point is that everything perfectly works if the tank is alone
It is a collision related problem
Why does my tank come to an halt , after a sliding collision with an other tank ?