Esempio n. 1
0
    private void HandleMove(float speedChangeUnitsPerSecond)
    {
        float   delta       = speedChangeUnitsPerSecond * Time.deltaTime;
        Vector3 flatForward = new Vector3(CachedTransform.forward.x, 0f, CachedTransform.forward.z).normalized;

        Vector3 newPosition = CachedTransform.position + flatForward * delta;

        CachedTransform.SetPositionAndRotation(newPosition, CachedTransform.rotation);
    }
Esempio n. 2
0
    private void HandleRotation(float orbitChangeAnglesPerSecond)
    {
        float angles = orbitChangeAnglesPerSecond * Time.deltaTime;

        Quaternion rotation = Quaternion.AngleAxis(angles, Vector3.up);
        Vector3    camPos   = (rotation * _fromOrbitTargetToCameraFlat) + _orbitTarget;
        Quaternion camRot   = Quaternion.Euler(new Vector3(0f, angles, 0f)) * CachedTransform.rotation;

        CachedTransform.SetPositionAndRotation(camPos, camRot);
    }