Jump to content

How to store object of AmbientSource Class on C++ side


photo

Recommended Posts

Hi guys,

 

I want to store object/instance of an "AmbientSource" Class on CPP side to track all objects on CPP side.

 

We are saving all objects/instances of "Node" class on CPP side using "Unigine::Variable", is it possible to use same for "AmbientSource" Class ?

 

Thanks

rakeshj.

Link to comment

Hi frustum,

 

Thanks for quick reply, so that we can find another solution.

 

One more thing, Is there any way to play "AmbientSource" sound without loading world ? e.g. Menu screen which contains only Gui elements.

 

Thanks,

rakeshj.

Link to comment

@frustum That's precisely what we did. We created AmbientSources in the system hierarchy and tried playing them. But it seems for you to actually hear the sound, one needs either the World or Editor scripts to be running. We have a custom app and we are playing the AmbientSource from the app, and there's no world or editor script loaded. The moment we load the editor, the sound starts to play and the moment we quit the editor the sound stops. Ditto for world loading.

Also, we tried printing the current time of the sound clip etc. to the console; the time is advancing, just that the sound can't actually be heard.

Link to comment

For sound to be played (even if it's an ambient sound), a player should be created in your system script unigine.cpp. Without a player, none of sound sources work. Try the following code snippet:

 

log.message("play\n");
AmbientSource source = new AmbientSource("samples/sounds/sounds/static_mono_00.oga");
source.setLoop(1);
source.play();

Player p = new PlayerSpectator();
engine.game.setPlayer(p);

Link to comment
×
×
  • Create New...