Hello Unity Community! I have tried to fix this, but I just can't. What is the problem with this code!?!? Thanks, Calvin
using UnityEngine;
using System.Collections;
public class MeleeSystem : MonoBehaviour
{
public int TheDamage = 50;
public float Distance;
void Update()
{
if (Input.GetButtonDown ("Fire1"))
{
RaycastHit hit = RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), hit))
{
Distance = hit.distance;
hit.transform.SendMessage ("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
↧