Forum rules - please read before posting.

Call AC.Sound.play from the code

edited October 2014 in Technical Q&A
I'd like to play one of the sound outside of AC namespace. Is it possible?

I'd like to do something like this:

AC.Sound scoreSound = (AC.Sound) GameObject.Find("SoundScorePoints");
scoreSound.Play(true);

But seems I can't get the AC.Sound. It gives me back:
"error CS0030: Cannot convert type `UnityEngine.GameObject' to `AC.Sound'"

I tried also to declare it in the public variables and set it in the editor, without success.

Is there a way to implement outside AC actions?
Otherwise I'll create a specific action.

Comments

  • The console error is telling you what you need to know: you're trying to convert a Sound object to a GameObject.  Try this:

    AC.Sound scoreSound = (AC.Sound) GameObject.Find("SoundScorePoints").GetComponent ();
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.