Beispiel #1
0
 private void Awake()
 {
     raycast = new Raycast()
     {
         Origin = () => transform.position
     };
     detector = new GroundDetector(raycast, distance, 0f, distance);
 }
        /// <summary>
        /// Initialization
        /// </summary>
        private void Awake()
        {
            //Create a new ground detector, which is linked to this characters transform
            //TODO: allow ground detector to be linked to a different trasnform, or a different origin tracking method all together
            groundDetector = new GroundDetector(new Raycast(transform, Vector3.down), 1f, 0.1f, 1f);
            //Attach a rigidbody to the character
            rigidbody = gameObject.AddComponent <Rigidbody>();
            //Turn off gravity, so that it can be simulated by the caracter controller
            //Leaving gravity on can cause the character to have movement studders with the framerate
            rigidbody.useGravity = false;
            //Freeze the rotation of the character, so that it can be controlled by the animation controller for the character
            rigidbody.constraints   = RigidbodyConstraints.FreezeRotation;
            rigidbody.interpolation = RigidbodyInterpolation.None;

            GetComponent <Collider>().material = PhysMat;
        }