Geiger Counter

Hello everyone!
Does anyone know how I can make a Geiger counter needle rotate based on the distance between the player and some “radioactive material”?
Should I use a Line Trace or OnBeginOverlap for this?

I’d also like the needle to have a slight left–right jitter so it’s not completely static — it should still rotate based on distance, but when the value isn’t changing much, it should wobble a bit for realism.

Additionally, how can I make it so that each time the needle updates (for example, every Tick), it plays a clicking sound like a real Geiger counter?

Thanks in advance!

Hey @Mixi1123! Welcome to the forums!

I’m going to kind of skim because this is multiple questions, let me know if there’s anything you’d like a more detailed explanation on!

Have a collider sphere on the “Radioactive_Actor” that goes out to the furthest reaches of where it would affect the player. Then use OnBeginOverlap to start a SetTimerByFunction, with an update speed relatively low, let’s say .075.

The connected function should check distance between the “Radioactive_Actor”'s Actor Location and the PLAYER’s Actor Location
(Use a Vector minus Vector node and then a Vector Length node).

Then you’ll take that distance and do math in a Function- make sure the String on the Set Timer By Function matches the function’s name exactly!

From here, with that number you could do a load of things, it all depends on how YOU want it to behave! :slight_smile: As far as putting a dial on the screen you can use a UI widget of some kind or another (Progress bar type, I believe, but you’d need a custom one I don’t think UE5 comes with one). If you wanted the Geiger counter to be in the environment of the game, that’s something else entirely.

Get back to us with a bit more info! :slight_smile:

1 Like

Hi again, thanks for the welcome!

I got it working with line trace, and yeah that “needle” is in 3D form not UI. One thing i can’t get is sound it plays but it doesn’t stop. Here is the Screenshot, i probably didn’t do something right, but i’m new in Game Development and i have spend so much time on getting this system to “work” :smile:

And i love every thing about Unreal and Epic, You guys really try to make everything simple and help people :smile:

Where are you playing the sound?

Maybe try a check using any of these Floats- if it’s above 0 or whatever threshold, play sound, if it’s below 0, stop sound. But of the ways you could be playing sound, I don’t see any?

I tried after Timeline, but it didn’t worked

Can you show what you mean with a picture? Also, can you show the insides of that timeline?

“Edit: Got The sound working. The fix is just to have Do Once and if there isn’t anything detected just plug that in reset”

Here is inside of Timeline

One thing about it is that the first time it rotates, it does it by Timeline, but next time it just snaps to that rotation, and besides that i would like to make that needle doesn’t stay static, it has left–right jitter

Here’s a couple of adjustments I’d add to try to get what you need:

This will make sure the adjustment goes down, as of right now you’re always getting a hit on the line trace so it’s never going reverse.

Also experiment with play vs play from start and reverse vs reverse from end. :slight_smile:

To add play into the needle you’re going to need to add a “Set timer by event”, and off of the “Completed” part of the timeline, run that, and every .2 seconds (looping) using the “Set Timer by event” , use “Random Float In range” to get a float between -5 and 5 degrees and have it add that to the relative rotation.

Hope that helps!

I Will try it now!

Did you give it a shot @Mixi1123 ? Let us know how it’s going!

Instead of doing a zillion linetraces and timelines, could just add a big collision sphere to player and use begin overlap to start the geiger.

Here I first check if overlapped actor has a radioactive tag, then add the actor to an array var. Next it starts a timer with event which checks the distance to the most recent rad source, does some sloppy math, and updates relative rotation of a needle mesh I attached to front of camera. Using a UI widget would probably be a better idea tho..

Finally when the large sphere ends overlap, I check if actor is in the rad source array and remove it:

Should probably also check here if array is empty, then clear timer and reset needle, but yea.

Edit to add: To add some drift/wobble to the needle just add a small random float in range just before feeding it to the select node in my example.

Mucked with this more a bit and made a component to do the rad tracking and added a UI for it..

Project files here (59MB) if anyone wants to scavenge things from it.

1 Like

(post deleted by author)

(post deleted by author)

(post deleted by author)