Question by
mittalshaurya004 · Jul 08, 2020 at 11:44 AM ·
physicsraycast3dphysics.raycastrpg-game
raycast not hittig anything but charecter
i was making a navigation mesh game and was trying to set up a test for my ray cast but my ray cast doesn't return any message when i click any thing , but it works only with my character gfx
public Camera cam;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray,out hit))
{
UnityEngine.Debug.Log("we hit" + hit.collider.name);
}
}
}
}
Comment
Be sure to have colliders to hit on the other objects