0 Favourites

problem matching player angle to collider angle

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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Sorry to bump..but anyone ?

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

  • Maybe you should create two collider objects. One for 0, other for 180 degrees. It's not an elegant solution but it should work.

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

    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 !

    Maybe you should create two collider objects. One for 0, other for 180 degrees. It's not an elegant solution but it should work.

    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 !

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