0 Favourites

Spawn Overlap Problem

  • Hi folks

    Having an issue with spawning multiple instances of the same object. My sprite is 32*32 with an image point at 49,16 (where it spawns its child).

    Basically, I don't want to spawn a new child if one of its brethren is in the way. So I tried this:

    <img src="http://img534.imageshack.us/img534/594/spawnproblem.png" border="0" />

    Specifically, I though the "Mob X Overlapping" would stop it spawning on top of an existing instance. Unfortunately, I was wrong.

    Is it not possible to do this? Should I pin another sprite so I can check for overlap on that instead? Or have I just done something daft.

    Thanks in advance for any help.

  • Make your 'not overlapping" condition like this:

    Not overlapping Mob at offset (Mob.imagepointX(1), Mob.ImagepointY(1))

    This condition checks if there is overlapping mob at location of the designated imagepoint.

    I am assuming that imagepoint you are checking for is imagepoint 1. Imagepoint 0 should always be your objects origin :)

  • Thanks for the feedback vee.

    That's much more efficient than messing about with maths. However, they still spawn on top of each other. Am using imagepoint 1.

  • Thanks for the feedback vee.

    That's much more efficient than messing about with maths. However, they still spawn on top of each other. Am using imagepoint 1.

    Then you should check that your sprites collision polygon is properly set. Posting a .capx of your problem would also make it easier to see what is the cause for that :)

  • Haven't tried sharing a non image file on here.....

    dropbox.com/s/mi3awr2r9o9kzaj/Alife2.capx

    Let's see if that works.

    Be warned, you may find my programming painfully naive.

  • My bad, the formula for checking overlap would actually be:

    Mob.ImagePointX(1) - Mob.X

    Mob.ImagePointY(1) - Mob.Y

    as it's offset from the object and not direct location coordinates :)

    Anyway, seems there is another problem when checking for overlaps from same objects, couldn't quite understand why. Probably someone else can shed some light on this? Does it perhaps have something to do with picking, like both of the objects are picked when checking for overlap and something weird happens?

    One way to go around this would be to add 'mob' into a family and check if there is overlap with that family. Not the most elegant way but seems to work.

  • Thanks again, vee. I'll have a go at using families.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Indeed, only solved by sticking Mobs in a family.

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