I, I’ve got some code that calls a routine to throw an object when the P key is pressed, it all works fine except every time I press the P key he throws the object + 1 more every time, I’m using (Input.GetKeyDown) can someone please point out the obvious that I’m missing please.
var ThrownObject : Transform; // Set var for a object to throw
var Explosion : Transform; // Set var for the exposion to use
function Chuk()
{
animation["Throw"].layer = 1;
animation.CrossFade("Throw",0.2);
animation["Throw"].blendMode = AnimationBlendMode.Additive;
var throwObjectEvent = new AnimationEvent();
throwObjectEvent.functionName = "throwObject";
throwObjectEvent.time = 0.5;
animation["Throw"].clip.AddEvent(throwObjectEvent);
}
function throwObject()
{
// Add a (var ThrownObject : Transform;) at top of script then drag the object you want
// to throw into it in the inspector window
var bullit = Instantiate(ThrownObject, GameObject.Find("throwSpawnPoint").transform.position, Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
var bang = Instantiate(Explosion, GameObject.Find("throwSpawnPoint").transform.position, Quaternion.identity);
}