Why does this work?

Just started using Construct 2? Post your questions here

Post » Sat Apr 22, 2017 11:11 pm

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:

Image

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!
B
5
S
1
G
3
Posts: 24
Reputation: 1,873

Post » Mon Apr 24, 2017 3:34 am

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.
B
87
S
44
G
16
Posts: 1,005
Reputation: 17,938

Post » Mon Apr 24, 2017 8:29 pm

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.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643

Post » Tue Apr 25, 2017 12:09 am

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?
B
5
S
1
G
3
Posts: 24
Reputation: 1,873

Post » Tue Apr 25, 2017 12:12 am

Actually never mind, collisions only care about the bounding box. Have an example capx to look at?
Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643

Post » Wed Apr 26, 2017 12:20 am

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
B
5
S
1
G
3
Posts: 24
Reputation: 1,873

Post » Wed Apr 26, 2017 12:34 am

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.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643

Post » Wed Apr 26, 2017 12:37 am

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.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643

Post » Thu Apr 27, 2017 3:11 pm

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!
B
5
S
1
G
3
Posts: 24
Reputation: 1,873

Post » Thu Apr 27, 2017 3:41 pm

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.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest