Hey guys I was wondering if you could help me on this! I am having a bit of a problem with this script and I’m really new to JavaScript. I wanted to throw an object when I press a button. But when I play the game to test it spawns hundreds automatically without pressing anything. Also it’s saying that it doesn’t understands what I mean by “Play” when I say “AnimationClip.Play(Anim);” . Help anyone? Thanks!
#pragma strict
var tossobj : Rigidbody;
var Sound : AudioClip;
var Anim : AnimationClip;
var throwpower : float = 10;
function Update () {
if(Input.GetKeyDown(0));{
var clone : Rigidbody;
clone = Instantiate(tossobj, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3.forward * throwPower);
AnimationClip.Play(Anim);
audio.PlayOneShot(Sound);
audio.Play();
}
}