An object randomly created along with another object?

  • Well, I would like to know how do we works on this....

    Object 1 : Moon

    Object 2: Star

    So on the layer, the Moon is randomly appear in a given condition. But can we set the Star appear must tag along with the Moon??? Mean the rule for Star is not location based, but stick to Moon

  • If I understand correctly you want to spawn and position the star when spawning the moon, in a position based around the room, like some random offset to the moon?

    Have you tried to spawn the star with System>Trigger Once, as event for the moon?

  • If I understand correctly you want to spawn and position the star when spawning the moon, in a position based around the room, like some random offset to the moon?

    Have you tried to spawn the star with System>Trigger Once, as event for the moon?

    Yup. Great you understand what issue i m facing...

    but the System > Trigger Once is purely an "If" conditional function....additional, the trigger unable to provide the location of the Star to be spawn

    Any sifu helps out pls.

  • try the Misc > On created as event for the moon

    spawning the star at a random offset from the moon is done thorugh Size & Position > Set position with X being something like Moon.X+random(Range[-100,100]]

    or something like that, look up the syntax

    plus the corresponding line for Y, of course

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • try the Misc > On created as event for the moon

    spawning the star at a random offset from the moon is done thorugh Size & Position > Set position with X being something like Moon.X+random(Range[-100,100]]

    or something like that, look up the syntax

    plus the corresponding line for Y, of course

    Hi.facecrime, thanks for your respond. I have not try, but seem it possible work. However, wondering due to the moon position is unfix, so will there be an issue?

    Secondly, was wondering will it works will spawn more than 2 moon?

  • https://www.scirra.com/manual/125/system-actions

    Create object

    Create a new instance of an object type on a layer at a given position. If a Family is chosen, a random object type from the family is picked, and an instance created for that.

  • that's what the 'Moon.X' part is about, it says 'take the Moon's X value, no matter what it is and add some random offset'

    Note: The offset won't update if you do it only OnCreated. if your moon is moving and you want to maintain your offset to it, you either 'Pin' it to the moon or store the offset away in an instance variable and re-apply it every tick.

  • that's what the 'Moon.X' part is about, it says 'take the Moon's X value, no matter what it is and add some random offset'

    Note: The offset won't update if you do it only OnCreated. if your moon is moving and you want to maintain your offset to it, you either 'Pin' it to the moon or store the offset away in an instance variable and re-apply it every tick.

    thnaks, will try it tomorrow

  • How to generate the "Moon.X"

    what's the "dot" mean? (sorry for my super nob question)

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