raycast layer ignore turret
This commit is contained in:
parent
b8171e1538
commit
bad5bb7f04
@ -17,7 +17,6 @@ public class CannonScript : MonoBehaviour
|
|||||||
private Vector3 lookDir;
|
private Vector3 lookDir;
|
||||||
private Vector3[] offsets;
|
private Vector3[] offsets;
|
||||||
[SerializeField]private int bullets;
|
[SerializeField]private int bullets;
|
||||||
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
@ -47,8 +46,9 @@ public class CannonScript : MonoBehaviour
|
|||||||
GameObject proj = Instantiate(projectile, cannon.transform.position, cannon.transform.rotation);
|
GameObject proj = Instantiate(projectile, cannon.transform.position, cannon.transform.rotation);
|
||||||
proj.GetComponent<Projectile>().SetDamage(damage);
|
proj.GetComponent<Projectile>().SetDamage(damage);
|
||||||
proj.GetComponent<Rigidbody>().AddForce(cannonForce * lookDir, ForceMode.Impulse);
|
proj.GetComponent<Rigidbody>().AddForce(cannonForce * lookDir, ForceMode.Impulse);
|
||||||
|
//proj.layer = GameManager.Instance.GetDimensionLayer();
|
||||||
RaycastHit hit;
|
RaycastHit hit;
|
||||||
if (Physics.Raycast(transform.position, lookDir, out hit, Mathf.Infinity))
|
if (Physics.Raycast(transform.position, lookDir, out hit, Mathf.Infinity, GetCurrentDimensionLayerMask()))
|
||||||
{
|
{
|
||||||
Debug.DrawRay(transform.position, lookDir * hit.distance, Color.yellow, 0.5f);
|
Debug.DrawRay(transform.position, lookDir * hit.distance, Color.yellow, 0.5f);
|
||||||
|
|
||||||
@ -119,6 +119,12 @@ public class CannonScript : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetCurrentDimensionLayerMask()
|
||||||
|
{
|
||||||
|
int layer_mask = LayerMask.GetMask("Dimension1");
|
||||||
|
return layer_mask;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFireRate(float nFireRate){
|
public void SetFireRate(float nFireRate){
|
||||||
this.fireRate = nFireRate;
|
this.fireRate = nFireRate;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user