Exemplo n.º 1
0
        private void OnDrawGizmosSelected()
        {
            if (Application.isPlaying)
            {
                Gizmos.color = Color.cyan;
                Gizmos.DrawWireSphere(_destinationPosition, 0.25f);
                Gizmos.DrawWireSphere(_startingPosition, 0.25f);
                Gizmos.DrawLine(_startingPosition, _destinationPosition);
            }
            else
            {
                Vector3 destinationPosition = this.transform.position + (Vector3Helper.GetDirection(_direction, this.transform) * _travelDistance);

                Gizmos.color = Color.cyan;
                Gizmos.DrawWireSphere(destinationPosition, 0.25f);
                Gizmos.DrawLine(this.transform.position, destinationPosition);
            }
        }
Exemplo n.º 2
0
        private void Initialize()
        {
            _rigidbody = this.GetComponent <Rigidbody>();
            if (_rigidbody != null)
            {
                _rigidbody.isKinematic            = true;
                _rigidbody.mass                   = 10;
                _rigidbody.angularDrag            = 0;
                _rigidbody.interpolation          = RigidbodyInterpolation.Interpolate;
                _rigidbody.constraints            = RigidbodyConstraints.FreezeRotation;
                _rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
                if (_direction != Direction.LocalUp && _direction != Direction.WorldUp && _direction != Direction.LocalDown && _direction != Direction.WorldDown)
                {
                    _rigidbody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotation;
                }
            }

            // Define default positions
            _startingPosition    = this.transform.position;
            _destinationPosition = this.transform.position + (Vector3Helper.GetDirection(_direction, this.transform) * _travelDistance);

            _active = _activeOnAwake;
        }