Game Development Reference
In-Depth Information
Way finding
When you think of way finding, you may also think of signs inside a building that
direct you where to go. I know that's what I think of, because I used to work in a
signs shop. What we are going to do in this section is create a method of way finding
with a GPS arrow that will direct you where to go. Let's say you wanted to direct the
player to the position of the weapon they have to collect. Import the arrow image I
have provided for you in this chapter's resource section, and then create a new actor
from it. This actor cannot be movable, so make sure to uncheck the Moveable option
in the actor's attributes. Obviously, we want to constrain the position of this arrow
to the position of our player, so drag in two Constrain Attribute behaviors into the
actor (for this part, we will be working on the actor in the Inspector window; we will
edit the actor in the scene later on) and change the Constrain Attribute behaviors to
self.Position.X | to | game.KevX and self.Position.Y | to | game.KevY .
Finally, create a new Integer attribute inside the arrow and name it Waypoint .
Then change its value to 1 .
Now drag the actor into the scene and place it near our Kevin actor. Now we will
edit the arrow actor in the scene. So double-click on it and click on the big lock icon.
First we want the arrow to point to the gun, so let's drag in a Rotate to Position
behavior. Apart from wanting the arrow actor to act differently at each level, the
benefit of editing the actor within the scene allows you to also select and edit the
attributes of the actor within the current scene.
Watch what I mean; for the Position option, click on the e side button to open up the
expression editor, click on the down arrow to expand the expressions editor, click
on Current Scene , and then click on Layers | Background . Then find the actor you
want the arrow to point to and select its X position.
How awesome is that?! Repeat the same for the Y position. Finally, uncheck the
Stops on Destination option in the Rotate to Position behavior. This will cause the
actor to constantly look in that direction.
 
Search WWH ::




Custom Search