Modifying an actor's collision shapes

Now that we know what collision shapes are, we can learn about modifying these shapes to meet our exact requirements.

Although the initial testing of our game demonstrated that the monkey can successfully traverse the jungle environment by running on the ground and jumping on the various obstacles that we created with tiles, there are some improvements to be made!

Note how the collision box around the leafy platform is larger than it needs to be; it projects far lower from the bottom of the platform than is necessary. This is likely to be annoying for players of our game, if the monkey jumps up when it is beneath the platform, it will bump the top of its head before it actually hits the platform. Even worse, the collision box around the monkey is also too large, which may lead to even greater frustration for our players.

To examine this problem more closely, test the game again, and make the monkey jump up when it is standing immediately beneath a platform. Although it's not a major issue while we're designing the game, players of our game will quickly give up if the same problem occurs when the monkey is standing close to an enemy actor – a collision will occur before a player can see the actors touching, and they will consider it to be unfair. This is a guaranteed way to annoy players, and they'll quickly start looking for a more fun game elsewhere!

We can see how this problem occurs in the following screenshot; a collision is detected whenever the collision shapes of the monkey and the platform intersect, but there is still quite a big gap between the image of the monkey and the platform.

Modifying an actor's collision shapes

The good news is that Stencyl equips us with the tools to make the required adjustments. We can use the Animation Editor to alter an actor's existing collision shapes and to add new ones. We can even add multiple collision shapes to an actor, so that we can form more complex shapes that closely represent the shape of our actor.

Note

When discussing collision detection, we can also refer to an actor's collision bounds; this simply denotes a single collision shape or multiple collision shapes that are used to specify the collision-detection areas for an actor.

Let's have a look at how we can improve the collision detection for the monkey.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.137.213