Why does this work?

0 favourites
  • 10 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Hi all, I'm brand new and following along in a basic Platformer tutorial. I'm setting up a behavior for the player to kill the enemy by jumping on him, Mario-like. I've got the beginnings of it set up and working, but I don't know why it works. Right now the player jumps on the enemy and the enemy jumps up. This will be expanded on, but it's the start of his death animation.

    Here's what it looks like:

    This works when the Player.Y is less than Worm_Green.Y-41, but how would I come up with the 41 number? I got it by displaying Worm_Green.Y-Player.Y on collision, and then I jumped on him and noted what was displayed. But how else could I learn this?

    The player is 80x100 and the worm is 48x48.

    Thanks in advance!

  • Its probably some arbitrary number that just felt good. Its being used to tweak the impact height of when the player hits the enemy.

    If the player collided with the worm and the worms collision box was all the way to the top of the sprite, it might look like the player is bouncing off the air above him. Depends where the collison box is.

  • Your player is probably not moving 1 pixel per frame, so if hes moving 9 pixels per frame at the point right before impact, he might be 49 pixels above the origin of worm (not overlapping), then the next frame he would be at 41 (overlapping).

    Otherwise, it might just have to do with the origin point of the worm not being all the way at the bottom of the sprite.

  • So, it should be 40 because that's half the height of the player? But shouldn't it be 64, because that's half of the player's height plus half of the enemy's height?

  • Actually never mind, collisions only care about the bounding box. Have an example capx to look at?

  • Yes, here it is (it's made in Construct 3. I'm not sure if it's backward compatible if you're using C2): http://mattsfiles.weebly.com/uploads/5/ ... roblem.c3p

    This is under the groups and sub groups: Things That Hurt > Enemies > Worm_Green > Worm_Green vs Player

  • Checking it out, but first I think I should mention each group takes up an event towards your free edition limitation - you might want to use comments to organize instead. Groups are generally most useful for toggling sets of events active and inactive, so if you're not doing that they don't really serve much purpose.

  • Ok this was pretty simple. The height of your worm's collision box isn't the height of the entire sprite. It is only the bottom 42 pixels of the sprite... which gives you the 41 number when the bottom of the player sprite starts to overlap the worm's collision box.

  • Yeah, that makes sense, lol.

    Thanks for the tip on groups - I got a warning when I loaded it up today that some feature are disabled because it's not the paid version, but wasn't sure what it was talking about. I must have hit that limit already :-/

    I really wish Construct was a little more lenient with their trial version. Why not allow you to build more, but restrict exporting your game unless you pay? That would seem to make more sense to me, but I guess that's for another topic.

    Thanks again for your help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • C2 free version allows for 100 events. There is a looot you can do with 100 events if you're efficient about it. It was too lenient so they reduced it to 50.

    A well designed game will not use too many unique condition specific events - instead opting for flexible events that cover many situations by using expressions. If you take a look at the examples, most don't go above 20-30 events, and all the core game logic is pretty much there already.

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