Fandom

GameBlender 4 Ever

FSM with logic bricks 1 phase 4

57pages on
this wiki
Add New Page
Talk0 Share

Phase 4 - grap the ballEdit

GoalEdit

GUS can pickup a ball. But there is no ball. In this section we will build the logic for the balls and teach GUS to interact with them.

PreparationEdit

GUS can stay, walk, pickup a ball and walk while holding a ball, but without a ball.

First we need the ball

The BallsEdit

Balls? Gus needs just one, Why more then one. We need one:

  • to lay on the ground
  • to be in GUSs hands
  • to fall down


The enhanced FSM graphEdit

GUS should grap the ball and pick the ball up. This is should be done with two states. In state one GUS has its hands free and can go back to state stand. In state two GUS already grapped the ball and can only go forward to state ball_stand. Therefore the state ball_pickup will be split into the states ball_grap and ball_pickup.

ball_grapEdit

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

The state action for state ball_grap sets the current animation to "GUS_pickup".

When the property frame is 41 the animation ends. GUS performs a transition from state ball_grap to state ball_pickup.

The transition action is "msg:pickup ball". That means the message "pickup ball" will be send to all objects switching from ball_floor to ball_GUS.

ball_pickupEdit

The entry action for state ball_pickup is en-frame41 that continues the pickup animation.

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

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

ball_walkEdit

When the FSM is in the state ball_stand and the key "s" is pressed GUS will perform a transition to the state ball_walk.

The entry action for state ball_walk is en-frame1. As before this sets the property frame to 1 to restart the current animation.

The state action for state ball_walk sets the current animation to "GUS_ball_walking".

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

When the key "w" is pressed while GUS is in walking state a transition to the state ball_stand will be performed.

Fsm phase4 split pickup


StatesEdit

The state Ball_grapEdit

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

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

File:FSM phase3 state ball grap.gif

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_walkEdit

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

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

File:FSM phase3 state ball walk.gif

TransitionsEdit

Remove 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.

  • Remove the AND controller named cStand->Ball_pickup with its connections.
  • Leave the property actuator aStateBall_pickup that assigns the value "ball_pickup" to the property state.

File:FSM phase3 del transition stand ball pickup.gif

Stand->Ball_grapEdit

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

  • Rename the AND controller named cStand->Ball_pickup to cStand->Ball_grap.
  • Leave the sensor sStateStand connected with controller cStand->Ball_grap.
  • Leave the sensor sB connected with controller cStand->Ball_grap.
  • Add a property actuator aStateBall_grap that assigns the value "ball_grap" to the property state.
  • Connect cStand->Ball_grap with aStateBall_grap.
  • Remove the connection between cStand->Ball_grap and aStateBall_pickup
  • Leave cStand->Ball_grap connected to the actuator aStatechange++.

File:FSM phase4 transition stand ball grap.gif

Ball_grap->StandEdit

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

  • Rename the AND controller cBall_pickup->Stand to cBall_grap->Stand.
  • Leave the sensor sStateBall_grap connected with controller cBall_grap->Stand.
  • Leave the sensor sS connected with controller cBall_grap->Stand.
  • Leave cBall_grap->Stand with aStateStand.
  • Leave cBall_grap->Stand connected to the actuator aStatechange++.

File:FSM phase4 transition ball grap stand.gif


Ball_grap->Ball_pickupEdit

When the property frame is 41 the ball_pickup animation ends. GUS performs a transition from state ball_grap to state ball_pickup.

  • Add a property sensor named sFrame41 that checks the property frame for the value 41.
  • Add an AND controller named cBall_grap->Ball_pickup.
  • Connect the sensor sStateBall_grap with controller cBall_grap->Ball_pickup.
  • Connect the sensor sFrame41 with controller cBall_grap->Ball_pickup.
  • Connect cBall_grap->Ball_pickup with aStateBall_pickup.
  • As cBall_grap->Ball_pickup is a transition controller connect it to the actuator aStatechange++.

FSM phase3 transition ball pickup stand

Ball_grap->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_walkEdit

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_walk->Ball_walkEdit

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.