Game Development Community

Making AIPlayer slide while colliding and moving forward

by Chris · in Torque 3D Professional · 05/12/2010 (4:58 pm) · 1 replies

Has anyone made a AIPlayer slide when it runs into something it can slide on?

I have path finding implemented but sometimes my AIPlayer hits the edge of something it could slide past if it just moved over a little, like if I have a client run the same path it hits and slides then continues.

#1
05/12/2010 (5:22 pm)
I think that you'd want to put something into onCollision ... probably use a raycast to see which way there isn't an obstruction so that they could move into that space and get round the obstacle ...

I set up a super basic "bounce off" if 2 Ai or Players collide to stop them from getting stuck together - haven't revisited it.

//in aiplayer::onCollision()
  if (%col.getClassName() $= "AIPlayer" || %col.getClassName() $= "Player")
	{
%colpos = %col.getWorldBoxCenter();
%objpos = %obj.getWorldBoxCenter();
%imp = vectorSub(%objpos,%colpos);
%imp = vectorScale(%imp,800);//was 400
%obj.applyImpulse(%col.getWorldBoxCenter(),%imp);
	}