How to spawn creatures on random line

Get help using Construct 2

Post » Wed Aug 14, 2013 9:07 am

Hi


I have 5 walkpaths (basically one line with 5 instances) and every 5,15,20 secs I spawn object on (x+200,walkpath(random(0,4)))

and this gives me the error

Javascript error!
Uncaught TypeError: Cannot read property 'y' of undefined
http://192.168.2.211:50000/commonace.js, line 174 (col undefined)

when trying to spawn the second one.

Which means probably when random number is generated. :/


Wondering why?
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,662

Post » Wed Aug 14, 2013 9:10 am

Sorry, let me add... so random could generate decimals too.

Added floor(random(0,4)) instead of just random(0,4)

Still the problem exists.
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,662

Post » Wed Aug 14, 2013 9:18 am

walkpath(random(0,4), is not a value, is it?

try changing it to walkpath(int(random(0,4))).y

I'm not sure int is necessary.LittleStain2013-08-14 09:25:21
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Aug 14, 2013 5:23 pm

Sorry that .y was there.. I just forgot to write it here.
it wouldnt accept without the .y anyway :)

Anyway, the problem was another random wrapping it by mistake.

This is fixed :)
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,662


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, busydude and 25 guests