- Home /
This question was
closed Jun 26, 2014 at 09:26 PM by
Graham-Dunnett for the following reason:
Duplicate Question
Question by
robotfishfx · Jun 26, 2014 at 09:24 PM ·
bce0017
what is the problem with this MeleeSystem
var range: float = 1.8;
var attackInterval: float = 0.7;
var meleeDamage: float = 30;
private var nextAttack: float = 0;
function MeleeAttack(){
if (Time.time > nextAttack){ // only repeat attack after attackInterval
nextAttack = Time.time + attackInterval;
// get all colliders whose bounds touch the sphere
var colls: Collider[] = Physics.OverlapSphere(transform.position, range);
for (var hit : Collider in colls) {
if (hit && hit.tag == "Enemy"){ // if the object is an enemy...
// check the actual distance to the melee center
var dist = Vector3.Distance(hit.transform.position - transform.position);
if (dist <= range){ // if inside the range...
// apply damage to the hit object
hit.SendMessage("ApplyDamage", meleeDamage);
}
}
}
}
}
function Update(){
if (Input.GetButtonDown("Fire1")){
MeleeAttack();
}
}
i keep getting the complier error: Assets/MeleeSystem.js(16,36): BCE0017: The best overload for the method 'UnityEngine.Vector3.Distance(UnityEngine.Vector3, UnityEngine.Vector3)' is not compatible with the argument list '(UnityEngine.Vector3)'.
Comment
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to import the object from server to unity 2 Answers
Material doesn't have a color property '_Color' 4 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer