How do I check if 2 objects are touching?

Get help using Construct 2

Post » Thu Mar 09, 2017 8:10 pm

I'm currently trying to make a platformer where the type of ground you step on determines your speed and acceleration. I'm having trouble being able to determine whether or not the player is on top of a ground. Notice that i want this to work even when the ground is not flat or horizontal. i know there is is a "Platform is on floor" event. Can i retrieve that floor instance or is there another easy way to do this?

If it helps anything i know how to write javascript but never tried bridging it to construct.
B
4
S
1
Posts: 5
Reputation: 310

Post » Thu Mar 09, 2017 8:37 pm

@juanfrancoc

There's a few different ways to do it, depending on how you have your ground set up.

Assuming you have different sprites for each ground type, one way would be to add Player is overlapping GroundSprite at offset (0,16) as a sub-event to the "Platform is on floor" event for each ground type and set speed/acceleration accordingly.
Find all the Construct 2 games that were on Steam Greenlight here
B
36
S
10
G
7
Posts: 479
Reputation: 7,023

Post » Thu Mar 09, 2017 8:55 pm

@OddConfection

I was thinking about this option as a last resource since it may cause problems with not horizontal grounds, however is one posible solution.
It would be nice for future uses having a "Is touching" event. There could be something done with overlapping a slightly bigger hitbox
B
4
S
1
Posts: 5
Reputation: 310

Post » Thu Mar 09, 2017 9:28 pm

juanfrancoc wrote:I was thinking about this option as a last resource since it may cause problems with not horizontal grounds, however is one posible solution.
It would be nice for future uses having a "Is touching" event. There could be something done with overlapping a slightly bigger hitbox


Using is overlapping at offset to look directly below the player should work for any slope that the player can stand on, it's just a matter of how far below it you look, which is why I used 16 instead of 1.

Also, the at offset version of is overlapping does away with the need for a bigger hitbox, with the offset essentially acting like extending the hitbox in a particular direction.
Find all the Construct 2 games that were on Steam Greenlight here
B
36
S
10
G
7
Posts: 479
Reputation: 7,023

Post » Thu Mar 09, 2017 9:47 pm

OddConfection wrote:Also, the at offset version of is overlapping does away with the need for a bigger hitbox, with the offset essentially acting like extending the hitbox in a particular direction.


Yes i understand that, however it fails to extend the hitbox in every direction. Moreover, it wont extend the hitbox, but rather move it, so if i have a small object and a big offset i could end up going over the object and not overlaping it at all.

For now i think this solution will work though, at least for the scope im using here. Thank you very much for your advice,
B
4
S
1
Posts: 5
Reputation: 310


Return to How do I....?

Who is online

Users browsing this forum: tarek2, work3 and 6 guests