< 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{
 35    public float moveSpeed = 10.0f; // Adjust this to control movement speed.
 36    public float rotationSpeed = 2.0f; // Adjust this to control rotation speed.
 37    public Vector2 limitX = new Vector2(490f, 560f);
 38    public Vector2 limitY = new Vector2(3.5f, 15f);
 39    public Vector2 limitZ = new Vector2(515f, 570f);
 310    public float delayToStartMovement = 3f;
 311    private float rotationX = 0.0f;
 312    private float rotationY = 0.0f;
 313    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()
 20524    {
 33025        if (!allowMovement) return;
 26        // Handle movement using WASD or arrow keys.
 8027        float horizontalInput = Input.GetAxis("Horizontal");
 8028        float verticalInput = Input.GetAxis("Vertical");
 29
 8030        Vector3 movement = new Vector3(horizontalInput, 0.0f, verticalInput) * moveSpeed * Time.deltaTime;
 8031        transform.Translate(movement);
 32
 33        // Get mouse input
 8034        float mouseX = Input.GetAxis("Mouse X");
 8035        float mouseY = Input.GetAxis("Mouse Y");
 36
 37        // Calculate the new rotations
 8038        rotationY += mouseX * rotationSpeed;
 8039        rotationX -= mouseY * rotationSpeed;
 40
 41        // Clamp the vertical rotation to prevent flipping
 8042        rotationX = Mathf.Clamp(rotationX, -90f, 90f);
 43
 44        // Apply the rotations to the GameObject
 8045        transform.rotation = Quaternion.Euler(rotationX, rotationY, 0.0f);
 46
 47        // Handle upward movement using the space key.
 8048        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.
 8055        if (Input.GetKey(KeyCode.LeftControl))
 056        {
 057            Vector3 downMovement = Vector3.down * moveSpeed * Time.deltaTime;
 058            transform.Translate(downMovement);
 059        }
 60
 8061        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
 8068        if(Input.GetKeyDown("escape"))
 069        {
 070            Application.Quit();
 071        }
 20572    }
 73
 74    private void startMovement()
 175    {
 176        allowMovement = true;
 177    }
 78}
 79