Gives for creating Set Value random variable?

Discussion and feedback on Construct 2

Post » Mon Mar 17, 2014 5:06 am

I got a Global Attack Number = 0

Except that when I tap the "A button", I apply a "Set Value" in varible attack for it to be random from 0 to 4.

Image


The number to leave the set value random, do a different attack when he collision with the target object.

Is to make it so? Or have another way to do this using variable?
The developer of Dunar: Dimension Two



2017-Thistom Studios Software
B
20
S
4
G
4
Posts: 35
Reputation: 4,110

Post » Mon Mar 17, 2014 12:02 pm

It's hard to understand what you mean, but here's some tips.

You can use the expression 'Choose(0,1,2,3,4)' for picking a value randomly.
Set position will make your object 'blink' to the position, so there'll be no moving effect.
If you want it, you can use bullet behavior, or custom plugin like "Move to".
B
23
S
8
G
1
Posts: 172
Reputation: 2,780

Post » Mon Mar 17, 2014 1:57 pm

@ sharecast

I did the test here and it worked.

'Choose (0,1,2,3,4)' Just needed to know to do that.

Now I can create AI of enemie for balhata shift system.

Thank you!
The developer of Dunar: Dimension Two



2017-Thistom Studios Software
B
20
S
4
G
4
Posts: 35
Reputation: 4,110

Post » Fri Feb 23, 2018 1:46 am

I would like to assign a value between 0 and 151 ... :geek: There is not another expression to add to choose? I do not necessarily want to write all 151 possibilities. :cry:
B
8
S
3
G
1
Posts: 61
Reputation: 1,282

Post » Fri Feb 23, 2018 2:12 am

@Banatawa
Use random(151) - this will return a number from 0 to 150.99999999999
So you if you want to round it to the nearest integer:
round(random(151))
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
156
Posts: 2,209
Reputation: 82,999

Post » Fri Feb 23, 2018 5:58 am

Thank you !
B
8
S
3
G
1
Posts: 61
Reputation: 1,282

Post » Wed Feb 28, 2018 1:33 pm

dop2000 wrote:@Banatawa
Use random(151) - this will return a number from 0 to 150.99999999999
So you if you want to round it to the nearest integer:
round(random(151))

And if I want to pick a number between, for exemple, 10 and 40?
B
8
S
3
G
1
Posts: 61
Reputation: 1,282

Post » Wed Feb 28, 2018 1:48 pm

random(10, 41)
ImageImageImage
B
72
S
22
G
288
Posts: 3,862
Reputation: 158,460


Return to Construct 2 General

Who is online

Users browsing this forum: John Cutter and 1 guest