Collisions: please help.

  • Hi guys,

    Spent already several hours to figure out how to handle collisions in C2 (offset stuff in particular).

    We are (trying) to develope a game that involves lot of actions triggered by ''on landed" conditions, till now we have prototyped such dinamics by using invisible rectangles that help to get the job done, but I am pretty sure that the same result can be achieved by using maths and expressions:

    basically this is what like to do:

    If character (1, red) lands after a jump/by falling onto the block (3, black) but only within the designed area (2, green) = something happen.

    Guess we didn t understand offset very well, as we cannot get the green designed area right.

    Please help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use another invisible rectangle! :)

    Seriously, an invisible rectangular sprite for character is a very common technique used in platformer games. It helps to avoid lots of potential issues with changing collision polygons. Player actually controls that invisible sprite and the character sprite is pinned to it.

    You can use other invisible sprites (green zone on your picture) to detect when character steps on something, or enters a room etc.

    Just a second condition to "On landed" event:

    CharacterBox On landed
    CharacterBox Is Overlapping LandingZone
    .......(do something)
    

    .

    Edit: I may have understood your question wrong. If you are asking about how to detect when the character is N pixels above the floor, in this case - yes, you need to use "Overlapping at offset" event, with a positive number in Y offset. Possibly together with "Character is falling" and "Trigger once" conditions.

  • Thank you for your answer dop2000.

    We found the "rectangle system" pretty steady indeed, but sometimes requires more code, as we need to move more parts and use UIDs to avaid mess.

    By using offset as you suggested the action is triggered on the entire width of the object, so with just

    one foot on platform and the character trigger the action... we don t want that.

  • In a big project hard-coding UIDs in code is a bad practice, you should use instance variables instead.

    If you need to detect when the character is standing both feet on the platform, you can put an invisible Zone sprite, which is smaller (narrower) than the actual platform. Then use "on collision with zone" or "is overlapping zone" events.

  • Yes, we are becoming fans of "strategic-phantom-rectangles", through them collisions work very well and are very easy to trigger.

    Thank you for your help Dop.

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