SanAndreasUnity icon indicating copy to clipboard operation
SanAndreasUnity copied to clipboard

Implemented horn sound base functionality

Open AdamLacko opened this issue 4 years ago • 3 comments

-Added GetKey method (modified copy of GetKeyDown method already present there) in CustomInput to operate continuous key pressing

-Looping of the horn sound is still not perfect yet. As we discussed before, problem is apparently in the original horn sounds SA engine was most probably modifying at runtime to better blend.

-I do have concerns about the method MakeSubclip() that is used to create loop-able sample for AudioSource, as it hasn't been tested for leaks yet. There are probably none, but it's a good practice to test it anyways. So should be tested horn AudioSource, since it has to be created additionally (due to new radio implementation which already uses one AudioSource), to prevent more of these components being created on, say, scene loads or whenever Awake is additionally called (but I reckon such scenario is not very common in game like this? I'm thinking this further as I work with RPGs where such scenario is quite common). I'll do all this in future commints.

-There is a doppler effect on horn sound. It sounds good in environment, although the effect is also laudable for the player inside car as well. This can be prevented pretty easily though, I'll implement that in next commit.

AdamLacko avatar Nov 15 '19 11:11 AdamLacko

TODO:

  • Make looping of the sound better.
  • PlayerController.ReadEvents() is used to read events, not states. With GetKey() you are reading the state of the key. ReadStates() is used for reading states.
  • BaseScriptState should not be aware of vehicles. Yes, it should have OnHornButtonPressed(), but it should not handle the logic for this. The logic should be handled in VehicleSittingState.
  • Vehicle.IsHornOn has a wrong name. It's name suggests in what state is the horn, but you are using it as 'was horn button pressed this frame'.
  • Use different sound for different type of vehicle.
  • You are creating memory leaks. Every created AudioClip should be destroyed. Or, even better solution would be to create AudioClip only once during application lifetime and store it in a static variable.
  • Should work in multiplayer (I don't think it works right now)
  • As for CustomInput - again, you don't understand the difference between key state and key event. GetKey() is used for state, GetKeyDown() is used for event.

in0finite avatar Nov 17 '19 15:11 in0finite

rip P/R

Bluscream avatar Sep 24 '20 19:09 Bluscream

Umm,,mmmmmm

TheBatter32 avatar Nov 17 '21 12:11 TheBatter32