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