Fandom

GameBlender 4 Ever

FSM with logic bricks 1 phase 3

59pages on
this wiki
Add New Page
Talk0 Share

Phase 3 - pick up a ballEdit

GoalEdit

In this phase we will teach GUS to bow down and pickup a ball.

PreparationEdit

GUS can stay and walk.


The enhanced FSM graphEdit

There are two new states ball_pickup and ball_standing. The prefix ball shows that this states are related to the object ball.

ball_pickupEdit

When the FSM is in the state stand and the key "b" is pressed GUS will perform a transition to the state ball_pickup.

The entry action for state ball_pickup is en-frame1 that restart the current animation.

The state action for state ball_pickup sets the current animation to "GUS_ball_pickup".

When the key "s" is pressed while GUS is in state ball_pickup a transition to the state stand will be performed.

When the property frame is 141 the animation ends. GUS performs a transition from state 'ball_pickup to state ball_stand.


ball_standEdit

The entry action for state ball_stand is en-frame1. This sets the property frame to 1 to restart the current animation.

The state action for state ball_stand sets the current animation to "GUS_walking".

When the property frame is 151 the animation ends. GUS performs a transition from state ball_stand to state ball_stand. This let GUS play the walking animation again.

Fsm phase3 pickup


StatesEdit

The state Ball_pickupEdit

A state sensor is required to check for the state ball_pickup.

  • Add a property sensor that checks the property state for the value ball_pickup. Call the sensor sStateBall_pickup.

FSM phase3 state ball pickup

The state Ball_standEdit

A state sensor is required to check for the state ball_stand.

  • Add a property sensor that checks the property state for the value ball_stand. Call the sensor sStateBall_stand.

FSM phase3 state ball stand

TransitionsEdit

Stand->Ball_pickupEdit

If the key "b" is pressed while GUS is in state stand a transition to the state ball_pickup should be performed.

  • Add a keyboard sensor named sB to check for the key b.
  • Add an AND controller named cStand->Ball_pickup.
  • Connect the sensor sStateStand with controller cStand->Ball_pickup.
  • Connect the sensor sB with controller cStand->Ball_pickup.
  • Add a property actuator aStateBall_pickup that assigns the value "ball_pickup" to the property state.
  • Connect cStand->Ball_pickup with aStateBall_pickup.
  • As cStand->Ball_pickup is a transition controller connect it to the actuator aStatechange++.

FSM phase3 transition stand ball pickup

Ball_pickup->StandEdit

If the key "s" is pressed while GUS is in state ball_pickup a transition to the state stand should be performed.

  • Add an AND controller named cBall_pickup->Stand.
  • Connect the sensor sStateBall_pickup with controller cBall_pickup->Stand.
  • Connect the sensor sS with controller cBall_pickup->Stand.
  • Connect cBall_pickup->Stand with aStateStand.
  • As cBall_pickup->Stand is a transition controller connect it to the actuator aStatechange++.

FSM phase3 transition ball pickup stand

Ball_pickup->Ball_standEdit

If the Ball_pickup animation ends (frame 141) a transition to the state ball_stand should be performed.

  • Add a property sensor named sFrame141 that checks the property frame to be equal to 141.
  • Add an AND controller named cBall_pickup->Ball_stand.
  • Connect the sensor sFrame141 with controller cBall_pickup->Ball_stand.
  • Connect the sensor sStateBall_pickup with controller cBall_pickup->Ball_stand.
  • Add a property actuator aStateBall_stand that assigns the value "ball_stand" to the property state.
  • Connect cBall_pickup->Ball_stand with aStateBall_stand.
  • As cBall_pickup->Ball_stand is a transition controller connect it to the actuator aStatechange++.

FSM phase3 transition ball pickup ball stand

Ball_stand->Ball_standEdit

As the walking animation will come to an end (at frame 41) we need to restart the walking animation. This will be done by a transition from state Ball_stand to Ball_stand.

  • Add an AND controller named cBall_stand->Ball_stand.
  • Connect the sensor sStateBall_stand with controller cBall_stand->Ball_stand.
  • Connect the sensor sFrame151 with the controller cBall_stand->Ball_stand.
  • As cBall_stand->Ball_stand is a transition controller connect it to the actuator aStatechange++.
  • Optional: Connect cBall_stand->Ball_stand with aStateBall_stand.

FSM phase3 transition Ball stand Ball stand

Remarks: There is currently no transition back to stand. This transition will be added in a later phase.

ActionsEdit

Entry ActionsEdit

Ball_pickupEdit

When entering the state ball_pickup the animation should be reset to frame 1.

  • Add an AND controller cEn-Ball_pickup.
  • Connect the sensor sStatechanged with the controller cEn-Ball_pickup.
  • Connect the sensor sStateBall_pickup with the controller cEn-Ball_pickup.
  • Connect cEn-Ball_pickup with the actuator aFrame1

FSM phase3 En-Ball pickup

Ball_standingEdit

When entering the state ball_standing the animation should be reset to frame 1.

  • Add an AND controller cEn-Ball_standing.
  • Connect the sensor sStatechanged with the controller cEn-Ball_standing.
  • Connect the sensor sStateBall_pickup with the controller cEn-Ball_standing.
  • Connect cEn-Ball_standing with the actuator aFrame1

FSM phase3 En-Ball standing


State ActionsEdit

State action Ball_pickupEdit

GUS should play its pickup animation "st-act:GUS_ball_pickup".

  • Add an AND controller with the name cBall_pickup.
  • Connect the sensor sStateBall_pickup with the controller cBall_pickup.
  • Add an action actuator named aBall_pickup. Select the action type "Property". Enter GUS_ball_pickup in the field "AC:" and frame in the field "Prop:".
  • Connect the controller cBall_pickup with aBall_pickup.

FSM phase3 Ball pickup

State action Ball_standEdit

GUS should play its pickup animation "st-act:GUS_ball_standing".

  • Add an AND controller with the name cBall_stand.
  • Connect the sensor sStateBall_stand with the controller cBall_stand.
  • Add an action actuator named aBall_standing. Select the action type "Property". Enter GUS_ball_standing in the field "AC:" and frame in the field "Prop:".
  • Connect the controller cBall_stand with aBall_standing.

FSM phase3 Ball stand

CleanupEdit

As in the previous phases the logic bricks should be sorted a bit to provide a better overview.

FSM phase3 cleanup


GUS can now walk, stand, pickup and walk while carrying a ball. Unfortunatly there is no ball to carry. The next phase will show how to add the ball.

Proceed with Phase 4 - grap the ball

or go back to FSM with logic bricks

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.