Toggle Sound on/off between audios, when looking at objects with gaze system

Hey! Working in a VR project.

I have a gaze system setup with linetraces, and whenever I look at an object, a title and descriprion shows in text form beside it. After a few seconds, the text dissapears and you have to look at the object again to prompt the text again.

I have several diferent objects in the level and each one of them has a different sound i need it to play, when i look at it.

Example: If I’m looking at the object 1 and i look to the object 2… the sound from object 1 stops and the sound from the object 2 starts… this for all the different objects in the level, no matter the order.

I can’t figure out how to properly do this, since my current setup only plays the sound once per object.

Here’s my setup (I’m probably overcomplicating this, as usual… so bare with me :sweat_smile:)

1 - This event is the one that happens once i look at the object.
It cast to the game engine the a name tag from a specific object. and also sets the sound i need to play from it.

2- Then, in my game instance, I receive this name tag information… That is sorted into a “switch on name”, so that I can define a particular sequence of events to a particular object.

3 - Here’s the Play Audio Function…

I’m probably overengineering this, but I can’t figure out how to simplify this.

Hope someone can guide in a better way of making this work.

Thanks for your attention!

You have a non-scalable system here. The more stuff you have in the game, the more of a nightmare it becomes.

A better way would be the objects talking to the player with an interface call.

The object can make it’s own text, and that would be a blueprint inheritance thing, so all inspectable objects descend from one blueprint. But the sound can be passed to the player over an interface call.

That way, the player is in control of what sound is playing when.

Object call to the player

In the player

2 Likes

Hey! I recreated this setup and there’s no sound coming out.

Here’s the setup inside the object I’m looking at

Inside the pawn

Don’t really know what else to show.

Things to check

  1. I don’t know how long that sound is, but is has silence at the start

image

  1. What happens when you put a print string here

Do you see it?

Ah, it’s not a character, it’s a pawn.

You need to do a GetActorOfClass on your pawn and call the interface on that.

The Sound was replaced by a louder and more complex one and there’s nothing printing when i intercept that.

I can’t seem to find a way to use that GetActorOfClass, I can’t call the interface on that.
image

Kinda of a noob here

What is the name of your pawn BP?

It’s BP_VRPawn, but do I call it inside it’s own blueprint?

Like I say, this is inside the thing begin looked at ( inspected ).

Got it! It is working when I look at the objects!

I do have to change a few things in my BP, because I have it set that I can only look again at the object when the sequence finishes, and the audio is at the begining of the sequence.

That makes it so that I cant look in between objects and have it “constantly” start and stop…

But, it works very well and how it’s supposed too.

Thank you! You rock @ClockworkOcean !

1 Like

Yeaaahhh! :slight_smile:

1 Like