I need help with an Echolocation Effect

I’m trying to make sonar/echolocation effect for Game Engine and was wondering if a proper effect is possible or can be made better than mine

Echolocation.blend (614.5 KB)

I was attempting to make something like this with a fade, sharing characteristics from both videos below. If it’s even possible in Blender. Some help would be greatly appreciated.

Like this:



hey there,

here’s a simple python fade, just plug it on a light object. module mode. you can configure speed and other goodies with properties, but it’s optional – works as it is without more setup than plugging in a controller to pulse always and writing down module name. if you look at the script you can see what property name does what, so i hope it’s not too hard to read.

from bge import logic
cont = logic.getCurrentController()
own = cont.owner
if "init" not in own:
    if "fadeout" not in own:
        own["fadeout"] = False
    if "downSpeed" not in own:
        own["downSpeed"] = 0.025
    if "upSpeed" not in own:
        own["upSpeed"] = 0.025
    if "maxEnergy" not in own:
        own["maxEnergy"] = 1
    if "minEnergy" not in own:
        own["minEnergy"] = 0
    own["init"] = True

def fade():
    fadeout = own["fadeout"]
    if not fadeout:
        own.energy += own["upSpeed"]
        if own.energy > own["maxEnergy"]:
            own["fadeout"] = True
        own.energy -= own["downSpeed"]
        if own.energy <= own["minEnergy"]:
            own["fadeout"] = False


Hello there!

The way you’ve imitated the effect is pretty creative :slight_smile: Good job!

From the videos you linked, I can tell the effect is done by some sort of shadercode.
The BGE supports shadercode in the form of GLSL, so an effect like this is entirely possible.

Hello again, I gave the shader part a shot, not sure how one would create the wall-crawling though.

Echolocation_Shader_00.blend (215.9 KB)

@sdfgeoff has made an echolocation shader, could be used to learn from.

I was going to return and say that I couldn’t get the script to work in the controller logic in module mode for the life of me @Liebranca but, the community pulled through again. Thank you so much @John_tgh for the compliment and the project! Thank you again for your help again @Cotaks! I was looking all over for anything with Echolocation in the forum and couldn’t find a thing. That cave project sounds exactly what I need. You guys are amazing. Hopefully, if I can make a cohesive 2.5D Template I will definitely share it with the community.

1 Like

One is glad to have been of service :slight_smile:

I made some changes to the file, maybe not all are good:Echolocation_Shader_01.blend (220.1 KB)
But the visuals should now match your desired effect more closely. Also there is a graph drawn onto the screen for debugging purposes.

Oh and last time I forgot to add the control scheme:
MouseMove for Camera.
WASD for walking.
MouseWheel UP/DOWN to in/de-crease frequency variable.
Mouse LEFT/RIGHT CLICK to in/de-crease amplitude.

I’m afraid the math is a bit bogus though, the terms frequency and amplitude are not correctly applied.
Perhaps you or someone else can alter the math to make it more usable.

1 Like

Oh, @John_tgh, is there a way that I could make the trail a different color than the leading edge of the wave? I have since updated my project and it fades to a different color.
I made it return since it seemed more practical to have the wave hit both sides of any object in a room. I wished I asked how to make it return sooner before you sent another updated project. Sorry.
I was inspired by the laser of a scanner.

Echolocation_final.blend (650.2 KB)

Hmmmmm, I’m not sure how to do that, but I’m thinking the easiest way, would be to change the timer property to a float property.

Why change the type of the property you might ask? Because the timer property should not be messed with xD
That’s the short version, there’s a long version but I don’t remember it off the top of my head : P

In my file, the timer property is attached to the cone object in the main scene.

If you change this timer property to a float property, then you’ll also have to create some sort of timer system or function. This system/function will set the value of the float based on some sort of logic.

The end result would be a sort of ping-pong effect that loops infinitely - just like in your second file.

It might be possible to do what I have described above, using only a few extra logic bricks - but I’m not sure as I am way too tired at the moment xD

I did some color and behavioral tweaks to that Cave project.
That seems the closest to what I want.
I also guess It’s not necessary to have a wave come back @John_tgh with the xray effect I added.

If anyone wants to check it out, here it is.
Cave multicolor.blend (845.1 KB)

Thanks a ton everyone.