Hi I was converting my script from js and I got this error.
Assets/weapon.cs(49,16): error CS1502: The best overloaded method match for `UnityEngine.Physics.Raycast(UnityEngine.Ray, out UnityEngine.RaycastHit)’ has some invalid arguments.
Here is my script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class weapon : MonoBehaviour {
public int dammage = 50;
public float distance;
public float maxdistance = 1.5f;
public Animator animator;
public float damagedelay = 0.6f;
public int hit1streak = 0;
public int hit2streak = 0;
public Ray ray;
// Update is called once per frame
void Update ()
{
if(Input.GetButtonDown ("Fire1"))
{
attackdamage();
}
}
IEnumerator attackdamage()
{
if (Random.value >= 0.5 && hit1streak <= 2) {
animator.SetBool ("Swing01", true);
hit1streak += 1;
hit2streak = 0;
}
else
{
if (hit2streak <= 2) {
animator.SetBool ("Swing02", true);
hit1streak = 0;
hit2streak += 1;
}
else {
animator.SetBool ("Swing01", true);
hit1streak += 1;
hit2streak = 0;
}
}
yield return new WaitForSeconds(damagedelay);
RaycastHit hit;
ray = Camera.main.ScreenPointToRay (new Vector3(Screen.width/2, Screen.height/2,0));
if(Physics.Raycast (ray, hit))
{
distance = hit.distance;
if(distance < maxdistance)
{
hit.transform.SendMessage ("applydammage", dammage, SendMessageOptions.DontRequireReceiver);
}
}
animator.SetBool ("Swing01", false);
animator.SetBool ("Swing02", false);
}
}