Вот нашел скрипт он рабочий но есть одна проблема не могу поменять значения скрипта:
Code
using UnityEngine;
using System.Collections;
public class PlayerAttack : MonoBehaviour {
public GameObject target;
public float coolDown;
public float attackTimer;
void Start () {
attackTimer = 0;
if(coolDown == 0){
coolDown = 2.0f;
}
}
void Update () {
if (attackTimer > 0)
attackTimer -= Time.deltaTime;
if (attackTimer < 0)
attackTimer = 0;
if (Input.GetKeyUp(KeyCode.F)){
if(attackTimer == 0){
Attack();
attackTimer = coolDown;
}
}
}
private void Attack(){
float distance = Vector3.Distance(target.transform.position, transform.position);
Vector3 dir = (target.transform.position - transform.position).normalized;
float direction = Vector3.Dot(dir,transform.forward);
if(distance < 4 && direction > 0){
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.AddjustCurrentHealth(-100);
}
}
}
Вопрос в том как поменять удар тоесть в скрипте указан удар на кнопку F а надо на Левую кнопку мыши. Я знаю что менять нужно именно здесь но как не пойму:
Code
if (Input.GetKeyUp(KeyCode.F)){
Добавлено (22.09.2012, 20:35)
---------------------------------------------
Уже не надо сам разобрался надо было написать место if (Input.GetKeyUp(KeyCode.F)){ на if (Input.GetMouseButtonDown(0)){