Game Development Reference
In-Depth Information
Physics/Fixed Rotation: Checked
Physics/Collision Shape: Circle
You have two options to define how the actors will collide. The shape will be
either rectangle or circle.
The ball will be spawned from either Rack Player 1 or Rack Player 2, depending
on which player is serving for the game. By default, Player 1 will start the game
by serving first. The winner of the point will serve the next ball. To define which
player will serve, use a Boolean attribute on whether Player 1 will serve. If true,
Player 1 will serve; if false, Player 2 will serve.
In the Scene Editor, select the Attributes Inspector window and create a new
Boolean attribute by clicking the + sign, as per Figure 2-22.
Figure 2-22. Attributes Inspector window
Name this attribute P1Serving and check it.
Back in the Actor Editor for the Ball actor, create a new rule. The rule will check
which player is serving and, based on the result, will change the direction. To do
so, use the Otherwise part of the rule.
Create a new rule and call it Ball Direction.The condition is if the attribute of
game. P1Serving is true. Drag in a Change Velocity behavior.
Change the direction using the Expression Editor. Click the small ''e'' at the right
of the direction field, as shown in Figure 2-23.
 
Search WWH ::




Custom Search