How do I solve the collision problem

0 favourites
  • 7 posts
  • Hi Guys!

    I would really appreciate if somebody could help me solve the next problem.

    I have a Player and two objects in my project. If player collides with Object1 it changes his opacity to 10. If player collides with Object2 it changes his opacity to 50. BUT when both object is close to each other, and the Player collides with both of them it always “choose” the first option.

    How could I make a rule for cases like that to make the Player choose the second option only if collides with both?

    Thank for the help in advance.

    Here is c3p if needed

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I haven't checked your c3p file yet, but my guess is the order of events is the problem. If I understand correctly, you want to player to pick Object2 (and use 50 opacity) if it is overlapping both.

    Event sheets run from top to bottom, meaning that the easiest way to solve your problem is to do this:

    Player is overlapping Object1 > Set Player Opacity to 10

    Player is overlapping Object2 > Set Player Opacity to 50

    Since Object2 is on the bottom, that means that if it is also run the same time as Object1, it will run last, meaning it would end with 50 opacity.

    Or do you mean second option as in whatever the player collides with second?

  • I haven't checked your c3p file yet, but my guess is the order of events is the problem. If I understand correctly, you want to player to pick Object2 (and use 50 opacity) if it is overlapping both.

    Event sheets run from top to bottom, meaning that the easiest way to solve your problem is to do this:

    Player is overlapping Object1 > Set Player Opacity to 10

    Player is overlapping Object2 > Set Player Opacity to 50

    Since Object2 is on the bottom, that means that if it is also run the same time as Object1, it will run last, meaning it would end with 50 opacity.

    Or do you mean second option as in whatever the player collides with second?

    Well, that was first that come to my mind and I tried to change the order of events. For some some reason it doesn't work and changes nothing.

  • If I understand correctly, you want to player to pick Object2 (and use 50 opacity) if it is overlapping both.

    Exactly. I want to choose needed result if Player overlaping both. And the most logical assumption is order of events. But for some reason it always choose the same option despite on events order and I am trying to understand this logic.

  • I've been messing around with your file, and I'm somehow stumped. Something this simple shouldn't be hard.

    If I find a solution, I'll tell you, but for now I've got no idea.

  • I've been researching this case.

    I determined that the player was hitting a solid red object and stopped. He was just 0.1 pixels short of the blue object and the colision did not work.

    This case can be called artificial and it will not happen in a real game.

    But I wanted to solve this problem. There is an option to attach an invisible sprite-sensor to the threat, which will be 1 pixel larger than the player and will be responsible for the collision.

    Here is an example.

    kibaga.org/c3-example/file_uploads/index.php

  • I've been researching this case.

    I determined that the player was hitting a solid red object and stopped. He was just 0.1 pixels short of the blue object and the colision did not work.

    This case can be called artificial and it will not happen in a real game.

    But I wanted to solve this problem. There is an option to attach an invisible sprite-sensor to the threat, which will be 1 pixel larger than the player and will be responsible for the collision.

    Here is an example.

    https://kibaga.org/c3-example/file_uploads/index.php?file_name=../MultiCollision.c3p

    It explains everything. Thank you a lot for your time and persistence!

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