Skip to content
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

Car engine sound #114

Open
in0finite opened this issue Aug 1, 2021 · 2 comments
Open

Car engine sound #114

in0finite opened this issue Aug 1, 2021 · 2 comments
Assignees
Labels

Comments

@in0finite
Copy link
Owner

in0finite commented Aug 1, 2021

Implement car engine sound.

Sound loading already works, use AudioManager.CreateAudioClipFromSfx() to load sounds.

When vehicle is created (eg. in Vehicle.Start()), load it's engine sound. Make sure to cache loaded sounds (eg. in a Dictionary), so we don't have to load them every time.

Each group of vehicles has different sound, so they need to be identified first.

We need to determine current RPM of the engine, so that we can increase or decrease pitch of engine sound. RPM can be determined based on current velocity, maximum velocity and number of gears. Something like this:

float velocityInGear = currentVelocity % (maxVelocity / numGears);
float rpmPercentage = velocityInGear / (maxVelocity / numGears);
audioSource.pitch = rpmPercentage;
@in0finite in0finite added good first issue Good for newcomers feature New feature vehicles audio labels Aug 1, 2021
@LDami
Copy link
Contributor

LDami commented Aug 8, 2021

Your script is not valid, because each gear must have it's ratio (the first gear is short while the fifth is long).
Actually this script works but the gears are splitted equally along the max velocity.

@in0finite
Copy link
Owner Author

Well, yeah you are probably right. Although the ratios are almost equal I would say, so their differences can be ignored, at least for a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants