public void Update(Transform _myTransform, Transform _targetTransform)
    {
        Vector3 targetDirection;
        float   step = 0;

        if (_targetTransform != null)
        {
            if (feedback == null && navigation == null)
            {
                feedback   = _myTransform.GetComponent <ObjectUserFeedback>();
                navigation = _myTransform.GetComponent <ObjectNavigation>();
            }

            if (dynamicRotation && !feedback.LightsFlickering)
            {
                Vector3 predictedNewPosition = Vector3.LerpUnclamped(navigation.LastPosition, _myTransform.position, 1.5f);
                targetDirection = predictedNewPosition - _myTransform.position;
                float angle = Vector3.Angle(_myTransform.forward, targetDirection);
                step = angle * Time.deltaTime * TURN_SPEED_DAMP;
            }
            else
            {
                targetDirection = _targetTransform.position - _myTransform.position;
                step            = ROTATESPEED * Time.deltaTime;
            }

            Vector3 newDirection = Vector3.RotateTowards(_myTransform.forward, targetDirection, step, 0.0f);
            _myTransform.rotation = Quaternion.LookRotation(newDirection);
        }
    }
示例#2
0
    private void Awake()
    {
        cam_Transform    = Camera.main.transform;
        canvas_Transform = functionTextMesh.transform.parent;

        navigation = GetComponent <ObjectNavigation>();
        navigation.OnNodeReached += OnNodeReachedFeedback;
    }
 public void Init(ObjectNavigation navigation, NodeAttributes node)
 {
     /*the standard movement script automatically behaves differently when instantiated after reaching a function node, because this means that
      * we are using a nonstandard version of rotation. A function must be either a movement function or rotation function*/
     if (node is FunctionNodeAttributes)
     {
         nonStandardRotation = (node as FunctionNodeAttributes).FunctionCount != 0;
         Debug.Log((node as FunctionNodeAttributes).FunctionCount);
     }
     else
     {
         nonStandardRotation = false;
     }
 }
    private void Awake()
    {
        if (observable != null)
        {
            ObjectNavigation objectNavigation = observable.GetComponent <ObjectNavigation>();
            objectNavigation.OnLeavingRoom  += OnLeavingRoom;
            objectNavigation.OnStartingRoom += OnStartingRoom;

            for (int i = 0; i < startnodes.Length; i++)
            {
                if (startnodes[i].GetInstanceID() == objectNavigation.MoveTarget.GetInstanceID())
                {
                    currentStartnodeIndex  = i;
                    currentObservePosition = GetObservePosition();
                    break;
                }
            }
        }
    }
示例#5
0
 public void Init(ObjectNavigation navigation, NodeAttributes node)
 {
     navigation.SetRotationBasedOnMoveDirection();
 }
示例#6
0
 public void Init(ObjectNavigation navigation, NodeAttributes node)
 {
 }
 public void Init(ObjectNavigation navigation, NodeAttributes node)
 {
     dynamicRotation = navigation.MoveDirectionBasedRotation;
 }
 public void Clean()
 {
     feedback   = null;
     navigation = null;
 }