< Summary

Class:MoveWithVelocity
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/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)

D:/--UnityProject/VR/_____ISSTA 26/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")]
 710    public float speed = 1.0f;
 11
 12    [Tooltip("Controls the direction of movement")]
 713    public Transform origin = null;
 14
 715    private Vector3 inputVelocity = Vector3.zero;
 716    private Rigidbody rigidBody = null;
 17
 18    private void Awake()
 319    {
 320        rigidBody = GetComponent<Rigidbody>();
 321    }
 22
 23    private void FixedUpdate()
 614524    {
 614525        ApplyVelocity();
 614526    }
 27
 28    private void ApplyVelocity()
 614529    {
 614530        Vector3 targetVelocity = inputVelocity * speed;
 614531        targetVelocity = origin.TransformDirection(targetVelocity);
 32
 614533        Vector3 velocityChange = targetVelocity - rigidBody.velocity;
 614534        rigidBody.AddForce(velocityChange, ForceMode.VelocityChange);
 614535    }
 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()
 753    {
 754        if (!origin)
 055            origin = transform;
 756    }
 57}