1 using System.Collections;
2 using System.Collections.Generic;
4 using UnityEngine.Events;
28 public bool isGrabbing => grabbedObject != null;
55 protected AVR_Grabbable grabbedObject => grabLocation!=null ? grabLocation.grabbable : null;
71 return grabbedObject ? grabLocation.localLocation : Vector3.zero;
80 return grabbedObject ? grabLocation.location : Vector3.zero;
83 protected override void Start() {
84 if(grabPoint==null) grabPoint = transform;
86 if (grabbableFinder == null) grabbableFinder = GetComponentInChildren<AVR_GrabbableFinder>();
87 if (grabbableFinder == null) {
88 AVR_DevConsole.error(
"Grabprovider " + gameObject.name +
" has no grabbableFinder assigned! Destroying " + gameObject.name);
98 return grabPoint.position;
106 return grabPoint.rotation;
123 else grabLocation = null;
131 grabLocation = location;
132 grabbedObject.Grab(
this);
139 if(grabbedObject !=null) {
141 grabbedObject.Release(
this);
148 if (IsOnline && !IsOwner)
return;
151 if(controller.inputManager.getEventStatus(grabEvent)) {
155 else if(controller.inputManager.getEventStatus(releaseEvent)) {
AVR_ControllerInputManager.BoolEvent grabEvent
Event that commences a grab. (Such as ONTRIGGERDOWN)
AVR_GrabbableFinder grabbableFinder
Area from which the player may grab an object. Required for the grabprovider to work.
virtual Quaternion getTargetRotation()
Target rotation the grabbed object should "strive" towards in world space. There will be force trying...
virtual Vector3 getTargetPosition()
Target position the grabbed object should "strive" towards in world coordiantes. There will be force ...
virtual Vector3 getLocalGrabLocation()
Offset at which an object is being grabbed. Meaning: grab-position in local coordiantes relative to t...
abstract bool getGrabLocation(out GrabLocation location)
Transform grabPoint
Transform of the location an object is grabbed towards (Typically the palm of your hand)...
virtual Vector3 getWorldGrabLocation()
Location at which the object is being grabbed in world coordinates. Example: If we grab a pan by its ...
Represents an (attempted) grab at a given location of an object.
Represents a grabbable object.
virtual void makeGrab()
Performs a grab on whichever object the GrabbableFinder returns. Is called when the respective "grabE...
GrabLocation grabLocation
virtual Transform getTargetTransform()
getTargetPosition() and getTargetRotation() combined into one transform. The grabbed objects transfor...
AVR_ControllerInputManager.BoolEvent releaseEvent
Event that ends a grab. (Such as ONTRIGGERUP)
virtual void makeRelease()
Ends a grab. Is called when the respective "releaseEvent" is true.
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
Simplest GrabProvider. Grabbed objects will move their center (obj.transform.position) towards the re...
virtual void makeGrab(GrabLocation location)
Perform a grab on with parameters given in a GrabLocation struct
UnityEvent OnRelease
Executed when a grabbed object is released.
AVR_Component specifically attatched to an AVR_Controller. Needs to have an AVR_Controller on this ga...
UnityEvent OnGrab
Executed when an object is (successfully) grabbed.
Class to retrieve a Grabbable object from a location, volume or similar.