Sound on collision and level change (UE5) - unreal-engine4

I have created a box collision(for falling off the platform) of simply losing a game and restarting the map. But when I add the "Open level" to the "On Component Begin Overlap", "Play Sound" does not work. Could someone help
enter image description here

This is because after the player hits the box collision, Unreal will restart the level so fast that you will not be able to hear the sound, in order to fix this problem just add a delay node after the play sound 2d node to hear the audio, then use the open level node afterwards.

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...

Climb down ladder in 2D platformer game

For my game, the player character requires to climb up and down ladders those are placed in the gameplay area.
At present, I can able to climb up for my player character to climb down at present I don't have anyway. Because platform box collider applied with platform effector, so for the climb up, effector does not create any problem but now after reaching the top, it becomes solid platform so now I can't able to move downside.
For climbing up, I have followed this tutorial: How To Make 2D Ladders In Unity - Easy Tutorial
I am looking to implement some physics so I can reach downside to the ladder after reaching top.
You need 2 boolean variables isClimbingUp and isClimbingDown which depend on pressed key and a second ray, which will check -Vector2.up direction. Then just add one more 'else if' statement for down direction.
Yes, I have managed to solve this, and the game is published in the stores.
You can check using the below link:
Humpty Trumpty's Border Wall
This is my overall physics setup for the stair:
I have applied a trigger collider to my stair object and disable player gravity scale when the player within the stair.
Then after within the trigger enter and exist, I have done this:
Physics2D.IgnoreCollision(m_CapsuleCollider, myStair.platformCollider, false);
Disable collision between player and platform colliders when the player is within the stair.
I don't think, Platform Effect 2D becomes useful to me in this process but I didn't remove this to remain in the safer side.
So you have to keep a reference of the platform object which is attached to Stair.
I hope you will get a general idea to solve this problem.

How can I use two Audio Listeners?

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.

UE4 Enabling Mouse During Play?

I'm extremely new to UE, and doing a few easy tutorials to get started, so I don't exactly know the correct terminology to use to help me find what I am looking for... Anyway, whenever I hit play and the game starts, my mouse disappears and I am only able to use the input that I set up; so my question is, even though I do not need mouse input for movement, as I am using WASD, how do I keep my mouse unlocked and available to move around without being locked to the camera?
When you hit play and the game starts, your mouse gets captured by the game to control the camera. If your play button is set to play in the viewport, you can release the mouse from the viewport by pressing Shift-F1. The game will still be running, but input (including from the keyboard) will be suspended and you can interact with the editor.
You can also change the default behavior of how the mouse is captured and it if is constrained to the viewport boundaries. To see these options, go into the project settings (settings button above main viewport/project settings...). On the left side of the project settings window, select 'Input' under the Engine heading. On the right side will be some mouse preferences that can change its behavior.
For instance, to allow the mouse to travel outside the viewport, change 'Default Viewport Mouse Lock Mode' to 'Do Not Lock'. I don't recommend this, but you might experiment with these to get a feel for what they do. Also, you might look up these settings in the Unreal documentation for more detail.
There are 3 blueprint nodes that change the input method:
Set Input Mode Game
Set Input Mode Game and UI
Set Input Mode UI
You want a combination of the second one and a "Show Mouse Cursor" node. However, if you are making an FPS and you use the mouse to look around, you may lose that ability with the second node above. It comes down to what your game is and how you want to use the mouse.
I had the similar issue. So I did something like this in Level Blueprints to achieve what I want.

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.