Page 1 of 1

Need help with school simulation project

PostPosted: Sun Mar 31, 2013 11:34 am
by Rayzen
Hello, i'm making a simulation about a project for college to get my license, i don't have the money to make the devices so a simulation works too, the project is about a device that would go in every car, think of it like it would be as standard in every car as airbags, the role of it is to take several data from devices throughout the car, devices like impact sensors, gps and a speedometer, after that the information is recorded and transmitted to an emergency server that's hooked up to the police, hospitals and fire departments, it generally will be used to do two things: first is when the car goes over let's say 60 km/h a ticket is given to the driver, second thing is, upon impact (read accident) the system automatically announces the car had an accident to the primary server and from there police/hospitals/fire departments can be announced about the accident and it's location.

Anyway i wanted to use game editor to make a simulation, i knew it'd be 2d but then i stumbled upon a game called NeonZRacing made by DST, so i played around with it and decided i'd use it as my base( i hope he doesn't mind, of course i'll give credit to him), so after modiffying it to suit my needs i've reached a point where my lack of programming skills is showing. :oops:

Read below for the problem.

The thing i need now is to be able to place some obstacle, i'm thinking of a pillar or something like that in the 3d environment, i need that so i can do collisions next, those are easy to do and i'll do them after this problem is solved. So if anyone can help me place an object in that environment i'd be most grateful.

Another problem i have can be found in script> meter -> Draw Actor , when i do if(speed=6) it sets the speed to 6(which is actually 60 cause i did *10 but that's not the point) instead of playing the sound when it reaches 60 km/h, i want it to play the sound once, to go around this problem i made it so it doesn't play the sound when below 5.9 or above 9, so i don't know why it sets the speed instead of doing what is said in that condition, the speed is 6.

Other things to note about the simulation:

You can control the car by the keyboard arrows, also pressing control a number of times switches gears, press just keyboard up and you can go to 50 km/h, keep pressing key up and ctrl once and you can go to 100 km/h, and so on until 300 km/h, anyway when you press key left or right it resets your gear switch, so you need to press it the number of times you want again to gain the speed you want, for example, you hit control 2 times and so you get 150 km/h, then you turn left and now the speed maintaines, but if you press ctrl once it goes down to 100km/h, if you press it twice fast you won't notice any decrease, to go above 150 ofc you'll have to press 3 times or more.

The version i did also has a bug, if the minimap goes red just stop the simulation and start it again untill it works, although it doesn't matter much, if i can't fix it i'll probably have to take it out, so if you have any ideas i'd greatly appreciate it.

The topside view of the car and the glowing lights in it are going to be used to determine the point of impact when the collision is made, the lights will activate then, it's not finished ofc so don't worry about it, for now you can change the transparency of that car by + and - on numpad. I'm going to put collision actors in the primary car and connect them with the "impact sensors" from the topside view car when i'll do collisions.

Don't mind the 2 animations in the topside corners they're just for fun until i finish.

The two links are dst's original work and the version i made for my simulation. Thank you. :)
Image

Re: Need help with school simulation project

PostPosted: Thu Apr 04, 2013 11:47 pm
by skydereign
Rayzen wrote:Another problem i have can be found in script> meter -> Draw Actor , when i do if(speed=6) it sets the speed to 6(which is actually 60 cause i did *10 but that's not the point) instead of playing the sound when it reaches 60 km/h, i want it to play the sound once, to go around this problem i made it so it doesn't play the sound when below 5.9 or above 9, so i don't know why it sets the speed instead of doing what is said in that condition, the speed is 6.

= will set the left equal to the right, while == will check if the left is equal to the right. So if you use one equals, chances are it isn't what you want, and that it will always be true (unless setting the number equal to 0).

Re: Need help with school simulation project

PostPosted: Fri Apr 05, 2013 11:08 am
by Rayzen
I did
Code: Select all
if(speed==6){PlaySound2("data/Alarma.wav", 1.000000, 1, 0.000000);
                   }

before and tryed it again just to be sure i wasn't remembering wrong, but it doesn't play the sound when it hits 6(60), i don't know why it doesn't work, if anyone knows of another way to make it play a sound when it hits 60 that would be great too.

Re: Need help with school simulation project

PostPosted: Fri Apr 05, 2013 5:43 pm
by skydereign
Rayzen wrote:I did
Code: Select all
if(speed==6){PlaySound2("data/Alarma.wav", 1.000000, 1, 0.000000);
                   }

before and tryed it again just to be sure i wasn't remembering wrong, but it doesn't play the sound when it hits 6(60), i don't know why it doesn't work, if anyone knows of another way to make it play a sound when it hits 60 that would be great too.

Have you checked if it actually ever hits 60? If you accelerate at a speed that bypasses 60 (or 6 in this case) the if statement won't trigger. A better way to do it would be to use ranges, so if(speed>=6 && state==0). The use of the variable state is to prevent that code from repeating, since within the if statement, you'll set the state of the car to be something non-zero to signify its speed. Alternately you could use a temp variable at the top to hold the old value of speed, and then check using those temp_speed<6 && speed>=6.

Re: Need help with school simulation project

PostPosted: Tue May 21, 2013 11:22 am
by Rayzen
Hello again, i've managed to place some pillars in the simulation, but now i can't seem to get collisions to work.

I've placed pillars using the draw_from function using as placement a number in the track1.txt file.

When i tryed to do collisions it doesn't seem to want to do them, i've also placed the pillar normally and caused it to move toward the car, with that method the collision works, so it seems there's a problem with draw_from collisions, if anyone knows how to do collisions with draw_from when getting the coordinates for placing from a txt file please help, the deadline is looming ever so closely above the head of my project, and it's holding an axe and not a crown, if you know what i mean =(

The code with draw_from can be found in Script Editor> Canvos> Draw actor

Thank you.