Modifying platform behavior

  • Hi, platform behavior has the following:

    -is by wall

    -is on floor

    But it does not have:

    -is on top

    To know if the sprite is touching the ceiling.

    Would it be very complicated to modify the behavior to add this event?

    I mean at the user level, I'm not asking Scirra to add it because he won't do it.

    What file should I edit?

    The platform behavior detects the roof in a standard way but that event does not exist.

  • On top of what?

  • You can simply check for "Overlapping at offset":

    Character Is Overlapping SolidFamily at offset X=0, Y=-2

  • But why doesn't the behavior include it?

    Measuring it with offset will not be as accurate I think.

    This is because the behavior uses raycast.

  • I guess not many people need this condition.

    And no, when checking for walls Platform behavior doesn't use raycast, at least not in C2. It moves the character 2px to the left/right and checks if it's overlapping a solid.

    It's easy to modify Platform behavior to include check for ceiling condition, but Scirra doesn't approve this. So I suggest using "Overlapping at offset", because it's basically the same.

  • the behavior uses raycast to detect the edge of the wall and place the sprite correctly on the edge

    I think I remember that Ashley commented

  • Possibly, but it uses testOverlapSolid method for "Platform Is by wall" condition. So if you need to check if character is touching the ceiling, it will be the same method.

  • It's like a ray cast, but the ray is as wide as the player is tall...

  • Hi, thanks for the answers.

    I want to understand why sometimes the condition "is on floor" is not detected.

    You will say "well, you have deactivated the behavior" but even if the behavior is deactivated, the condition is processed and the ground is detected, the problem happens that sometimes this does not work.

    I need the condition always functions, however, sometimes the condition fails.

    I find it perfect that collisions continue to be detected with the behavior disabled, so I can take advantage of the wall detection system for my purposes.

    Colludium

    I think you have studied this behavior, could you help me with this question please?

    To play the example just keep the "UP" cursor pressed.

    At some point the ground will not be detected and the sprite will fall and disappear from the screen.

    This also happen with the behavior activated!.

    Only activate the action that deactivates the behavior

    CAPX

    https://www.dropbox.com/s/6xje39sgzxlqlcc/testPlatformBehavior.capx?dl=0

    There is an action deactivated, if you give a value to the vector Y, then the ground will definitely never be detected with the behavior deactivated.

    But if you keep the vector Y with the value 0, then the ground will be detected except on the occasions that I have commented above.

  • I can explain why this happens. When Platform behavior is enabled and you control the character only with Platform actions, it prevents it from falling through solids and always keeps it about 0.5px above the floor.

    When you move the character with actions like "Set Y", on some ticks it may move a little further and actually overlap the floor. (even a fraction of a pixel is still considered overlapping)

    "Is on floor" condition moves the character 1px down to check if it will overlap a solid floor. However, if it's already stuck in solid, this condition returns false. That's why it doesn't trigger and your character continues falling down.

    .

    If you need to disable the Platform behavior for some reason, you shouldn't use its conditions to check for floors and walls, use "Sprite Is overlapping" and "Sprite On collisions" instead.

  • Hi. The isOnFloor returns true even if the behavior is disabled because there is no isEnabled check in the condition. dop2000 has correctly described how the isOnFloor will only return true if the player is exactly just above the floor object (inside the floor makes the plugin think that the player is stuck inside something and it then returns false).

  • Thanks for the info guys.

    It is a disappointment to me.

    I only need to detect the ground when the character falls, nothing more.

    To achieve this I have to activate the behavior and then that creates the problem, because I don't need to detect other hardnesses, or walls.

    Perhaps there is another solution, is it possible to transfer solids with activated behavior?

  • Why don't you simply use "Is overlapping" or "On collision"?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Because the behavior places the sprite correctly in the soil profile.

    using overlap or collision this not happen.

    The sprite simply stops when it detects the ground but is not well located.

  • The behavior doesn't place the sprite correctly when it's disabled. And the floor/walls checks also don't work correctly when it's disabled.

    So if you need Platform behavior to be disabled, then your only real option here is to use Is overlapping and On collision events.

    You can use "On collision with floor" and then move the sprite in a loop 1px up until it stops overlapping the floor. And this will position the sprite correctly on the floor.

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