Collision+movement...

Get help using Construct 2

Post » Sat Feb 27, 2016 9:39 pm

Maybe I'm missing something, but how do I have a collision box at an angle, and have my player walk directly into it, but it pushes him the correct way he needs to move? For example, if he's moving up, and he hits an angle, he should move up still, but at the angle of the collision.

How can this be accomplished smoothly in C2?

https://www.youtube.com/watch?v=YsyZmEZTMDc
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Sat Feb 27, 2016 11:47 pm

It involves finding the angle of the spot on the polygon the player hit and canceling the speed moving against the object. You can look here for a few examples you may be able to use in your game.
how-do-i-make-the-8-direction-behavior-slide-against-wal_p904925?#p904925
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Sun Feb 28, 2016 12:11 am

Thank you!
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Sun Feb 28, 2016 12:16 am

R0J0hound wrote:It involves finding the angle of the spot on the polygon the player hit and canceling the speed moving against the object. You can look here for a few examples you may be able to use in your game.
how-do-i-make-the-8-direction-behavior-slide-against-wal_p904925?#p904925



Umm, which of these would best suit a player moving around objects that are on a tilemap? You have like five hundred examples </exaggeration>
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Sun Feb 28, 2016 6:15 am

With a tilemap I don't think any of them will help, since all those get a collision shape either by using imagepoints or using the size and angle of the object to calculate the collision polygon. Tilemaps are different. For them to work we first need to find the tiles the player overlaps, then treat each tile as a separate object. It's doable, but I'm very slow at coding lately and I have other things I'd like to work on first.

Another way to do it is to use a different approach. Instead of figuring out the collision polygon, we could use collision checks with moving around a little to find the approximate angle of the hit edge. The closet existing capx to that would be this, but it would need more work to get it to handle sliding on more angles.
viewtopic.php?f=147&t=91933&p=719471&hilit=event_motion2.capx#p719471

By far the simplest thing to do would be to just use the physics behavior, which probably would look alright.
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Mon Feb 29, 2016 8:22 am

I'll look into your example more closely. I did try physics but my character kept sliding around. when colliding with square collision objects, and I don't know why. But I'll see what I can gain by looking at your stuff there, I'm sure I can figure something out. :)
B
25
S
6
G
6
Posts: 265
Reputation: 3,696


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests