From b04369531b2775654a64502ab8597c455657bbd7 Mon Sep 17 00:00:00 2001 From: Brajanowski Date: Fri, 17 Oct 2025 10:10:08 +0200 Subject: [PATCH] working on ai still --- Assets/jelycho/Code/Enemies/ZombieActor.cs | 24 +++++++--- .../APIReference.zip.meta} | 2 +- Assets/jelycho/Code/Player/PlayerActor.cs | 13 +++--- .../core/enemies/Zombie/actor_zombie.prefab | 5 ++ ...ram_zombie_ground_locomotion_forward.asset | 15 ++++++ ...mbie_ground_locomotion_forward.asset.meta} | 5 +- ...param_zombie_ground_locomotion_right.asset | 15 ++++++ ..._zombie_ground_locomotion_right.asset.meta | 8 ++++ .../animancer/zombie_ground_locomotion.asset | 46 +++++++++++++++++++ .../zombie_ground_locomotion.asset.meta | 8 ++++ Assets/jelycho/core/player/a_player.prefab | 4 +- ...comotion.asset => ground_locomotion.asset} | 2 +- ...sset.meta => ground_locomotion.asset.meta} | 0 .../com.unity.probuilder/Settings.json | 4 +- 14 files changed, 131 insertions(+), 20 deletions(-) rename Assets/{JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_HDRP_v1.01.unitypackage.meta => jelycho/Code/KinematicCharacterController/APIReference.zip.meta} (74%) create mode 100644 Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset rename Assets/{JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_URP_v1.01.unitypackage.meta => jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset.meta} (52%) create mode 100644 Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset create mode 100644 Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset.meta create mode 100644 Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset create mode 100644 Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset.meta rename Assets/jelycho/core/player/animancer/{param_ground_locomotion.asset => ground_locomotion.asset} (97%) rename Assets/jelycho/core/player/animancer/{param_ground_locomotion.asset.meta => ground_locomotion.asset.meta} (100%) diff --git a/Assets/jelycho/Code/Enemies/ZombieActor.cs b/Assets/jelycho/Code/Enemies/ZombieActor.cs index 9475c1b..e3c3762 100644 --- a/Assets/jelycho/Code/Enemies/ZombieActor.cs +++ b/Assets/jelycho/Code/Enemies/ZombieActor.cs @@ -68,8 +68,6 @@ namespace RebootReality.jelycho.Enemies { return BehaviourNode.Status.Failure; } - Debug.Log("Picking victim"); - Actor victim = zombie.FindNewVictim(); if (victim == null) { return BehaviourNode.Status.Failure; @@ -85,8 +83,6 @@ namespace RebootReality.jelycho.Enemies { return BehaviourNode.Status.Failure; } - Debug.Log("Goto player"); - if (!zombie.HasTravelDestination) { float3 victimPos = zombie.Victim.transform.position; float dstToVictimSq = math.distancesq(victimPos, zombie.transform.position); @@ -131,6 +127,11 @@ namespace RebootReality.jelycho.Enemies { [SerializeField, Group("Body parts")] ZombieBodyPart m_LeftLeg; [SerializeField, Group("Body parts")] ZombieBodyPart m_RightLeg; + [SerializeField, Group("Animations")] TransitionAsset m_GroundLocomotion; + [SerializeField, Group("Animations")] StringAsset m_GroundLocomotionPropertyRight; + [SerializeField, Group("Animations")] StringAsset m_GroundLocomotionPropertyForward; + SmoothedVector2Parameter m_SmoothLocomotionDirection; + [SerializeField, Group("Animations")] AnimationClip[] m_AttackClips; BehaviourTree m_BehaviourTree; @@ -155,6 +156,12 @@ namespace RebootReality.jelycho.Enemies { void Awake() { SetRagdollLocal(IsRagdoll); + m_SmoothLocomotionDirection = new SmoothedVector2Parameter(m_Animancer, + m_GroundLocomotionPropertyRight, + m_GroundLocomotionPropertyForward, + 0.1f); + m_Animancer.Play(m_GroundLocomotion); + m_BehaviourTree = new BehaviourTree("Zombie Behaviour"); var rootSelector = new Selector("Root"); @@ -186,8 +193,11 @@ namespace RebootReality.jelycho.Enemies { return; } - float velXZ = m_NavAgent.velocity.With(y: 0).magnitude; - // m_Animator.SetFloat(s_MovementSpeedHash, velXZ); + float3 vel = m_NavAgent.velocity; + float forwardVelocity = math.dot(m_NavAgent.transform.forward, vel); + float rightVelocity = math.dot(m_NavAgent.transform.right, vel); + + m_SmoothLocomotionDirection.TargetValue = new Vector2(rightVelocity, forwardVelocity); } public override void OnServerTick(float deltaTime) { @@ -203,6 +213,7 @@ namespace RebootReality.jelycho.Enemies { if (math.distancesq(pos, TravelDestination) <= 1.0f) { HasTravelDestination = false; + m_NavAgent.isStopped = true; } } @@ -220,6 +231,7 @@ namespace RebootReality.jelycho.Enemies { TravelDestination = pos; HasTravelDestination = true; + m_NavAgent.isStopped = false; return m_NavAgent.SetDestination(TravelDestination); } diff --git a/Assets/JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_HDRP_v1.01.unitypackage.meta b/Assets/jelycho/Code/KinematicCharacterController/APIReference.zip.meta similarity index 74% rename from Assets/JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_HDRP_v1.01.unitypackage.meta rename to Assets/jelycho/Code/KinematicCharacterController/APIReference.zip.meta index 042b5b0..0fec58b 100644 --- a/Assets/JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_HDRP_v1.01.unitypackage.meta +++ b/Assets/jelycho/Code/KinematicCharacterController/APIReference.zip.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d9d82f5af5ffea248a3cac2b7ea4a4af +guid: aadf824e76564404c8d43d99803c60a1 DefaultImporter: externalObjects: {} userData: diff --git a/Assets/jelycho/Code/Player/PlayerActor.cs b/Assets/jelycho/Code/Player/PlayerActor.cs index 27a5175..a807505 100755 --- a/Assets/jelycho/Code/Player/PlayerActor.cs +++ b/Assets/jelycho/Code/Player/PlayerActor.cs @@ -656,12 +656,13 @@ namespace RebootReality.jelycho.Player { m_CurrentCameraBobbing = Mathf.MoveTowards(m_CurrentCameraBobbing, m_TargetCameraBobbing, m_CameraBobbingTransitionSpeed * deltaTime); - m_Camera.SetBobbing(m_CurrentCameraBobbing); + //m_Camera.SetBobbing(m_CurrentCameraBobbing); - m_CameraSpring.UpdateSpring(deltaTime, - m_CharacterForwardTransform.up, - m_CharacterForwardTransform.right, - m_CharacterForwardTransform.forward); + m_Camera.SetBobbing(0.0f); + // m_CameraSpring.UpdateSpring(deltaTime, + // m_CharacterForwardTransform.up, + // m_CharacterForwardTransform.right, + // m_CharacterForwardTransform.forward); } void SenseInteractable() { @@ -845,7 +846,6 @@ namespace RebootReality.jelycho.Player { float3 targetCharacterForward = math.normalize(LookDirection.With(y: 0.0f)); float3 currentCharacterForward = math.normalize(m_CharacterForwardTransform.forward.With(y: 0.0f)); - // float angleDeg = Mathf.DeltaAngle(m_Camera.Yaw, m_Locomotion.YawRotation); float angleRad = math.acos(math.clamp(math.dot(targetCharacterForward, currentCharacterForward) / (math.length(targetCharacterForward) * math.length(currentCharacterForward)), -1f, 1f)); float angleDeg = math.degrees(angleRad); @@ -881,6 +881,7 @@ namespace RebootReality.jelycho.Player { } // Aim Target adjustment + // @BUG: when humbie interacts with a player then a camera is shaking m_HeadAimTargetTransform.position = (float3) m_HeadBoneTransform.position + LookDirection * 5.0f; } diff --git a/Assets/jelycho/core/enemies/Zombie/actor_zombie.prefab b/Assets/jelycho/core/enemies/Zombie/actor_zombie.prefab index 8531164..58c8194 100644 --- a/Assets/jelycho/core/enemies/Zombie/actor_zombie.prefab +++ b/Assets/jelycho/core/enemies/Zombie/actor_zombie.prefab @@ -126,6 +126,11 @@ MonoBehaviour: - {fileID: 600210410026507738} - {fileID: 6618653062145489106} bloodStreamParticles: {fileID: 1270265462580972260} + m_GroundLocomotion: {fileID: 11400000, guid: 39e8c20c7fe505a488e7cdfc3da3b847, type: 2} + m_GroundLocomotionPropertyRight: {fileID: 11400000, guid: a078042616c18a14fb11cb422b08df12, type: 2} + m_GroundLocomotionPropertyForward: {fileID: 11400000, guid: 7b74808cded386840b654dee92400abd, type: 2} + m_AttackClips: + - {fileID: -203655887218126122, guid: da6de1de3c6a8fd4089dac405ac26f86, type: 3} died: m_PersistentCalls: m_Calls: [] diff --git a/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset new file mode 100644 index 0000000..d634916 --- /dev/null +++ b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + 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: 11500000, guid: 4d26ada6b8b155b4cbf61e26d6fc9a06, type: 3} + m_Name: param_zombie_ground_locomotion_forward + m_EditorClassIdentifier: + _EditorComment: diff --git a/Assets/JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_URP_v1.01.unitypackage.meta b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset.meta similarity index 52% rename from Assets/JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_URP_v1.01.unitypackage.meta rename to Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset.meta index 139b7fc..d657e1e 100644 --- a/Assets/JC_StylizedNature_Lite/JC_StylizedNatureLite_2022.3.1_URP_v1.01.unitypackage.meta +++ b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_forward.asset.meta @@ -1,7 +1,8 @@ fileFormatVersion: 2 -guid: 853091bba666d1541bcf46287f5d8b0a -DefaultImporter: +guid: 7b74808cded386840b654dee92400abd +NativeFormatImporter: externalObjects: {} + mainObjectFileID: 11400000 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset new file mode 100644 index 0000000..76b8138 --- /dev/null +++ b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + 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: 11500000, guid: 4d26ada6b8b155b4cbf61e26d6fc9a06, type: 3} + m_Name: param_zombie_ground_locomotion_right + m_EditorClassIdentifier: + _EditorComment: diff --git a/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset.meta b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset.meta new file mode 100644 index 0000000..362d5e7 --- /dev/null +++ b/Assets/jelycho/core/enemies/Zombie/animancer/param_zombie_ground_locomotion_right.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a078042616c18a14fb11cb422b08df12 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset b/Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset new file mode 100644 index 0000000..c7adfdd --- /dev/null +++ b/Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + 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: 11500000, guid: c5a8877f26e7a6a43aaf06fade1a064a, type: 3} + m_Name: zombie_ground_locomotion + m_EditorClassIdentifier: + _Transition: + rid: 2723988711188463719 + references: + version: 2 + RefIds: + - rid: 2723988711188463719 + type: {class: MixerTransition2D, ns: Animancer, asm: Kybernetik.Animancer} + data: + _FadeDuration: 0.25 + _Speed: 1 + _Events: + _NormalizedTimes: [] + _Callbacks: [] + _Names: [] + _Animations: + - {fileID: -203655887218126122, guid: 7cb1b14715c58f44eb90c93bdd4a6505, type: 3} + - {fileID: -203655887218126122, guid: cc1877bf70cb4ca4da39d89d9a461c34, type: 3} + - {fileID: -203655887218126122, guid: cc1877bf70cb4ca4da39d89d9a461c34, type: 3} + - {fileID: -203655887218126122, guid: cc1877bf70cb4ca4da39d89d9a461c34, type: 3} + - {fileID: -203655887218126122, guid: cc1877bf70cb4ca4da39d89d9a461c34, type: 3} + _Speeds: [] + _SynchronizeChildren: + _Thresholds: + - {x: 0, y: 0} + - {x: 0, y: 1} + - {x: 0, y: -1} + - {x: 1, y: 0} + - {x: -1, y: 0} + _DefaultParameter: {x: 0, y: 0} + _Type: 0 + _ParameterNameX: {fileID: 11400000, guid: a078042616c18a14fb11cb422b08df12, type: 2} + _ParameterNameY: {fileID: 11400000, guid: 7b74808cded386840b654dee92400abd, type: 2} diff --git a/Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset.meta b/Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset.meta new file mode 100644 index 0000000..c07eca3 --- /dev/null +++ b/Assets/jelycho/core/enemies/Zombie/animancer/zombie_ground_locomotion.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 39e8c20c7fe505a488e7cdfc3da3b847 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/jelycho/core/player/a_player.prefab b/Assets/jelycho/core/player/a_player.prefab index 9c2ab58..d8cc5d3 100644 --- a/Assets/jelycho/core/player/a_player.prefab +++ b/Assets/jelycho/core/player/a_player.prefab @@ -1024,7 +1024,7 @@ MonoBehaviour: FieldOfView: 70 OrthographicSize: 5 NearClipPlane: 0.12 - FarClipPlane: 500 + FarClipPlane: 1000 Dutch: 0 ModeOverride: 0 PhysicalProperties: @@ -1185,7 +1185,7 @@ AudioSource: m_Enabled: 1 serializedVersion: 4 OutputAudioMixerGroup: {fileID: -7246246608557242452, guid: 95a6b2fae6891e9428abd9f1d02ef54d, type: 2} - m_audioClip: {fileID: 8300000, guid: 5716155335402be4393584059b4ff19d, type: 3} + m_audioClip: {fileID: 0} m_Resource: {fileID: 8300000, guid: 5716155335402be4393584059b4ff19d, type: 3} m_PlayOnAwake: 0 m_Volume: 1 diff --git a/Assets/jelycho/core/player/animancer/param_ground_locomotion.asset b/Assets/jelycho/core/player/animancer/ground_locomotion.asset similarity index 97% rename from Assets/jelycho/core/player/animancer/param_ground_locomotion.asset rename to Assets/jelycho/core/player/animancer/ground_locomotion.asset index f9c467f..d6db648 100644 --- a/Assets/jelycho/core/player/animancer/param_ground_locomotion.asset +++ b/Assets/jelycho/core/player/animancer/ground_locomotion.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: c5a8877f26e7a6a43aaf06fade1a064a, type: 3} - m_Name: param_ground_locomotion + m_Name: ground_locomotion m_EditorClassIdentifier: _Transition: rid: 2723988420483612950 diff --git a/Assets/jelycho/core/player/animancer/param_ground_locomotion.asset.meta b/Assets/jelycho/core/player/animancer/ground_locomotion.asset.meta similarity index 100% rename from Assets/jelycho/core/player/animancer/param_ground_locomotion.asset.meta rename to Assets/jelycho/core/player/animancer/ground_locomotion.asset.meta diff --git a/ProjectSettings/Packages/com.unity.probuilder/Settings.json b/ProjectSettings/Packages/com.unity.probuilder/Settings.json index cda292f..190ff0b 100644 --- a/ProjectSettings/Packages/com.unity.probuilder/Settings.json +++ b/ProjectSettings/Packages/com.unity.probuilder/Settings.json @@ -89,7 +89,7 @@ { "type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "key": "ShapeBuilder.ActiveShapeIndex", - "value": "{\"m_Value\":1}" + "value": "{\"m_Value\":6}" }, { "type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", @@ -99,7 +99,7 @@ { "type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "key": "ShapeBuilder.LastSize.Plane", - "value": "{\"m_Value\":{\"x\":384.8273010253906,\"y\":0.0,\"z\":-189.3860626220703}}" + "value": "{\"m_Value\":{\"x\":-70.788330078125,\"y\":0.0,\"z\":35.4305419921875}}" }, { "type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",