Skip to content

Evidence Collection

Jayden Tarrance edited this page Apr 26, 2024 · 5 revisions

Users can walk around the scene and collect evidence in provided bags.

Screenshot (64)

Score Tracker

Each bag tracks what is put inside it - if the item is on the warrant, it adds to the user's current score. If not, then the user's score is penalized.

Bag Sockets

In VR, objects set to the same layer can be attached to socket objects. Each bag has a separate socket that only accepts one object before disabling.

Clones

When grabbing a bag, the object clones itself and replaces the space with a new one. These share the same properties as the original object at startup.

Cart

Evidence must be placed inside a bag and on the cart to be scored.

image

Cart Movement

The cart movement is calculated by getting the initial angle of rotation when a player grabs the cart, then while grabbing the cart, the change in rotation is added to the rotation of the cart. Also, the colliders for all objects inside the cart are turned off to improve performance.

void OnGrab(SelectEnterEventArgs args)
{
    // Optional: Save initial grab rotation if needed for more complex rotation handling

    interactor = args.interactorObject;
    initialHandYRotation = interactor.transform.rotation.eulerAngles.y;
    initalCartYRotation = transform.eulerAngles.y;

    CartTriggerZoneDectector cartTrigger = GetComponentInChildren<CartTriggerZoneDectector>();

    if (cartTrigger.objectsInCart.Count != 0)
    {
        foreach (GameObject key in cartTrigger.objectsInCart.Keys)
        {
            Collider[] objectColliders = key.GetComponentsInChildren<Collider>();
            foreach (Collider col in objectColliders)
            {
                col.enabled = false; // Disable each collider
            }
        }
    }
}

void FixedUpdate()
{
    if (grabInteractable.isSelected)
    {

        float newHandYRotation = interactor.transform.rotation.eulerAngles.y;
        float YRotation = (initalCartYRotation - (initialHandYRotation - newHandYRotation));

        Quaternion newRotation = Quaternion.Euler(0, YRotation, 0);
        transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.fixedDeltaTime * rotationDampening);
    }
}

Clone this wiki locally