problem matching player angle to collider angle

Get help using Construct 2

Post » Mon Dec 02, 2013 3:21 pm

Hello,

I'm making a game where the player can stick to floors,walls,ceilings,etc..

When the player sprite is overlapping collider
-->rotate 4degrees toward collider's angle.

That's working not too bad.

Now my problem is, when the player goes on the other side of the collider..
for example, the collider angle = 0
If the player is on top of it, then it's perfect.
But if he's stick to the bottom of it, his angle should then be 180(flipped) instead of 0, so there's a little problem here...

Here is a very basic capx, without the sticking ability but you still can see the problem:

https://www.dropbox.com/s/hhzzf7kw84gru3k/alignement_problem.capx

I think I can resolve this with the "overlapping at offset", but I'm having real troubles to figure it out...so I thought maybe I could ask some help on the forum...

Thanks a lot if you can help !
Lunar Mission for Android & iOS
B
16
S
2
Posts: 44
Reputation: 1,365

Post » Wed Dec 04, 2013 9:14 am

Sorry to bump..but anyone ?
Lunar Mission for Android & iOS
B
16
S
2
Posts: 44
Reputation: 1,365

Post » Wed Dec 04, 2013 9:25 am

I can't open your capx, don't know why, probably something with my computer, but couldn't you just add a condition that compares the y-position of the player with the y position of the collider?

if collider.y < player.y - set player angle to 180 (or collider.angle + 180)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Dec 04, 2013 10:16 am

Maybe you should create two collider objects. One for 0, other for 180 degrees. It's not an elegant solution but it should work.
B
6
S
1
Posts: 20
Reputation: 1,058

Post » Wed Dec 04, 2013 11:26 am

[QUOTE=LittleStain] I can't open your capx, don't know why, probably something with my computer, but couldn't you just add a condition that compares the y-position of the player with the y position of the collider?

if collider.y < player.y - set player angle to 180 (or collider.angle + 180)[/QUOTE]
That's actually a not bad idea, but the problem is that the player can move along the collider (while being "stuck"(hanging) on it) and the collider's angle can be set at any angle, so the X,Y coordinates comparison will be kinda tricky I'm afraid..but might be worth a try !

[QUOTE=causenad] Maybe you should create two collider objects. One for 0, other for 180 degrees. It's not an elegant solution but it should work.[/QUOTE]
That's actually what I'm doing now...but yeah like you said, it's not the best and it's more time consuming so I was hoping for a better solution :)

Thank you both for your help !
Lunar Mission for Android & iOS
B
16
S
2
Posts: 44
Reputation: 1,365


Return to How do I....?

Who is online

Users browsing this forum: Twili and 2 guests