Page 1 of 1

pawn collision with brushes

Posted: Tue Nov 13, 2007 4:58 pm
by creekmonkey
Ok Im sure this has probably been ask before but I can find no reference in the forum anywhere.

I am using a modified genericmelee script.

I have a pawn that follows script points that works perfect. BUT!

If the pawn sees the player and runs to attack and then loses sight of the player, the pawn goes to the Idle Order then rotates to the next script pont and attempts to walk there, which it should.

But if it collides with a brush in the level it just stops there and continues with the walk animation.
Should the pawn not back up and turn if it collides with the brush?

If the pawn collides with a brush when moving to the place it last seen player it bounces off and continues.
How can I get the pawn to do the same when returning to the script ponts??

Posted: Sat Nov 17, 2007 2:13 pm
by Juutis
You need to add an obstacle avoidance order. In low level it is already done in the 'walk_movetogoal' order. You'll need do something similar when the pawn is in high level moving from one scriptpoint to another. The manual:
AvoidOrder(char *Order );

If the Pawn hits an obstacle during the action MoveToPoint(...) it will run the Script Order called Order before returning to the MoveToPoint(...) action. This is used to run a custom obstacle avoidance routine to get around things that may be in the way.
So basically you create a new order and every time the pawn hits an obstacle when moving to a scriptpoint it executes that order. In genericmonster.s this order is:

Code: Select all

	Avoidance[ ()
	{
		if(random(1,10)<3)	// backup and move sideways sometimes
		{
			MoveBackward(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
			MoveRight(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
		}
		else
		{
			Jump(RUN, FORCEUP*SCALE, true, "");
			if(random(1,10)<6)
			{
				Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, 90, 0, "");
			}
			else
			{
				Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, -90, 0, "");
			}
		}
		Return();
	} ]
Then just add in the first order:

Code: Select all

AvoidOrder("Avoidance");

Posted: Tue Nov 20, 2007 1:29 pm
by creekmonkey
Thanks Juutis!