Collision Issues when using Families

0 favourites
  • 3 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hey everyone,

    I'm fairly new to Construct and am encountering an issue I have been unsuccessful in resolving for several days. I have combed the forums and spent a lot of time testing different solutions, but nothing has worked thus far.

    https://www.dropbox.com/s/d5tf8m99ulfmp7c/Untitled_rolling_ball_game_test.capx?dl=0

    Game Objective

    The goal of the game is for the player to create a path using the available blocks at the bottom to reach the goal (checkered black and white box). When the player drags a block overlapping another block or within LOS (64 pixels) and drops it, the block will pin to that block, allowing the player to construct paths for the ball fairly quickly. I'm using families to control the majority of the logic for the blocks. Using families resolved a lot of the earlier issues I was having (instances of the same object type not pinning together, etc.). However, it has caused a new issue I wasn't encountering when not using families.

    The Issue

    When a block leaves the UI block and is dropped on the blue tiled background, collisions with the ball should be enabled. When a block is being dragged, collisions with the ball should be disabled. This works for the most part, except when I'm dragging an instance of a block that already exists on the blue tiled background. Collision is disabled for all instances of the object type, not just the block I'm dragging.

    Solution Attempts

    I'm willing to bet the issue comes from a lack of understanding on how Famiilies function on my part. Here is what I've tried so far to fix the problem:

    1.I tried creating a Boolean instance variable on each individual block instead of the family called 'canCollide'. When a block is dropped on the grid, the 'canCollide' Boolean instance variable is turned on. When a block has the 'canCollide' instance variable set to true, collision with the ball is enabled. This didn't seem to make any difference.

    2. Stop using families and program each individual block. The issue when I do this is I can no longer pin instances of the same object type to each other, which is critical for the "feel" of the game. Pinning blocks to one another has to be fast.

    Any help you all could provide would be hugely appreciated. Please let me know if any additional information is needed. Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think the problem has nothing to do with families. "Physics disable collisions" action affects all instances of this object, you can not disable it just for one.

    I suggest you disable Physics behavior for the dragged block, and re-enable it on drop.

    By the way, you should avoid mixing Physics with other behaviors - Pin, BoundToLayout etc. It may cause all kinds of bugs. So this is another reason why you should disable Physics while dragging the block. And when it's dropped, make it immovable instead of pinning.

  • Thank you so much! I really appreciate the suggested fix and the advice about mixing physics with other behaviors. I'm going to take another look and see if there is another way I can accomplish my intended outcome.

    Thanks again!

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