Yes i am going to learn more about unity before i try this but i want to take notes on this so when im ready i can do it. So how would i get the main character to be able to get into a car? I figured i could use raycast to see if a car is close enough then press a key and play an animation with the main character getting in the car. But i dont know how to write a script like that. Can someone help me? and radio stations to
Basically, the steps that I would take would be to, first have your character model. then get all the animations for it to walk around. Then you need an animation for it to open a car door, or if it is an open vehicle like a buggy or something, then just have an animation for the player getting into the seat. Obviously you would need a setup so that when the player enters the car, the control changes from the characters walk around script to the car driving script
Then what I would do for radio stations, is get each different radio station into it’s own single audio file, so if you had five radio stations, then you would have five audio files, where each different audio file is each different radio station. Then have a script that is set so that when the player hits the “change radio” button, it goes from one audio file to another.
That script might look something like this:
private var radioStation = "off";
function Update()
if(Input.GetKeyDown("tab")){
if(radioStation == "off"){
radioStation = "station1";
}
else if(radioStation == "station1"){
radioStation = "station2";
}
else if(radioStation == "station2"){
radioStation = "station3";
}
else if(radioStation == "station3"){
radioStation = "station4";
}
else if(radioStation == "station4"){
radioStation = "station5";
}
else if(radioStation == "station5"){
radioStation = "off";
}
if(radioStation == "station1"){
//PLAY STATION ONE FILE HERE
}
else if(radioStation == "station2"){
//PLAY STATION TWO FILE HERE
}
else if(radioStation == "station3"){
//PLAY STATION THREE FILE HERE
}
else if(radioStation == "station4"){
//PLAY STATION FOUR FILE HERE
}
else if(radioStation == "station5"){
//PLAY STATION FIVE FILE HERE
}
}
Hope this has helped you get an idea…
Feel free to comment back if you have any questions!!!
-Grady
It would be more realistic if all radio stations were playing constantly, but the inactive ones have volume set to zero and the one that is active has its volume up. This is because in real life (and GTA), radio stations continue even when switched off. I made it work perfectly in the Scratch Programming Language. What about Unity (C#/Javascript)?