Double-Fine-Game-Club / bad-golf-community-edition

A community developed version of Patrick Hackett's Bad Golf Amnesia Fortnight pitch!
Other
52 stars 38 forks source link

Split Screen Mode/Multiple Player Input #62

Open Cheeseness opened 10 years ago

Cheeseness commented 10 years ago

We currently have a split screen view in-game, but multiple input devices is not handled yet.

The big question to ask here is whether mutliple input devices and local multiplayer is something to look at on in the short term, or whether we should entirely focus on networked multiplayer for now.

I've been following a cross-platform input library for Unity called InControl for a little while. It might be a good option to look towards as Unity's built in input handlers aren't very consistent across operating systems.

Slimliner commented 10 years ago

I've looked into this a little bit, and I think the controller part and so aren't that bad, but the real problem is the audio listeners. You're only allowed to have one audio listener in the scene, and since we want to play the sound from each camera, you need to create some script to handle that. It seems non trivial to do. I think it might be possible to try to create a listener in the center of the screen, and somehow move the audio sources to the right place in regard to that point, but it's beyond me, and not even sure if that is the way to go. If we want to have this, this problem needs to be solved or atleast have a plan that's doable.

Cheeseness commented 10 years ago

@Slimliner Perhaps disabling positional audio altogether is the way to go here. There's no solution that we could come up with that would be congruent for all players, so trying to do anything would probably be a step in the wrong direction.

Cheeseness commented 10 years ago

@Slimliner I had a quick look at your fork. It looks like there's some stuff missing. I didn't have time to look, but @bobsayshilol suggested there may be DLLs that are excluded by .gitignore (you can still add them explicitly). Would you mind checking that out?

adipirro commented 10 years ago

Keeping positional audio with multiple players would be feasible using @Slimliner's suggestion. I've given it a bit of thought and here is how I would go about it:

For starters I would make an extension method for AudioSources called "PlayGolfAudio()" which would pass the audio source off to a Coroutine to manage its positioning. This way, the programmers could set up audiosources in the normal fashion and then just call "aSource.PlayGolfAudio()" instead of "aSource.Play()".

The Coroutine would start by collecting references to all player cameras and the central audio listener. It would also create a new GameObject with the audio source on it for each player. Then, every frame, the Coroutine would check the original audio source's position in relation to each camera and update the new GameObject position's accordingly(in relation to the central listener). The code for setting the positions would be very simple:

p1Source.transform.position = centralListener.transform.position + (ogSource.transform.position - p1Camera.transform.position);

Once the audio source is done playing the Coroutine could destroy the GameObjects it created and end.

Cheeseness commented 10 years ago

@thegsm has asked if people can offer feedback on pull request #107

thegsm commented 10 years ago

I started a component for positional audio, it will be more generic than the changes I currently did in car audio but the idea will be very much the same. So the way it will work is that you'll have one audio listener in the scene and if you add more audio sources they have to be via the positional audio component. It means audio listener should no longer be linked to a specific camera and audio sources need to be linked to this component. Just want to ensure those working on the levels can work with this method.

Cheeseness commented 10 years ago

@ErikBehar has brought in a bunch of local multiplayer stuff in his merge of the localmulti branch last night.

Cheeseness commented 10 years ago

@thegsm Were you able to get anywhere with your positional audio solution?

thegsm commented 10 years ago

@Cheeseness, I did not touch this recently, but I agree it's time given the recent work on the code. I believe it will require some changes to the audio manager, so I just want to ensure there's no one who is doing something major there as well (or at least make sure I'm notified before so we don't get complex merges).

I'm juggling some other projects, so I'll start in a few days. Since that coding part is not trivial, it will take a bit of time, I still think it's doable, but I'll give a shout out if I see it doesn't converge.

Cheeseness commented 10 years ago

Alrighty, sounds good. If anybody's doing deep reaching sound manager changes, they're doing them without my knowledge. You're welcome to tackle it when you're ready :)