How do I do random jump?

Get help using Construct 2

Post » Fri Jun 12, 2015 2:04 pm

Hello to everyone

In my game i have ennemies who are spawned/created every 5seconds, i would like to make them JUST to do randoms jumps.

How to tell to the sprites to jump randamly but NOT ALL at the same time??
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Fri Jun 12, 2015 2:30 pm

Create a "A" variable to generate random numbers every second, every tick, whatever you prefer.
Create a "B" variable to generate random values.
Create a Instance variable "C" on your enemies that will hold any value.
For each enemy you spawn, set it's stance variable "C" to the value of the variable B.
Then every tick, or every second, or whatever you prefer, compare the values of "C" for each enemy in game. And then set a command to whenever "C" has the same value of "A" simulate the enemy's jump.
;)
B
17
S
7
Posts: 277
Reputation: 2,514

Post » Fri Jun 12, 2015 2:34 pm

You could try putting all the enemies in a Family. If you reference the family in your events, each instance will move individually.

So you could do something like...
Every "random(A, B)" seconds -- EnemyFamily is on screen ----------- EnemyFamily - Y vector "number"

I think that might work.
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Fri Jun 12, 2015 2:51 pm

how to add the enemis to a familly? i don't see that option
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Fri Jun 12, 2015 5:00 pm

I hate being the guy to just link to the manual, but it really explains it well...
https://www.scirra.com/manual/142/families
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683


Return to How do I....?

Who is online

Users browsing this forum: datiel12, tarek2, Yahoo [Bot] and 59 guests