diff --git a/Assets/GothicVR/Resources/Prefabs/Vobs/zCVobSpot.prefab b/Assets/GothicVR/Resources/Prefabs/Vobs/zCVobSpot.prefab
index 1c04d66d4..0ef987adb 100644
--- a/Assets/GothicVR/Resources/Prefabs/Vobs/zCVobSpot.prefab
+++ b/Assets/GothicVR/Resources/Prefabs/Vobs/zCVobSpot.prefab
@@ -12,7 +12,6 @@ GameObject:
- component: {fileID: 5681108792341746749}
- component: {fileID: 4250102412515220408}
- component: {fileID: 3429925256554951498}
- - component: {fileID: 5979848652310601961}
m_Layer: 2
m_Name: zCVobSpot
m_TagString: PxVob_zCVobSpot
@@ -98,24 +97,3 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
---- !u!135 &5979848652310601961
-SphereCollider:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 3434156045681339339}
- m_Material: {fileID: 0}
- m_IncludeLayers:
- serializedVersion: 2
- m_Bits: 0
- m_ExcludeLayers:
- serializedVersion: 2
- m_Bits: 0
- m_LayerOverridePriority: 0
- m_IsTrigger: 1
- m_ProvidesContacts: 0
- m_Enabled: 1
- serializedVersion: 3
- m_Radius: 0.5
- m_Center: {x: 0, y: -0.0000019073486, z: -0.000015258789}
diff --git a/Assets/GothicVR/Resources/Prefabs/WayPoint.prefab b/Assets/GothicVR/Resources/Prefabs/WayPoint.prefab
index f82867b0d..d38ca960b 100644
--- a/Assets/GothicVR/Resources/Prefabs/WayPoint.prefab
+++ b/Assets/GothicVR/Resources/Prefabs/WayPoint.prefab
@@ -11,7 +11,6 @@ GameObject:
- component: {fileID: 2665078943939252271}
- component: {fileID: 1188047755481711733}
- component: {fileID: 6851058351796696224}
- - component: {fileID: 3747938385529500483}
m_Layer: 2
m_Name: WayPoint
m_TagString: Untagged
@@ -84,24 +83,3 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
---- !u!65 &3747938385529500483
-BoxCollider:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 4344130464614125633}
- m_Material: {fileID: 0}
- m_IncludeLayers:
- serializedVersion: 2
- m_Bits: 0
- m_ExcludeLayers:
- serializedVersion: 2
- m_Bits: 0
- m_LayerOverridePriority: 0
- m_IsTrigger: 1
- m_ProvidesContacts: 0
- m_Enabled: 1
- serializedVersion: 3
- m_Size: {x: 1, y: 1, z: 1}
- m_Center: {x: 0, y: 0, z: 0}
diff --git a/Assets/GothicVR/Scripts/Debugging/GvrGizmosDebug.cs b/Assets/GothicVR/Scripts/Debugging/GvrGizmosDebug.cs
new file mode 100644
index 000000000..787f5ca25
--- /dev/null
+++ b/Assets/GothicVR/Scripts/Debugging/GvrGizmosDebug.cs
@@ -0,0 +1,19 @@
+using UnityEngine;
+
+namespace GVR.Debugging
+{
+ ///
+ /// Add it to an object where you want to draw some information.
+ ///
+ public class GvrGizmosDebug : MonoBehaviour
+ {
+ private void OnDrawGizmos()
+ {
+ var pos = transform.position;
+ var up = new Vector3(pos.x, 100, pos.z);
+ var down = new Vector3(pos.x, -100, pos.z);
+
+ Gizmos.DrawLine(up, down);
+ }
+ }
+}
diff --git a/Assets/GothicVR/Scripts/Debugging/GvrGizmosDebug.cs.meta b/Assets/GothicVR/Scripts/Debugging/GvrGizmosDebug.cs.meta
new file mode 100644
index 000000000..1b77b25ee
--- /dev/null
+++ b/Assets/GothicVR/Scripts/Debugging/GvrGizmosDebug.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 178aac5ad24c4eae81d675be3b0136e2
+timeCreated: 1717123074
\ No newline at end of file
diff --git a/Assets/GothicVR/Scripts/Globals/Constants.cs b/Assets/GothicVR/Scripts/Globals/Constants.cs
index 20241a8a0..eb399ea2a 100644
--- a/Assets/GothicVR/Scripts/Globals/Constants.cs
+++ b/Assets/GothicVR/Scripts/Globals/Constants.cs
@@ -55,6 +55,9 @@ public static class Constants
// We need to set the scale so that collision and NPC animation is starting at the right spot.
public static Vector3 VobZSScale = new(0.1f, 0.1f, 0.1f);
+ // e.g. for NPCs to check if they reached a FreePoint already. Value is based on best guess/testing.
+ public const float CloseToThreshold = 0.6f;
+
static Constants()
{
LoadingMaterial = new Material(ShaderWorldLit);
diff --git a/Assets/GothicVR/Scripts/Manager/NpcHelper.cs b/Assets/GothicVR/Scripts/Manager/NpcHelper.cs
index 0e8c1ce75..9898e8e46 100644
--- a/Assets/GothicVR/Scripts/Manager/NpcHelper.cs
+++ b/Assets/GothicVR/Scripts/Manager/NpcHelper.cs
@@ -19,7 +19,7 @@ namespace GVR.Manager
{
public static class NpcHelper
{
- private const float fpLookupDistance = 20f; // meter
+ private const float fpLookupDistance = 7f; // meter
static NpcHelper()
{
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractAnimationAction.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractAnimationAction.cs
index 2599afcc8..8733aa649 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractAnimationAction.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractAnimationAction.cs
@@ -132,22 +132,12 @@ public virtual void AnimationEndEventCallback(SerializableEventEndSignal eventDa
IsFinishedFlag = true;
}
-
- public virtual void OnCollisionEnter(Collision coll)
- { }
- public virtual void OnTriggerEnter(Collider coll)
- { }
-
- public virtual void OnCollisionExit(Collision coll)
- { }
- public virtual void OnTriggerExit(Collider coll)
- { }
///
/// Called every update cycle.
/// Can be used to handle frequent things internally.
///
- public virtual void Tick(Transform transform)
+ public virtual void Tick()
{ }
///
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractRotateAnimationAction.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractRotateAnimationAction.cs
index dba4defc1..73ce9933d 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractRotateAnimationAction.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractRotateAnimationAction.cs
@@ -51,11 +51,11 @@ private string GetRotateModeAnimationString()
}
}
- public override void Tick(Transform transform)
+ public override void Tick()
{
- base.Tick(transform);
+ base.Tick();
- HandleRotation(transform);
+ HandleRotation(NpcGo.transform);
}
///
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractWalkAnimationAction.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractWalkAnimationAction.cs
index 1cf7479ee..a860016b0 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractWalkAnimationAction.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/AbstractWalkAnimationAction.cs
@@ -1,6 +1,7 @@
using System;
using GVR.Creator;
using GVR.Data.ZkEvents;
+using GVR.Globals;
using GVR.Manager;
using GVR.Vm;
using UnityEngine;
@@ -28,6 +29,8 @@ protected AbstractWalkAnimationAction(AnimationAction action, GameObject npcGo)
///
protected abstract Vector3 GetWalkDestination();
+ protected abstract void OnDestinationReached();
+
public override void Start()
{
base.Start();
@@ -35,9 +38,9 @@ public override void Start()
PhysicsHelper.EnablePhysicsForNpc(Props);
}
- public override void Tick(Transform transform)
+ public override void Tick()
{
- base.Tick(transform);
+ base.Tick();
if (IsFinishedFlag)
return;
@@ -46,16 +49,16 @@ public override void Tick(Transform transform)
{
case WalkState.Initial:
walkState = WalkState.Rotate;
- HandleRotation(transform, GetWalkDestination(), false);
+ HandleRotation(NpcGo.transform, GetWalkDestination(), false);
return;
case WalkState.Rotate:
- HandleRotation(transform, GetWalkDestination(), false);
+ HandleRotation(NpcGo.transform, GetWalkDestination(), false);
return;
case WalkState.Walk:
- HandleWalk(transform);
+ HandleWalk(Props.colliderRootMotion.transform);
return;
case WalkState.WalkAndRotate:
- HandleRotation(transform, GetWalkDestination(), true);
+ HandleRotation(NpcGo.transform, GetWalkDestination(), true);
return;
case WalkState.Done:
return; // NOP
@@ -87,11 +90,21 @@ private void StartWalk()
walkState = WalkState.Walk;
}
+
private void HandleWalk(Transform transform)
{
- // NOP
+ var npcPos = transform.position;
+ var walkPos = GetWalkDestination();
+ var npcDistPos = new Vector3(npcPos.x, walkPos.y, npcPos.z);
+
+ var distance = Vector3.Distance(npcDistPos, walkPos);
+
+ // FIXME - Scorpio is above FP, but values don't represent it.
+ if (distance < Constants.CloseToThreshold)
+ OnDestinationReached();
}
+
private void HandleRotation(Transform transform, Vector3 destination, bool includesWalking)
{
var pos = transform.position;
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToFp.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToFp.cs
index dab19edc9..019ad3564 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToFp.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToFp.cs
@@ -1,5 +1,4 @@
using GVR.Data.ZkEvents;
-using GVR.GothicVR.Scripts.Manager;
using GVR.Manager;
using GVR.Vob.WayNet;
using UnityEngine;
@@ -23,21 +22,6 @@ public override void Start()
var npcPos = NpcGo.transform.position;
fp = WayNetHelper.FindNearestFreePoint(npcPos, destination);
-
- // Fix - If NPC is spawned directly in front of the FP, we start transition immediately (otherwise trigger/collider won't be called).
- if (Vector3.Distance(npcPos, fp!.Position) < 1f)
- FreePointReached();
- }
-
- public override void OnTriggerEnter(Collider coll)
- {
- if (walkState != WalkState.Walk)
- return;
-
- if (coll.gameObject.name != fp.Name)
- return;
-
- FreePointReached();
}
public override void AnimationEndEventCallback(SerializableEventEndSignal eventData)
@@ -52,7 +36,7 @@ protected override Vector3 GetWalkDestination()
return fp.Position;
}
- private void FreePointReached()
+ protected override void OnDestinationReached()
{
Props.CurrentFreePoint = fp;
fp.IsLocked = true;
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToNpc.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToNpc.cs
index 4f5db6b8b..2c0317ab8 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToNpc.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToNpc.cs
@@ -33,5 +33,13 @@ public override void AnimationEndEventCallback(SerializableEventEndSignal eventD
IsFinishedFlag = false;
}
+
+ protected override void OnDestinationReached()
+ {
+ AnimationEndEventCallback(new SerializableEventEndSignal(nextAnimation: ""));
+
+ walkState = WalkState.Done;
+ IsFinishedFlag = true;
+ }
}
}
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToWp.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToWp.cs
index 293bdac39..a8b31ff1c 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToWp.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/GoToWp.cs
@@ -38,21 +38,26 @@ public override void Start()
destinationWaypoint.Name));
}
- public override void OnTriggerEnter(Collider coll)
+ protected override Vector3 GetWalkDestination()
{
- if (walkState != WalkState.Walk)
- return;
+ return route.Peek().Position;
+ }
- if (coll.gameObject.name != route.First().Name)
- return;
+ public override void AnimationEndEventCallback(SerializableEventEndSignal eventData)
+ {
+ base.AnimationEndEventCallback(eventData);
- // FIXME - get current waypoint object
- // props.currentWayPoint = coll.gameObject.
+ IsFinishedFlag = false;
+ }
+ protected override void OnDestinationReached()
+ {
route.Pop();
if (route.Count == 0)
{
+ AnimationEndEventCallback(new SerializableEventEndSignal(nextAnimation: ""));
+
walkState = WalkState.Done;
IsFinishedFlag = true;
}
@@ -62,17 +67,5 @@ public override void OnTriggerEnter(Collider coll)
walkState = WalkState.WalkAndRotate;
}
}
-
- protected override Vector3 GetWalkDestination()
- {
- return route.Peek().Position;
- }
-
- public override void AnimationEndEventCallback(SerializableEventEndSignal eventData)
- {
- base.AnimationEndEventCallback(eventData);
-
- IsFinishedFlag = false;
- }
}
}
diff --git a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/UseMob.cs b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/UseMob.cs
index 0cb9c20fb..eca3c584f 100644
--- a/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/UseMob.cs
+++ b/Assets/GothicVR/Scripts/Npc/Actions/AnimationActions/UseMob.cs
@@ -83,14 +83,8 @@ private GameObject GetNearestMobSlot(GameObject mob)
return slot;
}
- public override void OnTriggerEnter(Collider coll)
+ protected override void OnDestinationReached()
{
- if (walkState != WalkState.Walk)
- return;
-
- if (coll.gameObject != slotGo)
- return;
-
StartMobUseAnimation();
}
diff --git a/Assets/GothicVR/Scripts/Npc/AiHandler.cs b/Assets/GothicVR/Scripts/Npc/AiHandler.cs
index e2a9f5914..52e19f291 100644
--- a/Assets/GothicVR/Scripts/Npc/AiHandler.cs
+++ b/Assets/GothicVR/Scripts/Npc/AiHandler.cs
@@ -30,7 +30,7 @@ private void Start()
///
private void Update()
{
- properties.currentAction.Tick(transform);
+ properties.currentAction.Tick();
// Add new milliseconds when stateTime shall be measured.
if (properties.isStateTimeActive)
diff --git a/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs b/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs
index beebd4d9e..4dbe10945 100644
--- a/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs
+++ b/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs
@@ -1,48 +1,9 @@
-using GVR.Extensions;
-using GVR.Properties;
using UnityEngine;
namespace GVR.Npc
{
public class RootCollisionHandler : BasePlayerBehaviour
{
- private void OnCollisionEnter(Collision coll)
- {
- properties.currentAction?.OnCollisionEnter(coll);
- }
-
- private void OnTriggerEnter(Collider coll)
- {
- properties.currentAction?.OnTriggerEnter(coll);
- }
-
- private void OnCollisionExit(Collision coll)
- {
- properties.currentAction?.OnCollisionExit(coll);
-
- // FIXME - As we handle FreePoint locking via Colliders, we can't just say "free" whenever collider is left as a rotation can create this state already.
- // FIXME - Instead we need to handle unlocking via game logic. E.g. whenever a new state starts, clear our NPCs lock setting.
- // // If NPC walks out of a FreePoint, it gets freed.
- // if (coll.gameObject.name.StartsWithIgnoreCase("FP_") &&
- // coll.gameObject.TryGetComponent(out var vobSpotProperties))
- // vobSpotProperties.fp.IsLocked = false;
- }
-
- ///
- /// Sometimes a currentAnimation needs this information. Sometimes it's just for a FreePoint to clear up.
- ///
- private void OnTriggerExit(Collider coll)
- {
- properties.currentAction?.OnTriggerExit(coll);
-
- // FIXME - As we handle FreePoint locking via Colliders, we can't just say "free" whenever collider is left as a rotation can create this state already.
- // FIXME - Instead we need to handle unlocking via game logic. E.g. whenever a new state starts, clear our NPCs lock setting.
- // // If NPC walks out of a FreePoint, it gets freed.
- // if (coll.gameObject.name.StartsWithIgnoreCase("FP_") &&
- // coll.gameObject.TryGetComponent(out var vobSpotProperties))
- // vobSpotProperties.fp.IsLocked = false;
- }
-
private void Update()
{
// As we use legacy animations, we can't use RootMotion. We therefore need to rebuild it.