Compare commits

..

2 Commits

Author SHA1 Message Date
9f0a889eb0 bugfix: camera stuttering when humbie touched the player 2025-10-18 21:57:30 +02:00
b04369531b working on ai still 2025-10-17 10:10:08 +02:00
14 changed files with 128 additions and 17 deletions

View File

@@ -68,8 +68,6 @@ namespace RebootReality.jelycho.Enemies {
return BehaviourNode.Status.Failure; return BehaviourNode.Status.Failure;
} }
Debug.Log("Picking victim");
Actor victim = zombie.FindNewVictim(); Actor victim = zombie.FindNewVictim();
if (victim == null) { if (victim == null) {
return BehaviourNode.Status.Failure; return BehaviourNode.Status.Failure;
@@ -85,8 +83,6 @@ namespace RebootReality.jelycho.Enemies {
return BehaviourNode.Status.Failure; return BehaviourNode.Status.Failure;
} }
Debug.Log("Goto player");
if (!zombie.HasTravelDestination) { if (!zombie.HasTravelDestination) {
float3 victimPos = zombie.Victim.transform.position; float3 victimPos = zombie.Victim.transform.position;
float dstToVictimSq = math.distancesq(victimPos, zombie.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_LeftLeg;
[SerializeField, Group("Body parts")] ZombieBodyPart m_RightLeg; [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; [SerializeField, Group("Animations")] AnimationClip[] m_AttackClips;
BehaviourTree m_BehaviourTree; BehaviourTree m_BehaviourTree;
@@ -155,6 +156,12 @@ namespace RebootReality.jelycho.Enemies {
void Awake() { void Awake() {
SetRagdollLocal(IsRagdoll); 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"); m_BehaviourTree = new BehaviourTree("Zombie Behaviour");
var rootSelector = new Selector("Root"); var rootSelector = new Selector("Root");
@@ -186,8 +193,11 @@ namespace RebootReality.jelycho.Enemies {
return; return;
} }
float velXZ = m_NavAgent.velocity.With(y: 0).magnitude; float3 vel = m_NavAgent.velocity;
// m_Animator.SetFloat(s_MovementSpeedHash, velXZ); 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) { public override void OnServerTick(float deltaTime) {
@@ -203,6 +213,7 @@ namespace RebootReality.jelycho.Enemies {
if (math.distancesq(pos, TravelDestination) <= 1.0f) { if (math.distancesq(pos, TravelDestination) <= 1.0f) {
HasTravelDestination = false; HasTravelDestination = false;
m_NavAgent.isStopped = true;
} }
} }
@@ -220,6 +231,7 @@ namespace RebootReality.jelycho.Enemies {
TravelDestination = pos; TravelDestination = pos;
HasTravelDestination = true; HasTravelDestination = true;
m_NavAgent.isStopped = false;
return m_NavAgent.SetDestination(TravelDestination); return m_NavAgent.SetDestination(TravelDestination);
} }

View File

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

View File

@@ -450,8 +450,10 @@ namespace RebootReality.jelycho.Player {
} else { } else {
InterpolateActorState(deltaTime); InterpolateActorState(deltaTime);
} }
}
TickCharacterRotation(deltaTime);
void LateUpdate() {
TickCharacterRotation(Time.deltaTime);
} }
protected override void OnActorCommandServer(ulong senderID, ActorCommand actorCommand) { protected override void OnActorCommandServer(ulong senderID, ActorCommand actorCommand) {
@@ -845,7 +847,6 @@ namespace RebootReality.jelycho.Player {
float3 targetCharacterForward = math.normalize(LookDirection.With(y: 0.0f)); float3 targetCharacterForward = math.normalize(LookDirection.With(y: 0.0f));
float3 currentCharacterForward = math.normalize(m_CharacterForwardTransform.forward.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 angleRad = math.acos(math.clamp(math.dot(targetCharacterForward, currentCharacterForward) / (math.length(targetCharacterForward) * math.length(currentCharacterForward)), -1f, 1f));
float angleDeg = math.degrees(angleRad); float angleDeg = math.degrees(angleRad);

View File

@@ -126,6 +126,11 @@ MonoBehaviour:
- {fileID: 600210410026507738} - {fileID: 600210410026507738}
- {fileID: 6618653062145489106} - {fileID: 6618653062145489106}
bloodStreamParticles: {fileID: 1270265462580972260} 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: died:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] 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 fileFormatVersion: 2
guid: 853091bba666d1541bcf46287f5d8b0a guid: 7b74808cded386840b654dee92400abd
DefaultImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: 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 FieldOfView: 70
OrthographicSize: 5 OrthographicSize: 5
NearClipPlane: 0.12 NearClipPlane: 0.12
FarClipPlane: 500 FarClipPlane: 1000
Dutch: 0 Dutch: 0
ModeOverride: 0 ModeOverride: 0
PhysicalProperties: PhysicalProperties:
@@ -1185,7 +1185,7 @@ AudioSource:
m_Enabled: 1 m_Enabled: 1
serializedVersion: 4 serializedVersion: 4
OutputAudioMixerGroup: {fileID: -7246246608557242452, guid: 95a6b2fae6891e9428abd9f1d02ef54d, type: 2} 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_Resource: {fileID: 8300000, guid: 5716155335402be4393584059b4ff19d, type: 3}
m_PlayOnAwake: 0 m_PlayOnAwake: 0
m_Volume: 1 m_Volume: 1

View File

@@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c5a8877f26e7a6a43aaf06fade1a064a, type: 3} m_Script: {fileID: 11500000, guid: c5a8877f26e7a6a43aaf06fade1a064a, type: 3}
m_Name: param_ground_locomotion m_Name: ground_locomotion
m_EditorClassIdentifier: m_EditorClassIdentifier:
_Transition: _Transition:
rid: 2723988420483612950 rid: 2723988420483612950

View File

@@ -89,7 +89,7 @@
{ {
"type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ShapeBuilder.ActiveShapeIndex", "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", "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", "type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.LastSize.Plane", "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", "type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",