< Summary

Class:MoveWithVelocity
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Basics/Assets/_Course Library/Scripts/Core/MoveWithVelocity.cs
Covered lines:19
Uncovered lines:10
Coverable lines:29
Total lines:57
Line coverage:65.5% (19 of 29)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:8
Method coverage:62.5% (5 of 8)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MoveWithVelocity()0%000100%
Awake()0%000100%
FixedUpdate()0%000100%
ApplyVelocity()0%000100%
SetRightVelocity(...)0%0000%
SetForwardVelocity(...)0%0000%
SetUpVelocity(...)0%0000%
OnValidate()0%00075%

File(s)

E:/Unity/Unity Project/VR-Basics/Assets/_Course Library/Scripts/Core/MoveWithVelocity.cs

#LineLine coverage
 1using UnityEngine;
 2
 3/// <summary>
 4/// Move an object using velocity
 5/// </summary>
 6[RequireComponent(typeof(Rigidbody))]
 7public class MoveWithVelocity : MonoBehaviour
 8{
 9    [Tooltip("The speed at which the object is moved")]
 510    public float speed = 1.0f;
 11
 12    [Tooltip("Controls the direction of movement")]
 513    public Transform origin = null;
 14
 515    private Vector3 inputVelocity = Vector3.zero;
 516    private Rigidbody rigidBody = null;
 17
 18    private void Awake()
 219    {
 220        rigidBody = GetComponent<Rigidbody>();
 221    }
 22
 23    private void FixedUpdate()
 418324    {
 418325        ApplyVelocity();
 418326    }
 27
 28    private void ApplyVelocity()
 418329    {
 418330        Vector3 targetVelocity = inputVelocity * speed;
 418331        targetVelocity = origin.TransformDirection(targetVelocity);
 32
 418333        Vector3 velocityChange = targetVelocity - rigidBody.velocity;
 418334        rigidBody.AddForce(velocityChange, ForceMode.VelocityChange);
 418335    }
 36
 37    public void SetRightVelocity(float value)
 038    {
 039        inputVelocity.x = value;
 040    }
 41
 42    public void SetForwardVelocity(float value)
 043    {
 044        inputVelocity.z = value;
 045    }
 46
 47    public void SetUpVelocity(float value)
 048    {
 049        inputVelocity.y = value;
 050    }
 51
 52    private void OnValidate()
 553    {
 554        if (!origin)
 055            origin = transform;
 556    }
 57}