How do I math to create object random spot

Get help using Construct 2

Post » Thu Dec 18, 2014 11:45 pm

need some math that will create an object at random time intervals in randome locations... tried random(window.height,window.width) but that didn't work
Need Sprites For Your Next Project?
100% Vector Animated Sprites
B
8
S
2
Posts: 170
Reputation: 1,086

Post » Thu Dec 18, 2014 11:52 pm

Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Fri Dec 19, 2014 12:07 am

desjardins2014 wrote:need some math that will create an object at random time intervals in randome locations... tried random(window.height,window.width) but that didn't work


for starters it's X, Y (width, height) not Y,X
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Dec 19, 2014 12:57 pm

Try this demo
You do not have the required permissions to view the files attached to this post.
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535

Post » Fri Dec 19, 2014 3:23 pm

thanks they both work well - one more thing.... how can I have it AVOID being created ontop of a certain object I have roads set as solids and I dont want them spawning there...
Need Sprites For Your Next Project?
100% Vector Animated Sprites
B
8
S
2
Posts: 170
Reputation: 1,086

Post » Fri Dec 19, 2014 3:33 pm

use solids coordinate and use that as your guide not to spawn objects on
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535

Post » Fri Dec 19, 2014 3:57 pm

got it i figured it out - I actually just set it to check if it is overlapping either and if it is to destoy it and pick another spot... seems to work ok...only prob I having now is the enemy tank runs around but sometimes is getting stuck on the side walls and wont move... I added a buffer to the side walls and added that to his obstacles but he still gets stuck on that now... seems when he rotates he overlaps the buffer and gets stuck...
Need Sprites For Your Next Project?
100% Vector Animated Sprites
B
8
S
2
Posts: 170
Reputation: 1,086


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests