I’m looking for a good way to write a meele script. For now I have something like that
using UnityEngine;
using System.Collections;
public class MyHand : MonoBehaviour {
float Distance;
RaycastHit hit;
void Update () {
if (Input.GetButton("Fire1")) {
audio.Play();
Vector3 forward = transform.TransformDirection (Vector3.forward);
Distance = hit.distance;
if (Distance <= 2) {
hit.transform.SendMessage("ApplyDamage", 50, SendMessageOptions.DontRequireReceiver);
}
}
}
}
but it’s pointing only at one point which is kinda inconvenient. Especially if the player swings his fist all across the whole screen^^