Time for action – adding more collision shapes to the monkey

The game file to import and load for this session is 5961_03_02.stencyl.

We will use the following information to position the additional collision shapes correctly in step 3:

Time for action – adding more collision shapes to the monkey
  1. Ensure that the monkey's Idle Left animation is visible in the center panel of Collision Editor.
  2. Click on the Add Circle tool at the top of the center panel.
  3. Referring to the previous diagram, enter the X Position (Left), Y Position (Top), and Radius information for the body's collision circle (Circle 2) into the Add Circle dialog box, and click on OK to confirm.
  4. Repeat steps 2 and 3 to create a collision circle for the monkey's feet.
  5. Save the game.

What just happened?

We've added two more collision shapes to the monkey actor to ensure that it can more appropriately interact with tiles and other actors in our game.

We can see that the collision bounds for the Idle Left animation now consists of three circles. Circular collision shapes were chosen for the monkey actor because they enable it to more easily slide off the edge of platforms and other obstacles. However, it's a good idea, when developing a game, to experiment with different collision shapes in order to achieve the best results for collision detection.

We can test the game now, if desired, but be aware that we have only made changes to the Idle Left animation. We still have to modify the collisions for the remaining animations for the monkey actor.

Planning the collision shapes

Before spending too much time refining the collision shapes for each of an actor's animations, it's a good idea to plan in advance and carefully consider the requirements for each animation. Also, consider the following tips, which could save some time!

  • Don't spend too long agonizing over each collision shape; to start with, only reasonable accuracy is required. We can always revisit the collision bounds at a later stage in development if the existing configuration doesn't work as required.
  • Consider the requirements for each animation. For example, in our game, the monkey's dead animation does not require any collision detection. So, no collision shapes are required!
  • Once a collision shape has been created, the arrow keys on the keyboard can be used to adjust the position of the shape; this can be much faster than retyping the coordinates in the Animation Editor's Current Shape panel.
  • When several animations are similar, configure one of them, and then jot down the collision shape settings, so they can be copied for the other similar animations. It will then just take a few moments to enter these settings and adjust them slightly, if required.
  • We don't have to use circles for the collision shapes; rectangular collision shapes, and even polygonal shapes should be used if appropriate for the shape of the actor!
  • Take into account what a player might consider to be fair or unfair when playing the game. Don't make collision shapes too large or too small.
  • Remember to save the game regularly!

Have a go hero

The game file to import and load for this session is 5961_03_03.stencyl.

We've configured the collision bounds for the monkey's Idle Left animation, but all the other monkey animations (Idle Right, Jump Left, and so on) need their collision bounds updated.

Update the collision bounds for each of the monkey's animations, taking note of the planning tips provided previously.

Testing the updated collision bounds

When all the monkey animations' collision bounds have been created and adjusted, we can save and test the game again. Be sure to thoroughly test to ensure that the collision shapes for the monkey are suitable for the environment; for example, if the monkey jumps into a small gap, can it jump out again, or will it become trapped?

We may need to move some objects, such as the log tiles, within the scene to ensure that the monkey can move around the scene freely. These are the types of problems that need to be resolved before a game can be released to the public, so don't be afraid to make changes to the collision bounds or to adjust the layout of the scene to account for any gameplay difficulties that are discovered during the testing process.

There should now be a great improvement in the collision-detection accuracy when the monkey collides with other objects and with most of the tiles, but we still need to do some work on the collision shapes of the leafy platforms.

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

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