New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
radio #69
radio #69
Conversation
|
Driver has different touch input, so no changes there, but improved other things. |
So, |
@@ -416,7 +417,18 @@ private void Update() | |||
{ | |||
UpdateColors(); | |||
} | |||
|
|||
|
|||
if (currentRadioStation != 0 && Ped.Instance.CurrentVehicle == this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ped.Instance
can be null.
Ped.Instance
must be the driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why driver? passenger cant listen to radio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, passenger should hear radio. But, this way, when ped enters a vehicle as pessenger, ContinueRadio()
will be called which will switch the current song. Am I right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently radio station is not synced between players so I don't see a problem here. And it switches to next song only if last one has stopped playing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it switches to the next song always, because radio.isPlaying
will be false when ped exits the vehicle. Correct me if I am wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will switch song when ped (driver or passenger) enters vehicle. I guess radio should be started in VehicleSittingState.EnterVehicleInternal
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, you can do it from there. But make sure to restore previous time of the song. Don't restart the song every time when ped enters the vehicle.
} | ||
else | ||
{ | ||
currentRadioStationPos = Random.Range(radioStartPos, radioEndPos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Station time should not be randomized every time you switch to that station. It should be randomized on game start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly is good place for that? Vehicle.Start
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static field initializer or OnLoaderFinished()
callback in some manager script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Vehicle.Start
because:
UnityException: RandomRangeInt is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead.
Reverted |
Let me tell you how I imagined radio station times. Each vehicle has it's own active station. But, stations in all vehicles have the same current time (song and song's time). So, if ped changes vehicles, and plays the same station, he should hear the same song. With your setup, each vehicle has it's own current time for station. Plus, all stations have the same current position. It should not be like this. It should mimic the real world. |
Radio station playback position is kept across vehicles and station switches. |
Ok. Will test this tomorrow. |
Implemented playing radio stations in vehicles. Sounds are played in the order they are stored in files. Only driver ped can change station using the same buttons which are used for switching weapons (E and Q on a PC, arrows at bottom of screen when using touch input). Selected radio station is not currently synced between players.