Search the Community
Showing results for tags 'Spawns'.
-
So I am rather new to c++ and lua programming. I understand the basics of what the code I want is, just not how to express them. I want to choose between a number of things to randomly spawn in specific locations (like have one location but every time you return it is a diffrent item). I have the prefabs set up in the engine, and I want to assosiate those prefabs in the code with a number, and have the random number generator (which I have and it works) pick a number and then after that number is picked, spawn the item. I understand that for each piece I would have to do an If() statment, but don't understand how to make it spawn on the axis I set up in the map. Also The code I tried (but deleted because of it making leadwerks crash when it activated) would choose the number, but not be able to read what the number was supposed to be assosiated with. Any help, even just points in the right direction, would be very appreciated. #include<iostream.h> #include<conio.h> #include<stdlib.h> void main() { //clear the screen. clrscr(); //declare variables as int. int high,low,random; //get the data. cout<<"Enter higher limit:"; cin>>high; cout<<"Enter lower limit:"; cin>>low; //generate random number random = (rand() % (high-low+1) + low); //print the numbers cout<<random<<endl; //get character getch(); } that is my random number generator code (that I use to choose the items( I use the code several diffrent time for diffrent items))