protected override void FollowTarget()
    {
        Vector3 offset = GetFollowAxis() * behaviourSettings.Distance;

        cameraTransform.position = CM_MathTools.Lerp(cameraTransform.position, behaviourSettings.CameraTarget.position + offset, Time.deltaTime * behaviourSettings.Speed);
        base.FollowTarget();
    }
    protected virtual void LookAtTarget()
    {
        if (!IsValid)
        {
            return;
        }
        Matrix4x4 _oritentation = Matrix4x4.identity;
        Matrix4x4 _translation  = Matrix4x4.identity;
        Vector3   _pos          = cameraTransform.position;
        Vector3   _target       = behaviourSettings.CameraTarget.position;

        Vector3 _zAxis = CM_MathTools.Normalize(CM_MathTools.Substract(_pos, _target));

        Vector3 _xAxis = CM_MathTools.Normalize(CM_MathTools.CrossProduct(Vector3.up, _zAxis));
        Vector3 _yAxis = CM_MathTools.CrossProduct(_zAxis, _xAxis);

        _oritentation = new Matrix4x4(new Vector4(_xAxis.x, _xAxis.y, _xAxis.z, 0),
                                      new Vector4(_yAxis.x, _yAxis.y, _yAxis.z, 0),
                                      new Vector4(_zAxis.x, _zAxis.y, _zAxis.z, 0),
                                      new Vector4(0, 0, 0, 1));

        _translation = new Matrix4x4(
            new Vector4(1, 0, 0, 0),
            new Vector4(0, 1, 0, 0),
            new Vector4(0, 0, 1, 0),
            new Vector4(_pos.x, _pos.y, _pos.z, 1));
        cameraTransform.rotation = (_oritentation * _translation).rotation;
    }
Esempio n. 3
0
    protected virtual void LookAtTarget()
    {
        if (!IsValid)
        {
            return;
        }
        Matrix4x4 _orientation = Matrix4x4.identity;
        Matrix4x4 _translation = Matrix4x4.identity;
        Vector3   _pos         = cameraTransform.position;
        Vector3   _target      = cameraSettings.CameraTarget.position;

        Vector3 _zAxis = CM_MathTools.GetNormalize(CM_MathTools.GetVector3Substract(_target, _pos));

        Vector3 _xAxis = CM_MathTools.GetNormalize(CM_MathTools.GetVector3CrossProduct(Vector3.up, _zAxis));
        Vector3 _yAxis = CM_MathTools.GetVector3CrossProduct(_zAxis, _xAxis);

        _orientation = new Matrix4x4(new Vector4(_xAxis.x, _xAxis.y, _xAxis.z, 0),
                                     new Vector4(_yAxis.x, _yAxis.y, _yAxis.z, 0),
                                     new Vector4(_zAxis.x, _zAxis.y, _zAxis.z, 0),
                                     new Vector4(0, 0, 0, 1));

        _translation = new Matrix4x4(new Vector4(1, 0, 0, 0),
                                     new Vector4(0, 1, 0, 0),
                                     new Vector4(0, 0, 1, 0),
                                     new Vector4(-_pos.x, -_pos.y, -_pos.z, 1));


        Matrix4x4 _multiplied = _orientation * _translation;

        cameraTransform.rotation = _multiplied.rotation;

        //Debug.Log($"{CM_MathTools.GetVector3CrossProduct(Vector3.up, _zAxis)} - {Vector3.Cross(Vector3.up, _zAxis)}");
        //Debug.Log($"{_zAxis}-{_direction.normalized}");
        //cameraTransform.rotation.SetLookRotation(_zAxis);
    }
Esempio n. 4
0
 private void RotateAround()
 {
     if (!IsValid)
     {
         return;
     }
     cameraTransform.position = CM_MathTools.GetRotateAround(cameraSettings.CameraTarget.position, cameraSettings.CameraDistance, ref angle, cameraSettings.CameraSpeed, Time.deltaTime);
 }
Esempio n. 5
0
 private void OscilateCamera()
 {
     if (!IsValid)
     {
         return;
     }
     cameraTransform.position = CM_MathTools.GetOscilation(cameraTransform.position, cameraSettings.CameraDistance, ref delta, cameraSettings.CameraSpeed, Time.deltaTime);
 }
 private void RotateAround()
 {
     // cameraTransform.position = CM_MathTools.RotateAroud(behaviourSettings.CameraTarget.position, behaviourSettings.Distance , ref angle, behaviourSettings.Speed, Time.deltaTime);
     cameraTransform.position = CM_MathTools.RotateAroud(behaviourSettings.CameraTarget.position, behaviourSettings.Distance, angle, behaviourSettings.Speed);
 }
 private void Update()
 {
     this.transform.position = CM_MathTools.RotateAroud(targetTransform.position, 10, angle, 0);
 }
Esempio n. 8
0
    protected override void FollowTarget()
    {
        Vector3 _finalPos = cameraSettings.CameraTarget.position + (GetFollowAxis() * cameraSettings.CameraDistance);

        ;        cameraTransform.position = CM_MathTools.Lerp(cameraTransform.position, cameraSettings.CameraTarget.position, Time.deltaTime * cameraSettings.CameraSpeed);
    }