mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
added fire animation and fire rate
This commit is contained in:
Binary file not shown.
@@ -5,7 +5,10 @@ ModelImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
74: 4781951162920444690
|
||||
second: Armature|ArmatureAction
|
||||
second: Shoot
|
||||
- first:
|
||||
74: -3100369314251171874
|
||||
second: Idle
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
@@ -36,18 +39,47 @@ ModelImporter:
|
||||
extraUserProperties: []
|
||||
clipAnimations:
|
||||
- serializedVersion: 16
|
||||
name: Armature|ArmatureAction
|
||||
name: Shoot
|
||||
takeName: Armature|ArmatureAction
|
||||
internalID: 0
|
||||
firstFrame: 0
|
||||
lastFrame: 10
|
||||
lastFrame: 24
|
||||
wrapMode: 0
|
||||
orientationOffsetY: 0
|
||||
level: 0
|
||||
cycleOffset: 0
|
||||
loop: 0
|
||||
hasAdditiveReferencePose: 0
|
||||
loopTime: 0
|
||||
loopTime: 1
|
||||
loopBlend: 0
|
||||
loopBlendOrientation: 0
|
||||
loopBlendPositionY: 0
|
||||
loopBlendPositionXZ: 0
|
||||
keepOriginalOrientation: 0
|
||||
keepOriginalPositionY: 1
|
||||
keepOriginalPositionXZ: 0
|
||||
heightFromFeet: 0
|
||||
mirror: 0
|
||||
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||
curves: []
|
||||
events: []
|
||||
transformMask: []
|
||||
maskType: 3
|
||||
maskSource: {instanceID: 0}
|
||||
additiveReferencePoseFrame: 0
|
||||
- serializedVersion: 16
|
||||
name: Idle
|
||||
takeName: Armature|ArmatureAction
|
||||
internalID: 0
|
||||
firstFrame: 25
|
||||
lastFrame: 40
|
||||
wrapMode: 0
|
||||
orientationOffsetY: 0
|
||||
level: 0
|
||||
cycleOffset: 0
|
||||
loop: 0
|
||||
hasAdditiveReferencePose: 0
|
||||
loopTime: 1
|
||||
loopBlend: 0
|
||||
loopBlendOrientation: 0
|
||||
loopBlendPositionY: 0
|
||||
|
||||
@@ -686,8 +686,8 @@ MonoBehaviour:
|
||||
syncMode: 0
|
||||
syncInterval: 0.1
|
||||
muzzle: {fileID: 3649358604728444914}
|
||||
shootAnim: {fileID: 0}
|
||||
fireRate: 120
|
||||
shootAnim: {fileID: 4276885029697240453}
|
||||
fireRate: 320
|
||||
--- !u!114 &6207632454083444980
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -18,12 +18,14 @@ public class Headbob : NetworkBehaviour
|
||||
[SerializeField] private Transform Neck;
|
||||
|
||||
private Vector3 lastPos;
|
||||
private Vector3 startPos;
|
||||
private Vector3 newPos;
|
||||
private float oldDist = 0;
|
||||
private float lerpVal = 0;
|
||||
private void Start()
|
||||
{
|
||||
lastPos = this.transform.position;
|
||||
//startPos = this.transform.position;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -53,19 +55,7 @@ public class Headbob : NetworkBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Neck.localPosition = Vector3.zero;
|
||||
if (false) {
|
||||
Neck.localPosition = Vector3.Lerp(newPos, Vector3.zero, lerpVal);
|
||||
if (lerpVal < 1)
|
||||
{
|
||||
lerpVal = lerpVal + 0.01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Neck.position = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
Neck.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class PlayerMouseLook : NetworkBehaviour
|
||||
}
|
||||
playerCamera.position = playerNeck.position;
|
||||
playerCamera.position += playerNeck.up * neckLength;
|
||||
|
||||
|
||||
transform.Rotate(Vector3.up * currentMouseDelta.x * mouseSensitivity); //Rotate the hole player if looked sideways (Rotates the player left and right)
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,17 @@ public class ShootAnimation : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
[SerializeField]private GameObject gun;
|
||||
void Start()
|
||||
{
|
||||
anim = gun.GetComponent<Animator>();
|
||||
}
|
||||
|
||||
void OnSwitchWeapon(GameObject newGun)
|
||||
public void OnSwitchWeapon(float fireRate)
|
||||
{
|
||||
gun = newGun;
|
||||
//gun = newGun;
|
||||
anim = gun.GetComponent<Animator>();
|
||||
anim.SetFloat("ShootSpeed",1f/(60f/fireRate));
|
||||
}
|
||||
public void StartShootAnimation(float timeInSeconds)
|
||||
{
|
||||
anim.PlayInFixedTime("Shoot", 0, timeInSeconds);
|
||||
Debug.Log(anim.GetFloat("ShootSpeed"));
|
||||
anim.Play("Shoot");
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
||||
Reference in New Issue
Block a user