Collision offset to detect open space.

This forum is currently in read-only mode.
From the Asset Store
10 Orchestral Soundtracks / ~2 mins each / 11 audio clips in total
  • 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?

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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

    <img src="http://i369.photobucket.com/albums/oo136/4Sweet2Leaf0/detector.png" border="0" />

    +Detector doesn't overlap solid

    +bunch of other stuff

    -wooooooosh

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