Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / randomize placements

Author
Message
scythe_reaver
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 15th Nov 2011 16:38
i have a model that i want to use as decoration, but i want to randomize where the pop up at, not only to add more replayability to the game, but to reduce the amount of coding that i have to go in and place each object by hand. How can i make the model appear like 10-15 times in random positions?

http://www.shrinkpictures.com/processed/phprZ6E7O_c2AM.jpg
"I AM YOUR GOD OF DEATH"
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 15th Nov 2011 21:42
Here's a crude concept. You'll have to extrapolate on this and customise it to suit your needs.



scythe_reaver
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 15th Nov 2011 23:31
ok, i will try this out, thanks again so much nonZero.

http://www.shrinkpictures.com/processed/phprZ6E7O_c2AM.jpg
"I AM YOUR GOD OF DEATH"
scythe_reaver
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 16th Nov 2011 15:54
how should the code look? like this?


http://www.shrinkpictures.com/processed/phprZ6E7O_c2AM.jpg
"I AM YOUR GOD OF DEATH"
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 16th Nov 2011 16:31
Quote: "how should the code look? like this?"

Not really. You are now loading the same model 3 times with the same model number and trying to assign is seperate XYZ coords. Check the DBPro help for the correct syntax on LOAD OBJECT and POSITION OBJECT.


*The way you were assigning positions "x = rnd(1999), y = rnd(1999), z = 0" would effectively place models in mid-air (forgive me if that was you intention). X-axis is left-right, Y-axis is up-down and Z-axis is depth. So effectively, you want all your static models on the same Y-level (unless your terrain is bumpy but we'll keep it flat for argument's sake). Run the code below for a more graphical representation:



scythe_reaver
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 16th Nov 2011 19:30 Edited at: 17th Nov 2011 16:19
Ok, thanks so much. I'm new to DBP, I forgot Y is up and down. Yes the terrain
Is flat. Thanks for all your help!


edit: hey, it says object already exists when i try and load the object, why?


if you need all the coding here it is :\


http://www.shrinkpictures.com/processed/phprZ6E7O_c2AM.jpg
"I AM YOUR GOD OF DEATH"
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 18th Nov 2011 07:50 Edited at: 18th Nov 2011 07:52
You have already used object number 10 in a previous FOR-loop:



nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 18th Nov 2011 07:59 Edited at: 18th Nov 2011 08:00
May I suggest you track the number you use in objects at the top of your programs.



Login to post a reply

Server time is: 2024-05-20 07:35:06
Your offset time is: 2024-05-20 07:35:06