Collision offset to detect open space.

For questions about using Classic.

Post » Wed Nov 09, 2011 11:10 am

Imagine NES Megaman's slide. He can slide underneath obstacles that are otherwise too small to walk under.

If you're against a wall and try to slide, it won't work. However, if you're against a wall and there's a small gap at the bottom, it will work.

How would I use collision offset to check if my player is against a wall with a small gap at the bottom? (16x8 gap in this case)

I figured

+Player Is NOT overlapping solid at offset 1,-4
+Angle is 0
-Allow slide.

would detect open space 1 pixel to the right of the player, and 4 pixels up..but it doesn't! It keeps him from sliding against normal walls, which is good, but it's not detecting gaps and allowing you to slide like I thought it would.

Normally I'd use a detector for this sort of thing but I'd like not to.

Any idea what I'm doing wrong?
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Nov 09, 2011 12:41 pm

I think overlapping at offset is like if you were to move your entire character sprite 1 px to the right and 4 pixels up, would it overlap at that new position

I was going to suggest not using a detector exactly, but a marker, like a square indicating a slideable area, you could even simplify events by making it extend slightly to the left and right of the gap. Gives you more control anyway for how it works, so there aren't any unexpected slideable gaps.
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Wed Nov 09, 2011 1:19 pm

Oh wow. I always thought collision offset determined a single point relative to the boundaries of an object.

Such as..
player.x=100
player.right=108
thus collision offset at 2,0=single point at 110

Well thanks for clearing that up. I'll just go ahead and use a detector.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Nov 09, 2011 3:10 pm

Here's what I would do if I knew which walls were slide-able.
>+On your trigger
->wallWithGap pick closest to player.x,player.y
-->wallWithGap compare x wallWithGap.x >player.x+offset
--->player compare angle player.angle is 0: do stuff
-->wallWithGap compare x wallWithGap.x <player.x-offset
--->player compare angle player.angle is 180: do stuff

Edit:
Now that doesn't take y into account, so if you have multiple levels of walls, IE walls that can be slid under above and below the character, you will need to compare the y as well.newt2011-11-09 15:16:37
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Wed Nov 09, 2011 3:25 pm

Thanks guys. Little red dot detector set at the player base's position & angle works pretty well though :)



+Detector doesn't overlap solid
+bunch of other stuff
-woooooooshTokinsom2011-11-09 15:28:53
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests