I’m new to Unreal and game development as a whole and I’m trying to create a simple game where the player has a Geiger counter they can use to scan objects with. The goal is to find the object with the highest radiation levels and then you “win”. I was trying to research how to make it so that the Geiger counter plays the ticking sound when you’re near a radioactive object and then the ticking sound gets faster as you get closer. How would I create this effect?
Again, this is my first game, so please explain how I’d do this in thorough detail. Any help would be greatly appreciated!
Sorry for my lack of a super clean answer, but hopefully I can point you in the right direction. There are three components that you will have to interact with to get this up and running.
For the UI, you will have to create a UMG widget that you spawn on the players interface. This will need to access the value of the Geiger counter.
You will need to access the players position done via the player character.
You will need to create a blueprint or an actor that acts as the source that emits the radiation.
You can use the vector length between the player position and the radiation actor position to determine the distance between the objects; thus allowing you to know how far away you are from the source.
Using the tick event will allow you to update this value with every frame, and it should be fine as it is suck a simple procedure. Getting the Length and turning it into a variable will allow you to pass this over to the UI.
Use the cast function in the UI to get the variable and in here use a tick to update the value shown in the UI.
I hope this all makes sense, and if you are unsure about any of the words I mentioned; have a look at some tutorials on YouTube. They are great and can often solve any confusion.