added animation for weapon(walking)

This commit is contained in:
2022-04-13 22:38:42 +07:00
parent 95f61ab7e2
commit 1d41490f11
6 changed files with 88 additions and 13 deletions

View File

@ -1 +1 @@
{"count":1,"self":10.4549528,"total":10.4648434,"children":{"InitializeActuators":{"count":1,"self":0.0009976,"total":0.0009976,"children":null},"AgentSendState":{"count":288,"self":0.0029771,"total":0.0029771,"children":null},"DecideAction":{"count":288,"self":0.0049163,"total":0.0049163,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1649746841","unity_version":"2019.4.35f1","command_line_arguments":"D:\\Unity\\2019.4.35f1\\Editor\\Unity.exe -projectpath C:\\Users\\kiril\\real-shooter -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-kiril -hubSessionId 21e9de90-ba14-11ec-9398-079edccf5e34 -accessToken oIpf_7gKWQQRilVTeJehUsFhrxasdzsG_K3j5Swtgx0009f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"dont touch me plz","end_time_seconds":"1649746852"}}
{"count":1,"self":19.0202384,"total":19.0566016,"children":{"InitializeActuators":{"count":1,"self":0,"total":0,"children":null},"AgentSendState":{"count":716,"self":0.0039968,"total":0.0039968,"children":null},"DecideAction":{"count":716,"self":0.0313674,"total":0.0313674,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1649863963","unity_version":"2019.4.35f1","command_line_arguments":"D:\\Unity\\2019.4.35f1\\Editor\\Unity.exe -projectpath C:\\Users\\kiril\\real-shooter -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-kiril -hubSessionId 08b23f90-bb2b-11ec-8f91-71b1a8087934 -accessToken wPoaGUoqAdMDDj6g73Y4y-aTBFUY2UVeaU34xyILphA009f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"dont touch me plz","end_time_seconds":"1649863982"}}

View File

@ -37,11 +37,11 @@ Material:
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Scale: {x: 2, y: 2}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Texture: {fileID: 2800000, guid: e2d3ffb9e0c5b7a4d95d18b01f2c27e1, type: 3}
m_Scale: {x: 2, y: 2}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
@ -61,7 +61,7 @@ Material:
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _Glossiness: 0.52
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0

View File

@ -171,7 +171,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d911963c0a55d5243b20ebed4dddc9fd, type: 2}
- {fileID: 2100000, guid: 6f04a5d154786a140adee4d3bde602bb, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

View File

@ -1,5 +1,56 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4839747462788443060
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8723084081118426009}
- component: {fileID: 5958306789513936477}
m_Layer: 0
m_Name: WeaponAnimations
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8723084081118426009
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4839747462788443060}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4936565370263846416}
m_Father: {fileID: 8510909888689775087}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &5958306789513936477
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4839747462788443060}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 1ae0500836ae5b040ab0c41e276bf073, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1 &5245491127989480125
GameObject:
m_ObjectHideFlags: 0
@ -159,6 +210,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9826297ef4d853741b2af768441ec7f7, type: 3}
m_Name:
m_EditorClassIdentifier:
input_Movement: {x: 0, y: 0}
input_View: {x: 0, y: 0}
cameraHolder: {fileID: 5245491129196666053}
feetTransform: {fileID: 5245491129603592455}
@ -201,6 +253,7 @@ MonoBehaviour:
CameraHeight: -0.58
StanceCollider: {fileID: 5245491127989480121}
currentWeapon: {fileID: 8510909888689775086}
weaponAnimationSpeed: 0
--- !u!114 &8693388664594773644
MonoBehaviour:
m_ObjectHideFlags: 0
@ -391,7 +444,7 @@ Transform:
m_LocalPosition: {x: 0.332, y: 0.038, z: 0.394}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4936565370263846416}
- {fileID: 8723084081118426009}
m_Father: {fileID: 5245491129196666053}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -415,12 +468,18 @@ MonoBehaviour:
SwayResetSmoothing: 0.1
SwayClampX: 8
SwayClampY: 8
MovementSwayX: 0
MovementSwayY: 0
MovementSwayYInverted: 0
MovementSwayXInverted: 0
MovementSwaySmoothing: 0
weaponAnimator: {fileID: 5958306789513936477}
--- !u!1001 &142004959385982218
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 8510909888689775087}
m_TransformParent: {fileID: 8723084081118426009}
m_Modifications:
- target: {fileID: -4216859302048453862, guid: 99fcce1f10b2ebd4a8cd31a345f6bed8,
type: 3}
@ -445,7 +504,7 @@ PrefabInstance:
- target: {fileID: -4216859302048453862, guid: 99fcce1f10b2ebd4a8cd31a345f6bed8,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.098
value: 0.09800026
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 99fcce1f10b2ebd4a8cd31a345f6bed8,
type: 3}
@ -455,7 +514,7 @@ PrefabInstance:
- target: {fileID: -4216859302048453862, guid: 99fcce1f10b2ebd4a8cd31a345f6bed8,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.485
value: 0.4849999
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 99fcce1f10b2ebd4a8cd31a345f6bed8,
type: 3}

View File

@ -54,7 +54,11 @@ public class scr_CharacterController : MonoBehaviour
private Vector3 newMovementSpeed;
private Vector3 newMovementSpeedVelocity;
[Header("Weapon")] public scr_WeaponController currentWeapon;
[Header("Weapon")]
public scr_WeaponController currentWeapon;
public float weaponAnimationSpeed;
private void Awake()
{
defaultInput = new DefaultInput();
@ -138,6 +142,13 @@ public class scr_CharacterController : MonoBehaviour
playerSettings.SpeedEffector = 1;
}
weaponAnimationSpeed = characterController.velocity.magnitude / (playerSettings.WalkingForwardSpeed * playerSettings.SpeedEffector);
if (weaponAnimationSpeed > 1)
{
weaponAnimationSpeed = 1;
}
verticalSpeed *= playerSettings.SpeedEffector;
horizontalSpeed *= playerSettings.SpeedEffector;

View File

@ -4,9 +4,12 @@ using static scr_Models;
public class scr_WeaponController : MonoBehaviour
{
private scr_CharacterController characterController;
[Header("Settings")]
[Header("Settings")]
public WeaponSettingsModel settings;
[Header("References")]
public Animator weaponAnimator;
private bool isInitialised;
Vector3 newWeaponRotation;
@ -38,6 +41,8 @@ public class scr_WeaponController : MonoBehaviour
{
return;
}
weaponAnimator.speed = characterController.weaponAnimationSpeed;
targetWeaponRotation.y += settings.SwayAmount * (settings.SwayXInverted ? -characterController.input_View.x : characterController.input_View.x) * Time.deltaTime;
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;