Humanoid Control for Unity v4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Passer.Teleporter Class Reference

Description

The teleporter is a simple tool to teleport transforms.

Humanoid Control comes with built-in teleport support which can be customized using standard Unity solutions. The Teleporter is a specific implementation of an Interaction Pointer.

Setup

Two types of teleportation are supported:

Gaze Teleportation

You can enable gaze based teleportation on the Head Target of the Humanoid. Here you will find an ‘Add Teleporter’ button:

When this button is pressed, a Teleporter GameObject (see below) will be attached to the Head Target. It will be active by default so that you will see the focus point continuously when running the scene. The focus object is a simple sphere, while no line renderer is present. Additionally, the Left Button One of the controller will be set to the Click event of the Teleport which will teleport the humanoid to the location in focus:

The Left Button One will match the Menu Button on the SteamVR Controller and the X button of the Left Oculus Touch Controller.

Pointing Teleportation

Hand pointing based teleportation is activated on either Hand Target. Like above, you will find an ‘Add Teleporter’ button here:

This will add a Teleporter GameObject to the Hand Target. In this case, no focus object is used, but an line renderer is used to show the pointing direction. This is visible as a standard pink ray on the hand. Pointing teleporting is activated when the ‘One’ button is pressed. While the Click event is matched to the Trigger button. The former matches to the Menu Button on the SteamVR controller which the latter is the Trigger on this controller. On the Oculus Touch, the One button is the X or A button, while the trigger button is the Index Finger Trigger button.

Of course you can change these button assignments through the editing of the Controller Input, setting the desired button to the Teleporter.Activation and -.Click functions.

Configuration

For more information on these parameters, see the InteractionPointer Interaction Pointer.

Target Point Object

The target point object is disabled or enabled automatically when the Teleporter is activates or deactivated. The Transform of the target point object will be updated based on the ray curve to match the location where the teleport will go.It will be aligned with the Normal of the surface. This object can be used to show the target of the teleportation in the way you like.

Line Renderer

When an line renderer is attached to the Target 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 teleporter is active.

Inheritance diagram for Passer.Teleporter:
Passer.InteractionPointer

Public Types

enum  TransportType { Teleport , Dash }
 Determines how the Transform is moved to the Target Point.
 
enum  RayType { Straight , Bezier , Gravity , SphereCast }
 The ray modes for interaction pointers.
 
enum  PointerType { FocusPoint , Ray }
 The type of interaction pointer.
 

Public Member Functions

virtual void TeleportTransform ()
 Teleport the transform.
 
override void Click (bool clicking)
 Change the click status on the objectInFocus.
 
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 Activation (bool _active)
 Change the active status of the InteractionPointer.
 
virtual void ActivateClick (bool _active)
 

Static Public Member Functions

static new Teleporter Add (Transform parentTransform, PointerType pointerType=PointerType.Ray)
 Adds a default Teleporter to the transform.
 

Public Attributes

TransportType transportType = TransportType.Teleport
 The TransportType to use when teleporting.
 
Transform transformToTeleport
 The transform which will be teleported.
 
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

override 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)
 

Protected Attributes

HumanoidControl humanoid
 
bool hasClicked = false
 
InteractionModule interactionModule
 
int interactionID
 
InteractionModule.InteractionPointer interactionPointer
 
LineRenderer lineRenderer
 The LineRender for this pointer when available.
 
float focusTimeToTouch = 0
 
float focusStart = 0
 
float heightLimitAngle = 100f
 
Vector3 startPosition = Vector3.zero
 
Vector3 intermediatePosition
 
Vector3 endPosition
 
GameObject previousObjectInFocus
 

Member Function Documentation

◆ Awake()

override void Passer.Teleporter.Awake ( )
protectedvirtual

Reimplemented from Passer.InteractionPointer.

◆ Add()

static new Teleporter Passer.Teleporter.Add ( Transform  parentTransform,
PointerType  pointerType = PointerType::Ray 
)
static

Adds a default Teleporter to the transform.

Parameters
parentTransformThe transform to which the Teleporter will be added
pointerTypeThe interaction pointer type for the Teleporter

◆ Click()

override void Passer.Teleporter.Click ( bool  clicking)
virtual

Change the click status on the objectInFocus.

Parameters
clickingIndicates if the button is down

Reimplemented from Passer.InteractionPointer.

◆ SpawnOnObjectInFocus()

void Passer.InteractionPointer.SpawnOnObjectInFocus ( GameObject  prefab)
inherited

Spawns a prefab as a child of the objectInFocus.

Parameters
prefabThe 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.

◆ FullClick()

void Passer.InteractionPointer.FullClick ( )
inherited

Click on the objectInFocus.

This function will do a full click: a button down followed by a button up.

◆ Activation()

virtual void Passer.InteractionPointer.Activation ( bool  _active)
virtualinherited

Change the active status of the InteractionPointer.

Parameters
_activeIndicates if the InteractionPointer is active

Member Data Documentation

◆ active

bool Passer.InteractionPointer.active = true
inherited

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.

◆ timedClick

float Passer.InteractionPointer.timedClick
inherited

Automatically initiates a click when the objectInFocus does not change for the set amount of seconds.

The value 0 disables this function.

◆ focusPointObj

GameObject Passer.InteractionPointer.focusPointObj
inherited

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.

◆ objectInFocus

GameObject Passer.InteractionPointer.objectInFocus
inherited

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.

◆ focusDistance

float Passer.InteractionPointer.focusDistance
inherited

Distance to the objectInFocus.

This is float.infintiy when no object is in focus

◆ maxDistance

float Passer.InteractionPointer.maxDistance = 10
inherited

The maximum length of the curve in units(meters)

This value is used for Straight, SphereCast and Bezier RayTypes

◆ resolution

float Passer.InteractionPointer.resolution = 0.2F
inherited

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

◆ speed

float Passer.InteractionPointer.speed = 3
inherited

The horizontal speed for a gravity curve.

A higher speed will reach further positions.

◆ focusEvent

GameObjectEventHandlers Passer.InteractionPointer.focusEvent
inherited
Initial value:
= new GameObjectEventHandlers() {
label = "Focus Event",
tooltip =
"Call functions using the current focus\n" +
"Parameter: the Object in Focus"
}

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.

◆ focusPointEvent

Vector3EventList Passer.InteractionPointer.focusPointEvent
inherited
Initial value:
= new Vector3EventList() {
label = "Focus Point Event",
tooltip =
"Call functions using the current focus point\n" +
"Parameter: the position of the focus point"
}

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.

◆ clickEvent

GameObjectEventHandlers Passer.InteractionPointer.clickEvent
inherited
Initial value:
= new GameObjectEventHandlers() {
label = "Click Event",
tooltip =
"Call functions using the clicking status\n" +
"Parameter: the Object in Focus when clicking"
}

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.

◆ activeEvent

BoolEvent Passer.InteractionPointer.activeEvent = new BoolEvent()
inherited

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.


The documentation for this class was generated from the following file: