I am getting an error : ArgumentOutOfRangeException: Argument is out of range. Parameter name: index
I have tried to use an event in an animation at a particular time which further calls a function named AttackDamage (). Here is the code : #pragma strict var Damage : int = 50; var Distance : float; var MaxDistance : float = 1.5; var theSystem : Transform; function Update(){ if(Input.GetButtonDown("Fire1")) { // Attack Animation theSystem.GetComponent.<Animation>().Play("attack"); } } function AttackDamage(){ // Attack function var hit : RaycastHit; if(Physics.Raycast (transform.position, theSystem.transform.TransformDirection(Vector3.forward), hit)){ Distance = hit.distance; if(Distance < MaxDistance) { hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver); } } }
I can't understand and find the error please help me out.
Your answer
Follow this Question
Related Questions
Argument Out of Range Exception: Error with Array Turned into List 0 Answers
ArgumentOutOfRangeException: Argument is out of range. Parameter name: index 1 Answer
"event.current.keyCode" not work! 0 Answers
Argument out of Range Exception Error. [Basic] 0 Answers
How to to fix error UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) 0 Answers