Enemies not colliding with platform edges consistently

0 favourites
  • 7 posts
From the Asset Store
On the Edge is a puzzle game where you have 40 levels to have fun with.
  • I'm not attaching a CAPX file to this message because I'm asking it on behalf of a student who is enrolled in my games class. (I teach at a liberal arts university in San Antonio, Texas.)

    Her game is a simple platform game that follows the logic of the jungle platform tutorial. An invisible border box is attached to the skin for the player character, and that border box is used to detect collision with other objects. The platform behavior is also attached to the border box.

    Enemies move from left to right, and they check for collision with an invisible edge sprite when they reach the end of their platforms. In this case, the enemies are just an animated sprite. They do not have an invisible box attached to them. As in the tutorial, an instance variable is used to keep track of the enemy's direction, and the enemies are flipped each time they collide with an invisible edge sprite.

    As the player moves through the game, the enemies suddenly start running off the platforms and falling to their deaths. It seems like it might be a collision detection problem. For some reason, it is more likely to happen when the enemies are outside of the viewport window. This is what the collision boundaries look like for the enemy sprite:

    I noticed that the fox sprite is *slightly* wider on certain frames than on other frames. (Never more than a couple pixels.)

    Should we be using invisible border boxes with our enemy sprites to avoid this problem? If so, how would one do this with multiple enemy sprites? Would we need to have a unique invisible border box for each enemy sprite? That seems hugely unwieldy. Would we use UIDs to pin invisible border boxes to enemy sprites when the layout loads?

    Thanks in advance for any help you might provide.

  • I avoid it by setting the same collision box for all the sprite animations in all animations, or by attaching a placeholder on the animation, while the placeholder is the real player.

  • I'm not sure I know what you mean about the placeholder. Does the placeholder work for the *enemy* animations? Thanks!

  • Placeholder is an invisible sprite used pinned to the sprite animations, you can use it for everything and make all the real behaviors on it and leave the sprites to just animate against the events.

    Some useful help can be read here:

    https://www.scirra.com/tutorials/355/ma ... iple-parts

    and here:

    https://www.scirra.com/tutorials/361/un ... moke-trail

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Fantastic! I will look into this now. Thanks!

  • Thanks for the pointers, Gabriel!

    In the rocket example that you shared, you dynamically added rockets into the game at random spawner locations. I am trying to implement this concept in a modified version of the default platform template.

    I have multiple instances of a monster placeholder object (objEnemyBox), and I would like to pin monster skins (objMonsterSkin) to each of these at the beginning of the game. You can see what I've done in the attached CAPX file:

    transmedia.trinity.edu/~adelwich/forum-images/dynamic-objects.capx

    At the beginning of the layout, I'd like to attach skins to all of the objEnemyBoxes.

    1) Do I need to dynamically add the monsters (objEnemyBox) through my event sheet when the game starts? Currently, I have just dragged them on to the layout where I want them.

    2) If I need to add them dynamically, what is the best way to do this? Should I loop through each instance of a spawner object and place those objects where I want the enemies to exist?

    Thank you for your help!

    Aaron

  • I think I might have figured it out. When the layout starts, I use "for each instance of monsterPlaceholder" and dynamically pin the monster skin to the monster placeholder.

    This seems to work, but is this the recommended practice? Is there a better way of doing this? Are there times when my solution would be a very bad idea?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)