Destroy the object if too many objects overlap each other.

0 favourites
  • 3 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hey,

    I'm creating an event that generates clouds randomly to the background. I don't want too many clouds to overlap, however. I want to create events that destroy the cloud directly after it is created if it overlaps too many other clouds.

    I tried to do this by using an instance variable to measure how many other clouds a cloud is overlapping, for each loop, and PickedCount.

    Event: If object "Cloud" is overlapping "Cloud".

    Sub-event: For each "Cloud".

    Sub-sub-event: "Cloud" is overlapping "Cloud" => Action: Set instance variable "overlap count" Clouds.PickedCount.

    Sub-sub event: If instance variable "overlap count" > 4 => Action: destroy "Cloud".

    However, this doesn't seem to work. It seems like in this instance the program doesn't recognize when clouds are overlapping each other.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For overlap of the same "Cloud" add Cloud to a family and check if Cloud overlap family.

  • You need to use a family -> "For each Cloud, Cloud is overlapping CloudFamily". But be aware, that instances are not destroyed immediately. So the loop will destroy all overlapping clouds if you don't exclude already destroyed instances.

    I think it will be easier to do in "On created" event:

    Cloud on created
    Cloud is overlapping CloudFamily
    CloudFamily.pickedCount>2 
    	: Cloud destroy
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)