Raycast can be use in many fire like : There are many raycast type but these two are most that i used. 1.Physics.Raycast Player shooting/Fire 2.Physics.SphereCast Detect A object to Apply force due to explosion effect. Simple Physics Raycast as shown below : RaycastHit hit; Ray ray; void Update () { if ( Input .GetMouseButton(0)) { ray = Camera .main.ScreenPointToRay( Input. mousePosition); if ( Physics .Raycast(ray, out hit)) { Debug .Log( "Ray cast hit too " + hit.collider.gameObject.name); } } }
Raycast can be use in many fire like :
There are many raycast type but these two are most that i used.
1.Physics.Raycast
Player shooting/Fire
2.Physics.SphereCast
Detect A object to Apply force due to explosion effect.
Simple Physics Raycast as shown below :
RaycastHit hit;
Ray ray;
void Update()
{
if(Input.GetMouseButton(0))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
Debug.Log("Ray cast hit too " + hit.collider.gameObject.name);
}
}
}
Comments
Post a Comment