< Summary

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

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")]
 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()
 391324    {
 391325        ApplyVelocity();
 391326    }
 27
 28    private void ApplyVelocity()
 391329    {
 391330        Vector3 targetVelocity = inputVelocity * speed;
 391331        targetVelocity = origin.TransformDirection(targetVelocity);
 32
 391333        Vector3 velocityChange = targetVelocity - rigidBody.velocity;
 391334        rigidBody.AddForce(velocityChange, ForceMode.VelocityChange);
 391335    }
 36
 37    public void SetRightVelocity(float value)
 138    {
 139        inputVelocity.x = value;
 140    }
 41
 42    public void SetForwardVelocity(float value)
 143    {
 144        inputVelocity.z = value;
 145    }
 46
 47    public void SetUpVelocity(float value)
 148    {
 149        inputVelocity.y = value;
 150    }
 51
 52    private void OnValidate()
 553    {
 554        if (!origin)
 055            origin = transform;
 556    }
 57}