How do I add collision for specific families?

0 favourites
  • 9 posts
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Right now I'm using the Solid behaviour on my player character and enemies to prevent them from moving through each other. They are in separate families for obvious reasons.

    Now I want to add a "friendly NPC" family that will attack enemies but allow me to pass through, so the Solid behaviour on its own wouldn't be enough to solve this.

    Is there a way to do this with the Solid behaviour or do I need some fancy events?

  • Is this a platformer game? Using Solid behavior with moving player and enemies is not a good idea. I would probably do this with events instead, using "is overlapping" and "is overlapping at offset" conditions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How do you use those events to simulate collision? Google hasn't found anything useful, and simply preventing movement will trap the player inside the other object.

    Don't know if this is useful information, but you can't jump in the game, it's just left to right movement with the 8 direction behaviour.

  • Fixed this by using the "On collision with another object" condition and the "Stop" action on the 8 direction behaviour.

    This didn't work with the overlap condition since the player would just gradually move through the object anyway. I don't really know why that happens, but it works now.

  • Never mind, I only just now realised I had left the Solid behaviour on... any other input is appreciated.

  • It's hard to help you without seeing your code or project file. How do you move the enemies? Are they always moving towards the player?

    You can do something like this:

    Enemies compare X > (Player.X+50) .... Enemies simulate control Left
    
    Enemies compare X < (Player.X-50) .... Enemies simulate control Right
    

    This way enemies will stop within 50px from the player.

  • Here's my project file: ufile.io/pzdib

    Right now it's just two objects with the 8 direction behaviour, and that's it. In the future I want the enemy to chase the player and start attacking on collision.

    I've tried your example, but the objects will just push each other around. I've also tried using Set X instead of Simulate Control, which causes a lot of jittering.

  • I don't understand, so you are controlling both the player and the enemy?? Or is this a temporary thing, just for testing?

    Try this one:

    dropbox.com/s/18yv1gkey4zsm6e/projectscroller.c3p

  • That's exactly the kind of behaviour I want. Thanks.

    And yeah, I'm only controlling the enemies for testing. Once I've got more systems in place I'll start spawning the enemies and give them AI.

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