Hi, I’m having trouble getting a sound to play when you press the Fire Button, I’m still new to scripting so I may order things in scripts wrong.
My error Message is this “Expressions in statements must only be executed for their side-effects.”
Here’s what I’ve got
var projectile : Rigidbody;
var speed = 20;
function Update()
{
if( Input.GetButtonDown( "Fire1" ) )
{
//My problem is here, have i done this wrong with the "MP5 Shot";
audio.Play();
"MP5 Shot";
// Delay a clip by 1 sec (44100 samples)
audio.Play(44100);
var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );
}
}
You may recognise it from the FPS Tutorial, What i’m doing is not following the tutorial, I’m modifing the FPS Controller to my needs and also experimenting too, so I become more familiar with scripting, The Unity Script Resource is what’s helping alot, researching what type of script I’ll need and then placing it into the script and modifying it.
Can anyone help me please? I’m using Javascript