< Summary

Class:MoveWithVelocity
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Basics/Assets/_Course Library/Scripts/Core/MoveWithVelocity.cs
Covered lines:28
Uncovered lines:1
Coverable lines:29
Total lines:57
Line coverage:96.5% (28 of 29)
Covered branches:0
Total branches:0
Covered methods:8
Total methods:8
Method coverage:100% (8 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%000100%
SetForwardVelocity(...)0%000100%
SetUpVelocity(...)0%000100%
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")]
 210    public float speed = 1.0f;
 11
 12    [Tooltip("Controls the direction of movement")]
 213    public Transform origin = null;
 14
 215    private Vector3 inputVelocity = Vector3.zero;
 216    private Rigidbody rigidBody = null;
 17
 18    private void Awake()
 119    {
 120        rigidBody = GetComponent<Rigidbody>();
 121    }
 22
 23    private void FixedUpdate()
 313324    {
 313325        ApplyVelocity();
 313326    }
 27
 28    private void ApplyVelocity()
 313329    {
 313330        Vector3 targetVelocity = inputVelocity * speed;
 313331        targetVelocity = origin.TransformDirection(targetVelocity);
 32
 313333        Vector3 velocityChange = targetVelocity - rigidBody.velocity;
 313334        rigidBody.AddForce(velocityChange, ForceMode.VelocityChange);
 313335    }
 36
 37    public void SetRightVelocity(float value)
 838    {
 839        inputVelocity.x = value;
 840    }
 41
 42    public void SetForwardVelocity(float value)
 843    {
 844        inputVelocity.z = value;
 845    }
 46
 47    public void SetUpVelocity(float value)
 848    {
 849        inputVelocity.y = value;
 850    }
 51
 52    private void OnValidate()
 253    {
 254        if (!origin)
 055            origin = transform;
 256    }
 57}