This question was
closed Jul 08, 2018 at 10:55 AM by
numbernolodin for the following reason:
Was solved
Question by
numbernolodin · Jul 07, 2018 at 05:38 PM ·
physics.raycast
RaycastHit The best overloaded method has some invalid arguments
I have issue with using RaycastHit, visual studio don't want to see the constructor! Assets/Scripts/RaycastHit.cs(23,25): error CS1502: The best overloaded method match for 'UnityEngine.Physics.Raycast(UnityEngine.Ray, float)' has some invalid arguments Assets/Scripts/RaycastHit.cs(23,41): error CS1615: Argument '#2' does not require 'out' modifier. Consider removing 'out' modifier
using UnityEngine;
using System.Collections;
public class RaycastHit : MonoBehaviour
{
public GameObject infoFrame;
void Start()
{
infoFrame = GameObject.Find("Main Camera/Canvas/infoFrame");
infoFrame.SetActive(false);
}
void Update()
{
if (Input.touchCount > 0)
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray,out hit))// Issue is here
{
Transform objectHit = hit.transform;
Debug.Log(objectHit.name);
infoFrame.SetActive(true);
}
}
}
}
Comment
$$anonymous$$y problem was solved, my class was named RaycastHit, therefore it got all mixed up.