How do have new instances of a sprite have collision enabled?

0 favourites
  • 8 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • I'm using the Drag and Drop behavior, and I want it so that when the player drops an instance of a specific object, if it is overlapping with another instance of that object then the dropped instance goes back to where it was picked up. I already have the code for the second part and I know it works because it works with different conditions. However, it doesn't seem to work with this. I think it's because the object doesn't have collision enabled, however, I can't seem to get it enabled. I've tried using the action "enable collision" both at layout start and when a new instance is created, but neither is working.

    No instances start on the layout, they are spawned in over the course of the game.

  • You'll need specific events if it's the same object, I don't expect it to be related to collision. Did you try it with that object and a different object?

  • How would I detect collision with another instance of the same object then? There's a different way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When you use on drop condition it narrows the picked instances to 1. So when you then say sprite overlapping sprite it is checking if its overlapping itself not the instances that you think are involved in the overlap. This is why your current logic isn't working.

    There are a few ways you can fix that, some people use a Family, so when you say Sprite on dropped, is overlapping Family, you can easily pick between the one being dropped which is the Sprite and the one overlapping which is the Family (the Family just contains the same Sprite object).

    There is also a system condition you can use called 'Pick nth instance' you can use this to pick the 0 and 1 instance in the overlap, however you cannot use this immediately after the on drop condition for reasons mentioned above.

    Also you could identify the one being dropped in some way by setting a variable. If you open up the instances to be picked again then this could work. For example on drop - run a function that inside has sprite overlapping sprite condition, then with a sub event pick the sprite where the variable is set and then you can use actions on it.

  • Thanks!

  • Sorry, could you elaborate on an example of the last method? I'm having trouble figuring it out.

  • Like this you can see how it picks out the one you are dropping.

  • Ahh, that helps I think, thank you!

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