How do I keep collisions from stopping a sprite at once?

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello,

    I'm making a top-down game using the 8Direction behavior and I'd like to make collisions a bit more tolerant around the corners. Is it possible to tweak the 8Direction behavior so that collisions under a "soft" angle do not stop the sprite at once?

    I know I could achieve this using Physics but I'm not sure I should, as the rest of the game controls are pretty straightforward (I'm thinking performance here). I tried "cutting" the corners of my sprite's collision polygon, by making them 45° slopes instead of 90° angles, but it didn't change a thing (same result when I tried cutting corners from the solid tiles as well).

    My goal is to keep simple collisions while allowing the sprite to slide a bit when it collides on the very corner of a tile.

  • To do that you have to manually handle collisions and how the sprite responds. In other words you can't use the solid behavior.

    You can look here for a way to do wall sliding:

  • Thanks for your reply, R0J0hound!

    I had already found some of your helpful posts and .capx files here and there but wasn't sure they'd suit my project. Turns out they do!

    However for now I've been testing another of your solutions for colliding/sliding, the one named event_motion2.capx (https://www.scirra.com/forum/event-based-movements-amp-collisions_p719471?#p719471). I've had a bit of a hard time getting it to work in my project exactly as in yours, but I found out why: my player's sprite was 16x16 pixels scaled up to 128x128 and somehow it made collisions tighter or less tolerant... Anyway – I've changed my sprite for an actual 128x128 image displayed 1:1 (thus the collision polygon is 8 times bigger, and maybe 8 times more accurate?) and that did it! Now it's working as intended. The player collides with the walls but can slide sidewards a bit if it hits the extremity of a corner, and you can slide flawlessly along a wall that's already blocking you.

    I've looked at your latest .capx (the one you pointed to above) but I'm not sure I should use that one. Does it always handle the player's sprite as a circle when it collides? More importantly, can the size/position of the circle (relatively to the sprite's image) be tweaked? Oh and lastly, how do you think both of your methods compare in terms of processing power?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't follow the size issue. It works the same for me if the player is any size.

    The second one always handles the player as a circle, size is irrelevant but you do need to change the radius value i think.

    I have no comparison on which is slower. They do slightly different things.

  • I did try a few more options (Construct 2's Physics, or the latest iteration of your collisions with pushable objects) but they never were that much better, and sometimes were difficult to implement (your latest demo uses objects families but those can't be used in the Free version of Construct 2, which I use – oops! ^^).

    But for now it's working perfectly for what I need, and I got around to add touch control as well! Thanks again for your help, here and in other topics.

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