mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
Update Shoot.cs
This commit is contained in:
@@ -71,31 +71,33 @@ public class Shoot : NetworkBehaviour
|
|||||||
ray = new Ray(mCamera.transform.position, mCamera.transform.forward); // Raycast from Camera
|
ray = new Ray(mCamera.transform.position, mCamera.transform.forward); // Raycast from Camera
|
||||||
Debug.Log(" C Ray");
|
Debug.Log(" C Ray");
|
||||||
if (Physics.Raycast(ray, out crosshairHitPoint, 5000f)) { // Check if Raycast is beyond 5000
|
if (Physics.Raycast(ray, out crosshairHitPoint, 5000f)) { // Check if Raycast is beyond 5000
|
||||||
Debug.Log(" floor");
|
|
||||||
hitpos = crosshairHitPoint.point; // If hitpoint is under 5000
|
hitpos = crosshairHitPoint.point; // If hitpoint is under 5000
|
||||||
} else {
|
} else {
|
||||||
hitpos = mCamera.transform.position + mCamera.transform.forward * 5000;
|
hitpos = mCamera.transform.position + mCamera.transform.forward * 5000;
|
||||||
}
|
}
|
||||||
|
Debug.Log("shootAnim.rotationMod");
|
||||||
_pointDirection = hitpos - muzzle.transform.position;
|
_pointDirection = hitpos - muzzle.transform.position;
|
||||||
_lookRotation = Quaternion.LookRotation(_pointDirection);
|
_lookRotation = Quaternion.LookRotation(_pointDirection);
|
||||||
shootAnim.rotationMod[1] = Quaternion.RotateTowards(weaponHolder.transform.rotation, _lookRotation, 1f); // Point weapon to raycast hitpoint from camera
|
shootAnim.rotationMod[1] = Quaternion.RotateTowards(weaponHolder.transform.rotation, _lookRotation, 1f); // Point weapon to raycast hitpoint from camera
|
||||||
|
Debug.Log("Weapon.AllowAction");
|
||||||
if (weapon.AllowAction) { // If not reloading etc.
|
if (weapon.AllowAction) { // If not reloading etc.
|
||||||
|
Debug.Log("Raycast");
|
||||||
if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit) && weapon.CurrentAmmunition > 0) { // Raycast from Bullet Exit Point to camera raycast
|
if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit) && weapon.CurrentAmmunition > 0) { // Raycast from Bullet Exit Point to camera raycast
|
||||||
|
|
||||||
Debug.DrawLine(muzzle.transform.position, hit.point);
|
Debug.DrawLine(muzzle.transform.position, hit.point);
|
||||||
|
Debug.Log("BulletHole");
|
||||||
bulletHole(GameObject.CreatePrimitive(PrimitiveType.Sphere), hit); // Creates bullethole where raycast hits
|
bulletHole(GameObject.CreatePrimitive(PrimitiveType.Sphere), hit); // Creates bullethole where raycast hits
|
||||||
|
Debug.Log("hit Player?");
|
||||||
if (hit.transform.gameObject.GetComponent<Player>() != null) { // If hit object is a player
|
if (hit.transform.gameObject.GetComponent<Player>() != null) { // If hit object is a player
|
||||||
Debug.Log("-->HIT PLAYER: " + hit.transform.name);
|
Debug.Log("-->HIT PLAYER: " + hit.transform.name);
|
||||||
hit.transform.gameObject.GetComponent<Player>().RemoveHealth(weapon.Damage);
|
hit.transform.gameObject.GetComponent<Player>().RemoveHealth(weapon.Damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Debug.Log("SubtractAmmunition");
|
||||||
if (limitAmmunition) {
|
if (limitAmmunition) {
|
||||||
subtractAmmunition(weapon); // Subtract Ammunition
|
subtractAmmunition(weapon); // Subtract Ammunition
|
||||||
}
|
}
|
||||||
|
Debug.Log("Firerate");
|
||||||
StartCoroutine(fireRate());
|
StartCoroutine(fireRate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user