using System.Collections.Generic;
using UnityEngine;
Public class shiqu: MonoBehaviour
{
//Use this for initialization
Void the Start ()
{
}
//Update is called once per frame
Void the Update ()
{
If (Input. GetMouseButton (0))
{
Ray Ray=Camera. Main. ScreenPointToRay (Input. MousePosition);
RaycastHit hit;
If (Physics. Raycast (ray, out hit))
{
The Debug. DrawLine (ray origin, hit. Point);
Print (hit) starts. GameObject. Name);
}
}
}
}
I want to do the effect of the mouse to click loot items, use this code will only have ray, and the object will not disappear also won't follow the mouse to move, would like to ask how to do that kind of effect
CodePudding user response:
And you are the coordinates of the mouse to produce 2 d game is 3 d space, so you click generate only a ray and a point can't beYou can add starts to need to pick up objects box type of collision, then using ray direct collision detection and collision body to determine whether to pick up