< Summary

Class:FollowWithDamping
Assembly:Camera
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Camera/FollowWithDamping.cs
Covered lines:23
Uncovered lines:0
Coverable lines:23
Total lines:57
Line coverage:100% (23 of 23)
Covered branches:0
Total branches:0
Covered methods:6
Total methods:6
Method coverage:100% (6 of 6)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FollowWithDamping()0%110100%
Start()0%220100%
OnEnable()0%110100%
OnDisable()0%110100%
LateUpdate()0%22090.91%
OnWorldOffsetChange(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Camera/FollowWithDamping.cs

#LineLine coverage
 1using System;
 2using Cinemachine.Utility;
 3using UnityEngine;
 4
 5public class FollowWithDamping : MonoBehaviour
 6{
 7    public Transform target;
 8    public Vector3 damping;
 3419    public float dampingChangeSpeed = 0.5f;
 10
 11    [Header("Debug Zone")]
 12    public Vector3 currentDamping;
 13
 14    private void Start()
 15    {
 30116        currentDamping = damping;
 17
 30118        if (target != null)
 19        {
 30120            transform.position = target.position;
 30121            transform.forward = target.forward;
 22        }
 23
 30124        transform.parent = null;
 30125    }
 26
 27    private void OnEnable()
 28    {
 32429        CommonScriptableObjects.worldOffset.OnChange += OnWorldOffsetChange;
 32430    }
 31
 32    private void OnDisable()
 33    {
 32434        CommonScriptableObjects.worldOffset.OnChange -= OnWorldOffsetChange;
 32435    }
 36
 37    public void LateUpdate()
 38    {
 635239        if ( target == null ) return;
 40
 635241        Vector3 myPosition = transform.position;
 635242        Vector3 targetPosition = target.position;
 635243        Vector3 finalPosition = myPosition;
 44
 635245        currentDamping += Damper.Damp( damping - currentDamping, Vector3.one * dampingChangeSpeed, Time.deltaTime);
 635246        finalPosition += Damper.Damp(targetPosition - myPosition,  currentDamping, Time.deltaTime);
 47
 635248        Transform t = this.transform;
 635249        t.position = finalPosition;
 635250        t.forward = target.forward;
 635251    }
 52
 53    private void OnWorldOffsetChange(Vector3 current, Vector3 previous)
 54    {
 255        transform.position -= current - previous;
 256    }
 57}