kobolt
New Member
Posts: 3
Posts: 3
|
Post by kobolt on Oct 16, 2015 16:45:01 GMT
Hi, and first i want to say sorry for my ingnorance. This is the first time that i use middleware to make sound in Unity.
I understand the procedure but i don't know how use it.
The thing is, i'm make demos with the standard assets of Unity. Roll Ball, airplane, etc.
I have the roll ball asset, and i want to start a sound when the ball start to rolling. I know that this will be with a event sound. but i don't have idea how to tell the order to the event to start the sound. should i make some line code' or only combine the differents parts of this fantastic middleware.?
Thanks. and sorry for my primary questions, I have read the manual, but i don't know how to proceed.
Thanks
|
|
|
Post by DarkTonic Dev on Oct 16, 2015 20:06:04 GMT
There's no built in Unity event for "when an object starts to move" so you will need to use the API. You will not be able to use EventSounds script for this.
Commands such as
MasterAudio.PlaySound3dandforget
Are what you will use.
|
|
kobolt
New Member
Posts: 3
Posts: 3
|
Post by kobolt on Oct 17, 2015 17:16:16 GMT
OK, thanks, so i can not to add a EventSound to the game object "RollerBall" and configure to start to sound when the ball start to rolling? or modify Ball User Control Script. Or add a MA_player control and use this command MasterAudio.PlaySound3dandforget?
thanks
|
|
|
Post by DarkTonic Dev on Oct 17, 2015 17:18:36 GMT
Correct.
|
|
kobolt
New Member
Posts: 3
Posts: 3
|
Post by kobolt on Oct 17, 2015 17:39:20 GMT
i have this code in BallUserControll, how can i type the call for the sound?
using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.Vehicles.Ball { public class BallUserControl : MonoBehaviour { private Ball ball; // Reference to the ball controller.
private Vector3 move; // the world-relative desired move direction, calculated from the camForward and user input.
private Transform cam; // A reference to the main camera in the scenes transform private Vector3 camForward; // The current forward direction of the camera private bool jump; // whether the jump button is currently pressed
private void Awake() { // Set up the reference. ball = GetComponent<Ball>();
// get the transform of the main camera if (Camera.main != null) { cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Ball needs a Camera tagged \"MainCamera\", for camera-relative controls."); // we use world-relative controls in this case, which may not be what the user wants, but hey, we warned them! } }
private void Update() { // Get the axis and jump input.
float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); jump = CrossPlatformInputManager.GetButton("Jump");
// calculate move direction if (cam != null) { // calculate camera relative direction to move: camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; move = (v*camForward + h*cam.right).normalized; } else { // we use world-relative directions in the case of no main camera move = (v*Vector3.forward + h*Vector3.right).normalized; } }
private void FixedUpdate() { // Call the Move function of the ball controller ball.Move(move, jump); jump = false; } } }
|
|
|
Post by DarkTonic Dev on Oct 18, 2015 6:03:50 GMT
I don't have any more information for you on this issue. You should know where you need to place to code to play the sound better than me, since it's your code.
Anyway, when you want to play a sound, use:
MasterAudio.PlaySound3DAndForget
|
|
|
Post by Dracones on Jun 2, 2016 7:48:03 GMT
I don't have any more information for you on this issue. You should know where you need to place to code to play the sound better than me, since it's your code. Anyway, when you want to play a sound, use: MasterAudio.PlaySound3DAndForget
One bug in your code, in the Playmaker plugin you're making a call to this method. Here's a code error on a blank project, importing Playmaker, MA, and installing the MA_PlaymakerActionsAndScene plugin. Assets/Plugins/DarkTonic/MasterAudio/PlaymakerCustomActions/MasterAudioPlaySound.cs(59,37): error CS1501: No overload for method `PlaySound3DAndForget' takes `7' arguments
|
|
|
Post by DarkTonic Dev on Jun 2, 2016 15:57:56 GMT
|
|