I had a script written in Javascript for a melee attack system that I want to convert to C# but now I have these errors. Help!
Error CS1620: Argument '3' must be passed with the 'out' keyword (CS1620) (Assembly-CSharp)
Error CS1502: The best overloaded method match for 'UnityEngine.Physics.Raycast(UnityEngine.Vector3, UnityEngine.Vector3, out UnityEngine.RaycastHit)' has some invalid arguments (CS1502) (Assembly-CSharp)
using UnityEngine;
using System.Collections;
public class MeleeSystem : MonoBehaviour {
int Damage = 50;
float Distance;
float MaxDistance = 2;
Transform TheSystem;
void Update (){
if (Input.GetButtonDown("Fire1"))
{
TheSystem.animation.Play("melee_attack");
RaycastHit hit;
if(Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
↧