コード例 #1
0
        /*private Vector3 GetBeforeCollision()
         * {
         *
         *  Transform worldOrigin = creature.transform;
         *  Vector3 relativeVel =
         *      rigidbody.transform.InverseTransformDirection(rigidbody.velocity);
         *  RaycastHit hit;
         *  float distanceZ = float.MaxValue, distanceX = float.MaxValue;
         *
         *
         *  Vector3 direction;
         *  if (relativeVel.x > 0)
         *      direction = creature.transform.right;
         *  else
         *      direction = -creature.transform.right;
         *  rayLength = miscVariables[MiscVariables.AgentMiscVariables.Agent_Detect_Collision_X_Distance];
         *  if (Physics.Raycast(worldOrigin.position + direction, direction, out hit, rayLength))
         *  {
         *      if(DEBUG)
         *          Debug.DrawLine(worldOrigin.position + direction, hit.point, Color.blue, .5f);
         *      distanceX = Vector3.Distance(worldOrigin.position, hit.point);
         *  }
         *  if (distanceX < 0) distanceX = 0;
         *  if (distanceZ < 0) distanceZ = 0;
         *  if(_inTime)
         *      return new Vector3(distanceX/relativeVel.x, -1, distanceZ/relativeVel.z);
         *  else
         *      return new Vector3(distanceX, -1, distanceZ);
         * }
         * public Vector3 GetDistanceBeforeCollision()
         * {
         *  GetBeforeCollision();
         * }
         * public Vector3 GetTimeBeforeCollision()
         * {
         *  return GetBeforeCollision(true,false);
         * }*/
        #endregion CALCULATION METHODS

        // CONSTRUCTOR //
        public CreatureAgent(Creature creature)
        {
            this.creature           = creature;
            positionLastUpdate      = Vector3.zero;
            DistanceMovedLastUpdate = 0;
            touchingBodies          = new List <Transform>();
            miscVariables           = MiscVariables.GetAgentMiscVariables(creature);
            Active = true;
        }
コード例 #2
0
ファイル: Part.cs プロジェクト: Rakjavik/EmergenceOfRak
        protected Dictionary <MiscVariables.AgentMiscVariables, float> miscVariables; // Misc Constants

        public Part(CreaturePart creaturePart, Transform transform, float updateEvery)
        {
            this.PartType      = creaturePart;
            this.PartTransform = transform;
            this.UpdateEvery   = updateEvery;

            this.parentCreature = transform.GetComponentInParent <Creature>();
            this.attachedAgent  = parentCreature.GetCreatureAgent();
            miscVariables       = MiscVariables.GetAgentMiscVariables(parentCreature);
            audioClip           = CreatureConstants.GetCreaturePartAudioClip(parentCreature.GetBaseSpecies(), creaturePart);
            Enabled             = true;
        }