Game Development Reference
In-Depth Information
Open the Projectile actor in the Actor Editor. Create a Boolean actor attribute
and name it ''HasBeenTouched.''
In the Touch rule, add a Change Attribute behavior above the Constrain
Attribute behavior. Change HasBeenTouched to true, as shown in Figure 6-13.
Figure 6-13. Changing HasBeenTouched attribute
Then add a Change Attribute behavior at the top of the Behaviors window so
that the HasBeenTouched attribute is reset to false when you initiate the scene.
Set Projectile.HasBeenTouched to false.
Then expand the Otherwise section of the rule and add a new rule in this
section. Name this sub-rule ''Throwing.'' The condition is ''Attribute''
''Projectile.HasBeenTouched'' is ''true.'' Then drag and drop a Change Velocity
behavior into the Throwing rule. Change the settings of this behavior to
Direction: 180 + vectorToAngle(Projectile.Position.X-
gameInitialX, Projectile.Position.Y-gameInitialY)
Relative to: scene
Speed: 10*magnitude(Projectile.Position.X-gameInitialX,
Projectile.Position.Y-gameInitialY)
The rule is shown in Figure 6-14.
 
Search WWH ::




Custom Search