< Summary

Class:SpacialMovement
Assembly:Assembly-CSharp
File(s):D:/--UnityProject/VR/_____ISSTA 26/Island-Visualizer-PCVR/Assets/Scripts/Test/SpacialMovement.cs
Covered lines:35
Uncovered lines:11
Coverable lines:46
Total lines:79
Line coverage:76% (35 of 46)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SpacialMovement()0%000100%
Start()0%000100%
Update()0%00062.07%
startMovement()0%000100%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/Island-Visualizer-PCVR/Assets/Scripts/Test/SpacialMovement.cs

#LineLine coverage
 1using UnityEngine;
 2
 3public class SpacialMovement : MonoBehaviour
 4{
 45    public float moveSpeed = 10.0f; // Adjust this to control movement speed.
 46    public float rotationSpeed = 2.0f; // Adjust this to control rotation speed.
 47    public Vector2 limitX = new Vector2(490f, 560f);
 48    public Vector2 limitY = new Vector2(3.5f, 15f);
 49    public Vector2 limitZ = new Vector2(515f, 570f);
 410    public float delayToStartMovement = 3f;
 411    private float rotationX = 0.0f;
 412    private float rotationY = 0.0f;
 413    private bool allowMovement = false;
 14
 15    private void Start()
 216    {
 217        Cursor.visible = false;
 218        Invoke("startMovement", delayToStartMovement);
 219        rotationX = transform.rotation.eulerAngles.x;
 220        rotationY = transform.rotation.eulerAngles.y;
 221    }
 22
 23    private void Update()
 31924    {
 54225        if (!allowMovement) return;
 26        // Handle movement using WASD or arrow keys.
 9627        float horizontalInput = Input.GetAxis("Horizontal");
 9628        float verticalInput = Input.GetAxis("Vertical");
 29
 9630        Vector3 movement = new Vector3(horizontalInput, 0.0f, verticalInput) * moveSpeed * Time.deltaTime;
 9631        transform.Translate(movement);
 32
 33        // Get mouse input
 9634        float mouseX = Input.GetAxis("Mouse X");
 9635        float mouseY = Input.GetAxis("Mouse Y");
 36
 37        // Calculate the new rotations
 9638        rotationY += mouseX * rotationSpeed;
 9639        rotationX -= mouseY * rotationSpeed;
 40
 41        // Clamp the vertical rotation to prevent flipping
 9642        rotationX = Mathf.Clamp(rotationX, -90f, 90f);
 43
 44        // Apply the rotations to the GameObject
 9645        transform.rotation = Quaternion.Euler(rotationX, rotationY, 0.0f);
 46
 47        // Handle upward movement using the space key.
 9648        if (Input.GetKey(KeyCode.Space))
 049        {
 050            Vector3 upMovement = Vector3.up * moveSpeed * Time.deltaTime;
 051            transform.Translate(upMovement);
 052        }
 53
 54        // Handle downward movement using the left control key.
 9655        if (Input.GetKey(KeyCode.LeftControl))
 056        {
 057            Vector3 downMovement = Vector3.down * moveSpeed * Time.deltaTime;
 058            transform.Translate(downMovement);
 059        }
 60
 9661        transform.position = new Vector3
 62        (
 63            Mathf.Clamp(transform.position.x, limitX.x, limitX.y),
 64            Mathf.Clamp(transform.position.y, limitY.x, limitY.y),
 65            Mathf.Clamp(transform.position.z, limitZ.x, limitZ.y)
 66        );
 67
 9668        if(Input.GetKeyDown("escape"))
 069        {
 070            Application.Quit();
 071        }
 31972    }
 73
 74    private void startMovement()
 175    {
 176        allowMovement = true;
 177    }
 78}
 79