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

Get help using Construct 2

Post » Tue Jul 12, 2016 3:05 pm

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.
B
8
S
1
Posts: 15
Reputation: 470

Post » Tue Jul 12, 2016 4:04 pm

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:
how-do-i-make-the-8-direction-behavior-span-class-posthilit-slide-s_p904925?#p904925
B
94
S
33
G
113
Posts: 5,354
Reputation: 73,269

Post » Wed Jul 13, 2016 2:34 pm

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?
B
8
S
1
Posts: 15
Reputation: 470

Post » Wed Jul 13, 2016 6:07 pm

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.
B
94
S
33
G
113
Posts: 5,354
Reputation: 73,269

Post » Thu Jul 14, 2016 10:55 pm

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. :)
B
8
S
1
Posts: 15
Reputation: 470


Return to How do I....?

Who is online

Users browsing this forum: koops and 7 guests