added fire animation and fire rate

This commit is contained in:
juliuse98
2021-11-06 17:07:06 +01:00
parent 4fc928f530
commit 360ceb55f3
8 changed files with 217 additions and 189 deletions

Binary file not shown.

View File

@@ -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

View File

@@ -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

View File

@@ -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()
@@ -54,18 +56,6 @@ 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;
}
}
}
}

View File

@@ -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);
}
}

View File

@@ -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()

View File

@@ -45,10 +45,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 298.4
x: 839.2
y: 73.6
width: 710.80005
height: 413.4
width: 330.8
height: 449.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -59,7 +59,7 @@ MonoBehaviour:
m_ShowGizmos: 0
m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
m_TargetSize: {x: 710.80005, y: 392.4}
m_TargetSize: {x: 330.8, y: 428.4}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@@ -74,10 +74,10 @@ MonoBehaviour:
m_VRangeLocked: 0
hZoomLockedByDefault: 0
vZoomLockedByDefault: 0
m_HBaseRangeMin: -284.32004
m_HBaseRangeMax: 284.32004
m_VBaseRangeMin: -156.96
m_VBaseRangeMax: 156.96
m_HBaseRangeMin: -132.31999
m_HBaseRangeMax: 132.31999
m_VBaseRangeMin: -171.36
m_VBaseRangeMax: 171.36
m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1
@@ -95,23 +95,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 710.80005
height: 392.4
m_Scale: {x: 1.1592739, y: 1.1592739}
m_Translation: {x: 355.40002, y: 196.2}
width: 330.8
height: 428.4
m_Scale: {x: 1.1592737, y: 1.1592739}
m_Translation: {x: 165.4, y: 214.2}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -306.57123
y: -169.24387
width: 613.14246
height: 338.48773
x: -142.67552
y: -184.77083
width: 285.35104
height: 369.54166
m_MinimalGUI: 1
m_defaultScale: 1
m_LastWindowPixelSize: {x: 888.50006, y: 516.75}
m_LastWindowPixelSize: {x: 413.5, y: 561.75}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
@@ -136,7 +136,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1171.2
width: 1172
height: 730.8
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
@@ -157,13 +157,13 @@ MonoBehaviour:
m_Children:
- {fileID: 5}
- {fileID: 7}
- {fileID: 9}
- {fileID: 10}
m_Position:
serializedVersion: 2
x: 0
y: 0
width: 1171.2
height: 434.4
width: 1172
height: 470.4
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 8096}
vertical: 0
@@ -185,8 +185,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 298.4
height: 434.4
width: 492
height: 470.4
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 6}
@@ -216,8 +216,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 73.6
width: 297.4
height: 413.4
width: 491
height: 449.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -225,9 +225,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 581cffff
m_LastClickedID: -58280
m_ExpandedIDs: 621cffff661cffff8e1cffffb220ffffbc20ffffc020ffffe820ffff3ab1ffff3eb1ffff48b1ffff4cb1ffff74b1ffffb0f2ffff2cfbffff
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 660bffff7a0bffff800bffffac0bffff540fffff680fffff6e0fffff9a0fffffd842ffffec42fffff242ffff1e43ffff4c58ffff6058ffff6658ffff9258ffff6876ffff7c76ffff8276ffffae76ffff8cceffff96ceffff9aceffffc6ceffff7ef2ffff84f2ffffe0f3ffffe4f3ffffeef3fffff2f3ffff1ef4ffffdcfaffffeafaffffeefaffff1afbffff2afbffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -261,24 +261,88 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: GameView
m_Name: SceneView
m_EditorClassIdentifier:
m_Children: []
m_Position:
serializedVersion: 2
x: 298.4
x: 492
y: 0
width: 712.80005
height: 434.4
width: 347.2
height: 470.4
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 2}
m_ActualView: {fileID: 9}
m_Panes:
- {fileID: 8}
- {fileID: 2}
- {fileID: 9}
m_Selected: 1
m_LastSelected: 0
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 12914, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: Animator
m_Image: {fileID: 1711060831702674872, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 297.6
y: 73.6
width: 207.6
height: 450
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
m_SaveData: []
m_ViewTransforms:
m_KeySerializationHelper:
- {fileID: 7614406280852874800, guid: daf332133edb41440a3abb1cf6e24558, type: 2}
m_ValueSerializationHelper:
- e00: 0.93576187
e01: 0
e02: 0
e03: -345.5047
e10: 0
e11: 0.93576187
e12: 0
e13: 81.44865
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_PreviewAnimator: {fileID: 0}
m_AnimatorController: {fileID: 9100000, guid: daf332133edb41440a3abb1cf6e24558, type: 2}
m_BreadCrumbs:
- m_Target: {fileID: 7614406280852874800, guid: daf332133edb41440a3abb1cf6e24558, type: 2}
m_ScrollPosition: {x: 0, y: 0}
stateMachineGraph: {fileID: 0}
stateMachineGraphGUI: {fileID: 0}
blendTreeGraph: {fileID: 0}
blendTreeGraphGUI: {fileID: 0}
m_AutoLiveLink: 1
m_MiniTool: 0
m_LockTracker:
m_IsLocked: 0
m_CurrentEditor: 0
m_LayerEditor:
m_SelectedLayerIndex: 0
--- !u!114 &9
MonoBehaviour:
m_ObjectHideFlags: 52
m_CorrespondingSourceObject: {fileID: 0}
@@ -298,10 +362,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 298.4
x: 492
y: 73.6
width: 579.6
height: 413.4
width: 345.2
height: 449.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -366,9 +430,9 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 1
snapOffset: {x: 67.5, y: 86}
snapOffset: {x: -140.5, y: 86}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
snapCorner: 1
id: Orientation
index: 0
layout: 4
@@ -498,25 +562,25 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffset: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Animation Rigging
index: 11
layout: 4
m_WindowGUID: cc27987af1a868c49b0894db9c0f5429
m_Gizmos: 1
m_Gizmos: 0
m_OverrideSceneCullingMask: 6917529027641081856
m_SceneIsLit: 1
m_SceneIsLit: 0
m_SceneLighting: 1
m_2DMode: 0
m_isRotationLocked: 0
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 0.6799998, y: -2899.7808, z: 0}
m_Target: {x: 0.5076783, y: 3.9909852, z: 0.061484996}
speed: 2
m_Value: {x: 0.6799998, y: -2899.7808, z: 0}
m_Value: {x: 0.5076783, y: 3.9909852, z: 0.061484996}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@@ -563,13 +627,13 @@ MonoBehaviour:
m_GridAxis: 1
m_gridOpacity: 0.5
m_Rotation:
m_Target: {x: 0.15275785, y: -0.5323912, z: 0.09836364, w: 0.8267796}
m_Target: {x: -0.013870413, y: 0.90260464, z: 0.029275607, w: 0.42936158}
speed: 2
m_Value: {x: -0.15275785, y: 0.5323912, z: -0.09836363, w: -0.82677954}
m_Value: {x: -0.013869748, y: 0.90256137, z: 0.029274205, w: 0.42934102}
m_Size:
m_Target: 12.124355
m_Target: 0.22076394
speed: 2
m_Value: 12.124355
m_Value: 0.22076394
m_Ortho:
m_Target: 1
speed: 2
@@ -594,32 +658,6 @@ MonoBehaviour:
m_SceneVisActive: 1
m_LastLockedObject: {fileID: 0}
m_ViewIsLockedToObject: 0
--- !u!114 &9
MonoBehaviour:
m_ObjectHideFlags: 52
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: AnimatorControllerTool
m_EditorClassIdentifier:
m_Children: []
m_Position:
serializedVersion: 2
x: 1011.2
y: 0
width: 159.99994
height: 434.4
m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 10}
m_Panes:
- {fileID: 10}
m_Selected: 0
m_LastSelected: 0
--- !u!114 &10
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -629,61 +667,23 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 12914, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: GameView
m_EditorClassIdentifier:
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: Animator
m_Image: {fileID: 1711060831702674872, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
m_Children: []
m_Position:
serializedVersion: 2
x: 1011.2
y: 73.6
width: 157.99994
height: 413.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
m_SaveData: []
m_ViewTransforms:
m_KeySerializationHelper:
- {fileID: 7614406280852874800, guid: daf332133edb41440a3abb1cf6e24558, type: 2}
m_ValueSerializationHelper:
- e00: 1
e01: 0
e02: 0
e03: -330.4
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_PreviewAnimator: {fileID: 0}
m_AnimatorController: {fileID: 9100000, guid: daf332133edb41440a3abb1cf6e24558, type: 2}
m_BreadCrumbs:
- m_Target: {fileID: 7614406280852874800, guid: daf332133edb41440a3abb1cf6e24558, type: 2}
m_ScrollPosition: {x: 0, y: 0}
stateMachineGraph: {fileID: 0}
stateMachineGraphGUI: {fileID: 0}
blendTreeGraph: {fileID: 0}
blendTreeGraphGUI: {fileID: 0}
m_AutoLiveLink: 1
m_MiniTool: 0
m_LockTracker:
m_IsLocked: 0
m_CurrentEditor: 0
m_LayerEditor:
m_SelectedLayerIndex: 0
x: 839.2
y: 0
width: 332.8
height: 470.4
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 2}
m_Panes:
- {fileID: 2}
m_Selected: 0
m_LastSelected: 0
--- !u!114 &11
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -694,23 +694,23 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: ProjectBrowser
m_Name: ConsoleWindow
m_EditorClassIdentifier:
m_Children: []
m_Position:
serializedVersion: 2
x: 0
y: 434.4
width: 1171.2
height: 296.4
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 12}
y: 470.4
width: 1172
height: 260.4
m_MinSize: {x: 101, y: 121}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 13}
m_Panes:
- {fileID: 12}
- {fileID: 13}
m_Selected: 0
m_LastSelected: 1
m_Selected: 1
m_LastSelected: 0
--- !u!114 &12
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -732,9 +732,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 508
width: 1170.2
height: 275.4
y: 544
width: 1171
height: 239.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -752,22 +752,22 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Objects/Weapons/M9
- Assets/Prefabs/Player
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 64
m_LastFolders:
- Assets/Objects/Weapons/M9
- Assets/Prefabs/Player
m_LastFoldersGridSize: -1
m_LastProjectPath: C:\Users\juliu\Desktop\Ausbildung\Fps-build\3d-shooter
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 68.600006}
m_SelectedIDs: 926f0000
m_LastClickedID: 28562
m_ExpandedIDs: 000000000e5c0000105c0000325d00008466000000ca9a3bffffff7f
scrollPos: {x: 0, y: 185}
m_SelectedIDs: 6a670000
m_LastClickedID: 26474
m_ExpandedIDs: 000000004e62000050620000606200006262000066620000b8620000f462000000ca9a3bffffff7f
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -795,7 +795,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 000000000e5c0000105c000000ca9a3bffffff7f
m_ExpandedIDs: 000000004e62000050620000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -820,10 +820,10 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_ListAreaState:
m_SelectedInstanceIDs: 581cffff
m_LastClickedInstanceID: -58280
m_HadKeyboardFocusLastEvent: 0
m_ExpandedInstanceIDs: c6230000986f000030660000
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c623000030660000986f0000d65e0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -872,9 +872,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 508
width: 1170
height: 275
y: 544
width: 1171
height: 239.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -894,12 +894,12 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 1171.2
x: 1172
y: 0
width: 364.80005
width: 364
height: 730.8
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 15}
m_Panes:
- {fileID: 15}
@@ -925,9 +925,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1171.2001
x: 1172
y: 73.6
width: 363.80005
width: 363
height: 709.8
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: