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

  • Object Placement

    • TriggerZone

      image

    • Functionality

      There are trigger zones in each bucket of the cart which detect when an object is placed inside the cart. When an object is placed into the cart there are a series of events that happen:

      • A check happens that insures the objects tag is set to "Interactable"
      • Another check makes sure the object is not already in the list, objectsInCart, and it is not being held
      • If those checks pass, then the object is added to the list, objectsInCart
      • The object's parent is set to the cart
      • The object is set to Kinematic so that physics does not affect it
      • If the object is a Bag, then the variable, numberOfBagsInCart, on the ScoreTracker is incremented by 1
  • 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