Moving Characters

From BiaSDK
Jump to: navigation, search

Now it's time to get one of our characters to walk around, we will use Paddock for this step, there are a couple pathnodes already placed and labeled, their pathnode icon is about half the size of a normal one. (Done just to differentiate them from the others)

Copy the lines below into the PostFade state right after the EVENT_Friar_Start:

ACTION_Walk( 'Paddock' );
ACTION_MoveTowardTag( 'Paddock', 'PN_Paddock_01', False, );
Do {
sleep( 1.0 );
ACTION_MoveTowardTag( 'Paddock', 'PN_Paddock_01', False, );
} Until ( PawnIsAtDestination( Pawn_Paddock, GetNavigationPoint( 'PN_Paddock_01' )) );
Sleep( 2.0 );
Do { sleep( 1.0 ); ACTION_MoveTowardTag( 'Paddock', 'PN_Paddock_02', False, ); } Until ( PawnIsAtDestination( Pawn_Paddock, GetNavigationPoint( 'PN_Paddock_02' )) );
Pawn_Paddock.Controller.Focus = GetLocalPlayerPawn();

The first command, ACTION_Walk, is simply telling Paddock to walk, instead of run, ACTION_Run would switch Paddock back to a run. You can also completely fine-tune the movement speed by using ACTION_SetDesiredSpeed( 'Paddock', 0.3 ); the number being 0.0 to 1.0.

ACTION_MoveTowardTag is the command actually making Paddock move to a location, we supply the Tag of a pathnode, PN_Paddock_01, the False says that Paddock should not try to avoid other characters, Sometimes you might want it to True, it helps avoid getting ScriptedController characters stuck on each other, but it can also make them behave erratically. There is a 4th optional property which is the tag of any Actor, which Paddock will turn and face while moving.

Then there is a Do Until loop, it’s very simple, the script will loop Until Paddock gets to the navigation point PN_Paddock_01. Inside the loop we have it sleeping for 1 second, and also issuing another MoveTowardTag order, so that Paddock will keep trying to get to the pathnode if the player stands in his way.

Once Paddock is at the node, it breaks out of the Do Until loop, and sleeps for 2.0 seconds, and we send him off to another pathnode.

Once he is at the second pathnode, we tell Paddock to Focus on the Player, but this can be any other Actor with a tag set. The purpose of setting his Controller.Focus is so he turns and faces the player (or any other Actor).

Another method to think about is including a counter into the loop, such as in the following lines of code.

var int i ;
i = 0 ; While ( !PawnIsAtDestination( Pawn_Paddock, GetNavigationPoint( 'PN_Paddock_01' ) ) && i < 30 ) { Sleep( 1.0 ); ACTION_MoveToward( Pawn_Paddock, GetNavigationPoint( 'PN_Paddock_01' ), TRUE );\\
i++; }

There is a variable, i, and the While loop is checking to see if Paddock is NOT at the pathnode (note the ! exclamation mark, which is a NOT operand), and it’s also checking to see that i is less than 30.. Therefore once Paddock is at the pathnode, or i goes over 30, the script will move on. (Working as a failsafe)


Back to Main Page