mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-30 04:57:10 +01:00
added fire animation and fire rate
This commit is contained in:
@@ -8,6 +8,14 @@ public class Shoot : NetworkBehaviour
|
||||
[SerializeField] GameObject muzzle;
|
||||
[SerializeField] ShootAnimation shootAnim;
|
||||
[SerializeField] float fireRate;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
shootAnim.OnSwitchWeapon(fireRate);
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
@@ -28,7 +36,7 @@ public class Shoot : NetworkBehaviour
|
||||
GameObject dedplayer;
|
||||
RaycastHit hit;
|
||||
|
||||
shootAnim.StartShootAnimation(60f/fireRate);
|
||||
shootAnimation();
|
||||
|
||||
if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit))
|
||||
{
|
||||
@@ -43,9 +51,9 @@ public class Shoot : NetworkBehaviour
|
||||
|
||||
[Client]
|
||||
// This code will be executed on the Client.
|
||||
void RpcOnFire()
|
||||
void shootAnimation()
|
||||
{
|
||||
|
||||
shootAnim.StartShootAnimation(fireRate);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user