Is there a fix for solid objects going through other solid objects?

1 favourites
  • 9 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
  • How do I keep the solid objects from going through other solid objects?

    If you look at the video below you'll see:

    Red walls are under faded gray walls - both are set to solid

    The alien is pinned to a faded blue square - both set to solid (That's 4 solids)

    The alien also has the pathfinder behavior.

    The collision boxes are as far out as they can go and still allow the alien to move.

    I've tried to offset the alien so when it gets near the walls it moves over - nothing changed

    I tried setting the pinned box to offset by several pixels - again nothing.

    I tried putting image points around the alien & the walls (desperation) - nothing.

    I tried to create a function that moved the alien over 45 degrees when coming into contact with the wall - nothing.

    Watch the video - it's like the alien goes out of it's way to pass through everything solid - why? It's as if the word 'solid' is only a suggestion. I think it's mocking me.

    Is there a fix for this?

    youtu.be/WYm6s5PUOBw

  • What method are you using to move your objects?

    The solid behavior has specific interactions with other behaviors. You can reference these in the manual construct.net/en/make-games/manuals/construct-3/behavior-reference/solid.

  • oosyrag

    For this game I am using pathfinding, but it doesn't matter which behaviors you use. Pasthfinder is set to obstacles: solids and I gave the sprite a solid behavior.

    I've made several different kinds of games and solid objects always seem to go through other solid objects. Many times if a sprite is moving and it walks into a solid object it gets stuck there - half in and out of the object it's stuck in.

    I don't understand why solid doesn't mean 100% solid.

  • It depends on the action you are using to move your object.

    If you manually move a solid object past or on top of another solid object by setting its x/y position, the solid behavior doesn't do anything.

    If you use 8 direction, the object controlled by 8 direction will be blocked by a solid object properly.

    For pathfinding, solids are only taken into account when calculating the path. There may possibly be issues with cell size and origin points, but without seeing your project that would be difficult to diagnose.

    Also note solids don't normally have any interact with each other, which seems to be your assumption. The solid behavior interacts with other movement behaviors. For example, if I had a solid wall, and a player object moving by 8direction, the player doesn't need to be solid and it still won't be able to pass or enter the solid area.

  • To get the behavior you are describing you might be interested in the Custom Movement Behavior. For every solid object you have, also add a Custom Movement Behavior and use the Push Out Solid action every tick or on overlap with another object.

  • oosyrag

    Here's a link to the project: drive.google.com/open

    I'm using pathfinder.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok there are two issues here - one is that your cell border is set to -1, this effectively shrinks your solid walls to basically nothing since your cell size is larger than your wall size. Try setting this to 0, and lowering your cell size to 16 or so.

    Problem two is the slow rotate speed - This will cause your object to float around corners and cut through what should be solid walls. This is amplified by the fact that you are updating your path every second. If the pathfinding has to turn around or pick a new route, then your object has to slowly rotate and turn around. You can increase this to 1000 or 2000 for a tighter turn.

    Remember the solid behavior doesn't affect the movement portion of the pathfinding behavior, only the pathfinding part of it. So as your object was trying to get back on the path, with a slow rotation speed, it would go ahead and go through solid walls. Also with the cell border set to -1, there were basically no solids at all on your layout as far as the pathfinding behavior is concerned.

    If you're making a pacman type game, I suggest building your levels and walls with standard tile sizes, things will run much more smoothly.

  • oosyrag,

    Ok, I understand the cell boarder -1 bit, but if I set it to 0 or 6 as you suggest, how do I get the alien to move? The alien doesn't move unless the cell boarder is set to -1.

    When I set the pathfinder behavior, C3 automatically set the cell size to 30 cell boarder -1. Nothing worked. When I set the cell size to 32 - everything works exactly the way I want it to, Except the solid alien goes through the solid walls. When the settings are changed the alien doesn't move.

    The grid is set to 32x32, with 64 pix between each wall. The alien is 45x45px, 64px is more than enough room for a 45x45 sprite to go between the walls, but even when I make the alien 20x20 it will only move if the cell boarder is set to -1.

    It all words great Except the alien doesn't seem to understand it's not supposed to go through the walls.

    How do I tell the alien - do everything you're doing - except don't go through the walls?

  • As I said before, you need to lower the cell size, change the border to 0, and increase the rotation speed.

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