How can I use two Audio Listeners? - unity3d

The problem is that I have a character controller the player with a camera and the camera have a Audio Listener.
But I also have another camera the Main Camera that also have a Audio Listener.
The Main Camera is using Cinemachine Brain and using virtual cameras.
If I disable the Audio Listener on the Main Camera the character in my cut scene will walk to a door/s but when the door/s will open there will be no sound of the door open.
And if I disable the player controller camera Audio Listener then when I will move my player around to door/s there will be no sound when the player enter a door.
And I need both to work. While the character in the cut scene is walking and enter a door and the door is open the player can walk around.
Screenshot of the player controller camera and the audio listener:
And this is the Main Camera Audio Listener screenshot:
So now when running the game the character medea_m_arrebola is walking by animation through a door and there is a sound of the door open and close.
This is part of a cut scene that work in the background I mean the cut scene camera is not enabled yet but you can hear the audio.
Later I will switch between the cameras to show parts of the cut scene.
But now also the FPSController ( Player ) is working and the player can move around but when he will walk through a door the door will open but there will be no audio sound of the door.
And if I will enable both Audio Listeners I will get this warning message in the console in the editor say that more then 2 audio listeners are enabled....etc.

This sounds like a design issue to me. Unity can only handle one AudioListener at a time. You basically have to construct your cutscene-system to work with what Unity offers, or find some kind of workaround to fit your specific case.
You could try to en-/disable your AudioListeners on the fly or maybe use AudioSources around you player dedicated to directional audio input while in a cutscene. (Like a surround sound setup with empty objects) That way you could simulate two AudioListeners. The best case would be if you reworked your system to use one AudioListener for both inputs.
Maybe try a workaround first but if it does not 100% work as intended do the rework. It's worth it in the long run.

Related

Is it possible to play your unity game in scene mode?

Hi I'm working on a simple 2D unity game and it would be so much easier to figure out problems if I could play my game in scene mode so that I could check on every object's values as I go. Is it at all possible to play your game in scene mode?
That is not possible, as of now, in the Unity engine. You would need to handle it yourself. Take the Unity's Cinemachine package as an example. You can tweak the values of a cinemachine virtual camera in-game and store the values as you tweak them if you check the "Save during play". The package is designed in a way that it preserves its state, so when you stop playing, it doesn't lose the changes you made in play mode. Moreover, Cinemachine gives you gizmos that you can tweak the values through the game viewport, not only the inspector.
You would need to do such things for your game so when you start playing, you can, for example, click the gizmos on a puzzle object and change where it sits in the scene, and when you stop playing, the tweaked position would be preserved.
You can read Inputs while being in a custom editor with for example:
if(Event.current.type == EventType.KeyDown
&& Event.current.keyCode == KeyCode.W) {...}
You can read all your wanted inputs and pass it on to your default input scripts. You could make whole games in just the inspector window or whereever you want, but if you should is another question...

Unity3D idle player animation overrides jump animation

I've followed the brackeys tutorials to make a 2D Player Character jump but having issues with the jump animation. When I hit jump, the Player goes into the air but it'll play the idle animation in the air til I give another keyboard input. If I hit jump again while in the air, it'll play the jump animation and go back to idle when hitting the ground.
In the animator I noticed that the jump animation triggers fast and seems to be overridden by the idle animation. I've loaded and compared the working final brackeys project, and rebuilt the animator nodes. The code and everything in the editor are the same but the only thing I can think of is that I'm using different art assets.
Here are the tutorials I followed.
2D Movement: https://www.youtube.com/watch?v=dwcT-Dch0bA
2D Animation: https://www.youtube.com/watch?v=hkaysu1Z-N8
Could you post some screenshots of your Animator Controller, its animation settings or code, please? I suspect it might have something to do with transitions or events.

Is it possible to create a game scene that saves an animation file as an asset in Unity 3D?

I want to know that if it's possible to have a game scene in your game that allows any player to animate a character?
Let's ignore the cognitive load a player will face while animating a character and assume that, somehow, we manage to abstractly present it in a game scene. Can we make it happen that after player's making of certain animation, unity stores that in a .anim file and in the next game scene the player can play a character having that specific animation?
I think calling it real time in-game animation creation would describe it.

Activate Two Cameras At The Same Time

How do I activate 2 cameras at the same time? The first camera follows the character and the second camera follows the character more slowly. After a while we can't see the character with the second camera but the point is each camera renders a special game object. The second camera renders the back game object. So two cameras with each other make better scene moving. Is this possible?
I believe you are looking to implement a scene background parallax where the background appears to be moving across the scene slower than the forground.
Take a look at this video about separating your scene's layers. There is a quick fix solution in the first few minutes of the video, and a longer re-work that is a good idea to think about.
Parallax Scrolling

Simulation like in the fps without flying in the Unreal Engine

When I start the simulation, I want to be able walk on my scene like in the real game, but the player is flying. He is not walking through the walls, but he is flying and not walking. How can I solve it?
When you use "Simulate In Editor" (by pressing Alt+S or pressing the play symbol with a cog next to it) the engine generates a default Pawn and PlayerController which move about in the way you described (i.e. flying with collision).
If you want to use the normal player controller and pawn (i.e. how the player would move about in the level), you just need to use "Play in Editor" (by pressing the Play symbol without the cog).
You can read about different ways of testing your game in the editor here.