Humanoid Control for Unity v4
|
A generic pointer to interact with objects in the scene using the Unity Event system.
The interaction pointer is a generic pointer to interact with objects in the scene using the Unity Event system or InteractionEvents. The objects can receive and react on these interactions when an Unity Event Trigger component has been added to them. The Teleporter is an specific implementation of an Interaction Pointer.
An interaction pointer can be added to any object. The objects Transform determines the starting position of the pointer and the pointer will always point in the direction of the Transform Forward.
The straight mode will cast a ray from the Transform position in the forward direction until it hits an object.
In bezier mode, a curve will be cast from the Transform position in the forward direction. The distance reached by this curve is limited. The curve is determine by the following parameters:
In gravity mode, a curve will be cast from the Transform position in the forward direction. This curve follows a gravity path as if an object is launched. The curve can be configured with the following parameters:
Is similar to the Straight mode, but casts a sphere instead of a ray. It has the following configuration parameters:
The Focus Point Object is disabled or enabled automatically when the Interaction Pointer is activated or deactivated. The Transform of the target point object will be updated based on the ray curve to match the focus point of the Interaction Pointer. It will be aligned with the normal of the surface. This object can be used to show the focus point of the interaction pointer in the way you like.
When an line renderer is attached to the Focus Point Object, it will automatically be updated to show the line ray casting curve. You can change this line render to your likings. Only the positions will be overwritten when the Interaction Pointer is active.
The following event of the Event System are currently supported:
Public Types | |
enum | RayType { Straight , Bezier , Gravity , SphereCast } |
The ray modes for interaction pointers. | |
enum | PointerType { FocusPoint , Ray } |
The type of interaction pointer. | |
Public Member Functions | |
void | PointTo (GameObject obj) |
void | SetDirection (Vector3 lookDirection) |
void | LaunchRigidbody (Rigidbody rigidbody) |
void | LaunchPrefab (GameObject prefab) |
void | SpawnOnObjectInFocus (GameObject prefab) |
Spawns a prefab as a child of the objectInFocus. | |
void | ApplyForce (float magnitude) |
void | FullClick () |
Click on the objectInFocus. | |
virtual void | Click (bool clicking=true) |
Change the click status on the objectInFocus. | |
virtual void | Activation (bool _active) |
Change the active status of the InteractionPointer. | |
virtual void | ActivateClick (bool _active) |
Static Public Member Functions | |
static InteractionPointer | Add (Transform parentTransform, PointerType pointerType=PointerType.Ray) |
Adds a default InteractionPointer to the transform. | |
Public Attributes | |
bool | active = true |
Is the interaction pointer active? | |
float | timedClick |
Automatically initiates a click when the objectInFocus does not change for the set amount of seconds. | |
GameObject | focusPointObj |
The GameObject which represents the focus point of the Interaction Pointer when it is active. | |
GameObject | objectInFocus |
The object to which the Interaction Pointer is pointing at. | |
float | focusDistance |
Distance to the objectInFocus. | |
RayType | rayType = RayType.Straight |
The ray mode for this interaction pointer. | |
float | maxDistance = 10 |
The maximum length of the curve in units(meters) | |
float | resolution = 0.2F |
The size of a segment in the curve. | |
float | speed = 3 |
The horizontal speed for a gravity curve. | |
float | radius = 0.1F |
The radius of the sphere in a SphereCast. | |
GameObjectEventHandlers | focusEvent |
Event based on the current focus. | |
Vector3EventList | focusPointEvent |
Event based on the current focus. | |
GameObjectEventHandlers | clickEvent |
Event based on the clicking status. | |
BoolEvent | activeEvent = new BoolEvent() |
Event based on the active status. | |
Protected Member Functions | |
virtual void | Awake () |
virtual InteractionModule | CreateInteractionModule () |
virtual EventSystem | CreateEventSystem () |
virtual void | Start () |
virtual void | Update () |
virtual void | UpdateStraight () |
virtual void | UpdateBezier () |
virtual Vector3[] | UpdateBezierCurve (Transform transform, float maxDistance, out Vector3 normal, out GameObject focusObject) |
Vector3 | GetPoint (float t, Transform transform) |
Vector3 | GetVelocity (float t, Transform transform) |
virtual void | UpdateGravity () |
virtual void | UpdateGravityCurve (Transform transform, float forwardSpeed, out Vector3 normal, out GameObject hitObject) |
virtual void | UpdateSpherecast () |
virtual void | UpdateFocus () |
void | UpdateFocusPoint () |
virtual void | OnDrawGizmosSelected () |
Static Protected Member Functions | |
static void | DebugLog (string s) |
|
static |
Adds a default InteractionPointer to the transform.
parentTransform | The transform to which the Teleporter will be added |
pointerType | The interaction pointer type for the Teleporter. |
void Passer.InteractionPointer.SpawnOnObjectInFocus | ( | GameObject | prefab | ) |
Spawns a prefab as a child of the objectInFocus.
prefab | The prefab to spawn |
The spawn position and rotation will match the focusPoint transform. When the objectInFocus is null, the prefab will be spawned as a root transform.
void Passer.InteractionPointer.FullClick | ( | ) |
Click on the objectInFocus.
This function will do a full click: a button down followed by a button up.
|
virtual |
Change the click status on the objectInFocus.
clicking | Indicates if the button is down |
Reimplemented in Passer.Teleporter.
|
virtual |
Change the active status of the InteractionPointer.
_active | Indicates if the InteractionPointer is active |
bool Passer.InteractionPointer.active = true |
Is the interaction pointer active?
When an interaction pointer is active, it will actively point to objects. The objectInFocus will be updated based on the pointer. When a focusPointObj is set, this object will be set active. When a Line Renderer is set, the line renderer will be updated according to the properties of the pointer.
float Passer.InteractionPointer.timedClick |
Automatically initiates a click when the objectInFocus does not change for the set amount of seconds.
The value 0 disables this function.
GameObject Passer.InteractionPointer.focusPointObj |
The GameObject which represents the focus point of the Interaction Pointer when it is active.
If this is set and the pointer is active, the object will be objected based on the pointer's properties This GameObject will be disabled when the pointer is not active.
GameObject Passer.InteractionPointer.objectInFocus |
The object to which the Interaction Pointer is pointing at.
This is updated at runtime while the pointer is active. The value is null when the pointer is not reaching any object.
float Passer.InteractionPointer.focusDistance |
Distance to the objectInFocus.
This is float.infintiy when no object is in focus
float Passer.InteractionPointer.maxDistance = 10 |
The maximum length of the curve in units(meters)
This value is used for Straight, SphereCast and Bezier RayTypes
float Passer.InteractionPointer.resolution = 0.2F |
The size of a segment in the curve.
Lower values will give a smoother curve, but requires more performance This value is used for Bezier and Gravity RayTypes
float Passer.InteractionPointer.speed = 3 |
The horizontal speed for a gravity curve.
A higher speed will reach further positions.
GameObjectEventHandlers Passer.InteractionPointer.focusEvent |
Event based on the current focus.
This event is generated from the objectInFocus. It has the objectInFocus as parameter. It can be used to execute functions when the focus changes between objects.
Vector3EventList Passer.InteractionPointer.focusPointEvent |
Event based on the current focus.
This event is generated from the objectInFocus. It has the objectInFocus as parameter. It can be used to execute functions when the focus changes between objects.
GameObjectEventHandlers Passer.InteractionPointer.clickEvent |
Event based on the clicking status.
This event is generated from the clicking boolean. It has the objectInFocus as parameter. It can be used to exectue functions when the user has clicked on an object.
Event based on the active status.
This event is genereated from the active boolean Is has the active boolean as parameter. It can be used to execute functions when the interaction pointer is activated.