Exemplo n.º 1
0
 public void Execute(ref Mover mover, ref BodyTorque bodyTorque, ref Translation position, ref Rotation rotation)    // ref AIState brain, ,
 {
     if (mover.disabled == 0)
     {
         float3     normalBetween = math.normalizesafe(mover.target - position.Value);
         quaternion targetAngle   = quaternion.LookRotationSafe(0.05f * normalBetween, math.up());
         quaternion newAngle      = QuaternionHelpers.slerp(rotation.Value, targetAngle, delta);
         Quaternion newAngle2     = new Quaternion(newAngle.value.x, newAngle.value.y, newAngle.value.z, newAngle.value.w);
         rotation.Value = (newAngle2);
     }
 }
Exemplo n.º 2
0
 public void Execute(ref AIState brain, ref Wander wander, ref BodyForce body, ref BodyTorque torque, ref BodyInnerForce innerBody, ref Rotation rotation)
 {
     if (brain.state == 1)
     {
         if (wander.thinking == 0)
         {
             body.velocity      = new float3(0, 0, innerBody.movementForce);
             wander.targetAngle = (new float3(0, wander.random.NextFloat(0, 360), 0));
             if (time - wander.lastWandered >= wander.wanderCooldown)
             {
                 wander.lastWandered = time;
                 if (wander.Value.waitCooldownMin != 0 && wander.Value.waitCooldownMax != 0)
                 {
                     wander.thinking     = 1;
                     wander.waitCooldown = wander.random.NextFloat(wander.Value.waitCooldownMin, wander.Value.waitCooldownMax);
                 }
             }
         }
         else
         {
             body.velocity = new float3();
             if (time - wander.lastWandered >= wander.waitCooldown)
             {
                 wander.lastWandered   = time;
                 wander.wanderCooldown = wander.random.NextFloat(wander.Value.wanderCooldownMin, wander.Value.wanderCooldownMax);
                 wander.thinking       = 0;
             }
         }
         quaternion newAngle = QuaternionHelpers.slerp(
             rotation.Value,
             quaternion.Euler(wander.targetAngle),
             deltaTime * innerBody.movementTorque);
         Quaternion newAngle2 = new Quaternion(newAngle.value.x, newAngle.value.y, newAngle.value.z, newAngle.value.w);
         rotation.Value = newAngle2;
     }
 }