working on ai still

This commit is contained in:
2025-10-17 10:10:08 +02:00
parent 0bf2bbfb97
commit b04369531b
14 changed files with 131 additions and 20 deletions

View File

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

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d9d82f5af5ffea248a3cac2b7ea4a4af
guid: aadf824e76564404c8d43d99803c60a1
DefaultImporter:
externalObjects: {}
userData:

View File

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

View File

@@ -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: []

View File

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

View File

@@ -1,7 +1,8 @@
fileFormatVersion: 2
guid: 853091bba666d1541bcf46287f5d8b0a
DefaultImporter:
guid: 7b74808cded386840b654dee92400abd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a078042616c18a14fb11cb422b08df12
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 39e8c20c7fe505a488e7cdfc3da3b847
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

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