An object randomly created along with another object?

Just started using Construct 2? Post your questions here

Post » Mon Apr 21, 2014 9:06 am

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
B
8
S
1
G
1
Posts: 26
Reputation: 638

Post » Mon Apr 21, 2014 1:10 pm

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?
B
13
S
6
Posts: 222
Reputation: 1,859

Post » Mon Apr 21, 2014 3:37 pm

facecrime wrote: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.
B
8
S
1
G
1
Posts: 26
Reputation: 638

Post » Mon Apr 21, 2014 3:57 pm

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
B
13
S
6
Posts: 222
Reputation: 1,859

Post » Mon Apr 21, 2014 4:13 pm

facecrime wrote: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?
B
8
S
1
G
1
Posts: 26
Reputation: 638

Post » Mon Apr 21, 2014 4:18 pm

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.
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Mon Apr 21, 2014 4:25 pm

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.
B
13
S
6
Posts: 222
Reputation: 1,859

Post » Mon Apr 21, 2014 4:30 pm

facecrime wrote: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
B
8
S
1
G
1
Posts: 26
Reputation: 638

Post » Wed Apr 23, 2014 2:24 pm

How to generate the "Moon.X"
what's the "dot" mean? (sorry for my super nob question)
B
8
S
1
G
1
Posts: 26
Reputation: 638


Return to Beginner's Questions

Who is online

Users browsing this forum: brunopalermo, papnikol and 5 guests