How do I Move created object to empty spot then stop.

0 favourites
  • 5 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • I'm currently trying to spawn a created object to an empty spot against a wall, then having it stop. Followed by creating another object and having do the same. I guess think tetris but creating the object at the furthest empty left location.

    I currently have something like this:

    Create object Mouse animalfamily.X +25, animalfamily.Y

    Create object Horse animalfamily.X +50, animalfamily.Y

    Create object Snake animalfamily.X +75, animalfamily.Y

    This leaves a blank spot if one does not exist.

    I have tried this a few different ways this was the closest I got:

    Create object Mouse animalfamily.X + (animalfamily.count x 25), animalfamily.Y

    Create object Horse animalfamily.X + (animalfamily.count x 25), animalfamily.Y

    Create object Snake animalfamily.X + (animalfamily.count x 25), animalfamily.Y

    The issue is this kept making objects over and over until they ran off screen? removing the animalfamily.count to find how far to place the object via X location only makes one but again it wont test for an empty spot.

    Please if I can help you help me by answering any questions feel free to let me know how I can clear up any confusion in my question.


  • Still trying to figure out how to test an empty spot to spawn an object at. Can anyone give me anything to at least attempt or get my brain turning? Only thing I can think is testing if a space DOESN'T have one at an over lapping point if so set X to that. I guess I can try that. Too but I'm still kind of coming up blank.

  • Could you explain what you want to do rather than what you are doing?

    Possibly a repeat x times, or using a loop will solve your issue, but it's not clear when and how you'd like the objects to be created..

  • The player obtains the objects: cat dog and horse. I'm trying to display those as objects that can then be interacted with.

    When they buy or obtain an animal I'm trying to create an object at the top left of their screen.

    Then if they obtain another animal I want to make that object 25 pixels right of the current object. Basically like an inventory.

    I have a set X location for each animal Cat = x 25, dog = x 50, horse = x 75. Making a nice neat line of all the animals you own. The problem I'm having is if they don't have the animal then there is a gap, due to the set x location.

    I just want the first of ANY type of animal to be located at x 25, the second animal at x50, and so on.

    If they have a Cat, dog and horse, I want these objects to be made at Cat x25, dog x50, horse x75. Should they sell the cat I want the dog to be made at x25 and horse x50.

    Something like so:

    On start of layout,

    if Cat is "owned",

    is x25 empty?, yes: create object Cat x25

    no: is x50 empty? yes: create object Cat x50

    if dog is "owned",

    is x25 empty?, yes: create object Dog x25

    no: is x50 empty? yes: create object Dog x50

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I resolved it -.- trigger once for the win....

    On start of layout "barn"

    if Mouse "owned"

    Trigger Once: Create object Mouse animalfamily.X + (animalfamily.count * 25), animalfamily.Y

    if Horse "owned"

    Trigger Once: Create object Horse animalfamily.X + (animalfamily.count * 25), animalfamily.Y

    if Snake "owned"

    Trigger Once: Create object Snake animalfamily.X + (animalfamily.count * 25), animalfamily.Y

    Only displays owned animals and picks X location based on how many of the family are current. Puts Mouse at 25, then Horse 50 since animalfamily.count went up by 1.


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