# GvrLaserVisual Class Reference

# GvrLaserVisual

Visualizes a laser and a reticle using a LineRenderer and a Quad.

## Summary

Provides functions for settings the end point of the laser, and clamps the laser and reticle based on max distances.

### Inheritance

Inherits from: MonoBehaviour, [IGvrArmModelReceiver](https://developers.google.com/vr/reference/unity/interface/IGvrArmModelReceiver)

| ### Public attributes ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1afba6250cf3b95e63523b29f4c5c61d47 = 0.0f` | `float` Begin shrinking the laser when the angle between `transform.forward` and the reticle is greater than this value. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a575161209b7f8d22b31472e20c5e32d4` | `Transform` The controller visual's transform. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a818591482210a7f3954c1374c9612978 = 2.0f` | `float` Finish shrinking the laser when the angle between `transform.forward` and the reticle is greater than this value. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a3c062ea4f9685ab2b11614cfc8a3fd8b = new Color(1.0f, 1.0f, 1.0f, 0.25f)` | `Color` Color of the laser pointer including alpha transparency. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a8ad5cc60ecae7f2db27b842ac8736161 = new Color(1.0f, 1.0f, 1.0f, 0.0f)` | `Color` Color of the laser pointer including alpha transparency. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a23e629037d3af6d41f6a08d74d01e21e = 20.0f` | `float` The rate that the current position moves towards the target position. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a50fe1e5a739f204af2d765d3e5781a09 = 1.0f` | `float` The threashold at which position change becomes immediate. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a7be3ae8ff2c231fb42ca0ea47f0fda03 = 1.0f` | `float` Maximum distance of the laser (meters). |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a1a99ac100165633eca70c18be4c80f10` | `https://developers.google.com/vr/reference/unity/class/GvrControllerReticleVisual#classGvrControllerReticleVisual` Used to position the reticle at the current position. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1aab7225cbeac669fec654b403bdd2ecff = true` | `bool` This is primarily used for Hybrid Raycast mode (details in * [GvrBasePointer](https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer) *) to prevent mismatches between the laser and the reticle when the "camera" component of the ray is used. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1ab68b9a440836e021ee7745a3499bde80 = 0.2f` | `float` Amount to shrink the laser when it is fully shrunk. |

| ### Protected attributes ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a5cab0753147ab71091dce784e155295e` | `float` Current distance to the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1af1ba85076c7d8fbdf1d7223f413f9e1c` | `Vector3` Current local position of the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1ae5490aebe319040682b0ef3bb48391a8` | `Quaternion` Current local rotation of the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a321c9fe865541f2bcc486e013f97a926` | `Vector3` Current world position of the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a8a476e9d9534b5f8fc61a9841b9920fe` | `float` Ratio to shrink the visual by. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a5b8f0c6ea96bfcb9892bc404a8d66a8e` | `float` Distance to the target object. |

| ### Properties ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a8c958e6608820f6652696ac1ac38fc89` | `https://developers.google.com/vr/reference/unity/class/GvrBaseArmModel#classGvrBaseArmModel` Gets or sets the arm model used to control the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1ac90b3dfc1d9582da93c9d58db61219b4` | `float` Gets the current distance to the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1adc12c2213d19639866ae0f9ed3fda196` | `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a4173083274666a6871b60d7624bf34c4` Gets or sets the function to use for determining the point at a distance. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a264b6c3e5cc402c73d410d9246c5421f` | `LineRenderer` Gets a reference to the laser's line renderer. |

| ### Public functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a4173083274666a6871b60d7624bf34c4(float distance)` | `delegate Vector3` Optional delegate for customizing how the currentPosition is calculated based on the distance. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a07e6d5c6f3f7308f34d247be153d260d(float distance, bool immediate)` | `virtual void` Set the distance of the laser. |

| ### Protected functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a206c9f73207c966c2b33c92a4619a460()` | `virtual float` Gets the speed of the moving pointer visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a15aeb4a5b1783074e9ea79243a13d4ab()` | `virtual void` Updates the rotation of the controller based on the current local rotation. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1aac09aa376b082e6b7a9a6e90ca7e6def()` | `virtual void` Updates the current position of the visual. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a36a091c3375213bc270f0376bd5cf5da()` | `virtual void` Updates the alpha of the laser beam. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1a11cda8e6afc5bf3c112f22cc97a09676()` | `virtual void` Updates the endpoint of the laser based on max distance. |
| `https://developers.google.com/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual_1ac2ff80bd03c5f901d2df5fe40ce8a4a7()` | `virtual void` Updates the position of the reticle to the current position. |

## Public attributes

### beginShrinkAngleDegrees

```c#
float beginShrinkAngleDegrees = 0.0f
```
Begin shrinking the laser when the angle between `transform.forward` and the reticle is greater than this value.

### controller

```c#
Transform controller
```
The controller visual's transform.

The end point of the visual will not necessarily be along the forward direction of the laser. This is particularly true in both Camera and Hybrid Raycast Modes. In that case, both the laser and the controller are rotated to face the end point. This reference is used to control the rotation of the controller.

### endShrinkAngleDegrees

```c#
float endShrinkAngleDegrees = 2.0f
```
Finish shrinking the laser when the angle between `transform.forward` and the reticle is greater than this value.

### laserColor

```c#
Color laserColor = new Color(1.0f, 1.0f, 1.0f, 0.25f)
```
Color of the laser pointer including alpha transparency.

### laserColorEnd

```c#
Color laserColorEnd = new Color(1.0f, 1.0f, 1.0f, 0.0f)
```
Color of the laser pointer including alpha transparency.

### lerpSpeed

```c#
float lerpSpeed = 20.0f
```
The rate that the current position moves towards the target position.

### lerpThreshold

```c#
float lerpThreshold = 1.0f
```
The threashold at which position change becomes immediate.

If the targetPosition is greater than this threshold, then the position changes immediately instead of lerping.

### maxLaserDistance

```c#
float maxLaserDistance = 1.0f
```
Maximum distance of the laser (meters).

### reticle

```c#
GvrControllerReticleVisual reticle
```
Used to position the reticle at the current position.

### shrinkLaser

```c#
bool shrinkLaser = true
```
This is primarily used for Hybrid Raycast mode (details in * [GvrBasePointer](https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer) *) to prevent mismatches between the laser and the reticle when the "camera" component of the ray is used.

### shrunkScale

```c#
float shrunkScale = 0.2f
```
Amount to shrink the laser when it is fully shrunk.

## Protected attributes

### currentDistance

```c#
float currentDistance
```
Current distance to the visual.

### currentLocalPosition

```c#
Vector3 currentLocalPosition
```
Current local position of the visual.

### currentLocalRotation

```c#
Quaternion currentLocalRotation
```
Current local rotation of the visual.

### currentPosition

```c#
Vector3 currentPosition
```
Current world position of the visual.

### shrinkRatio

```c#
float shrinkRatio
```
Ratio to shrink the visual by.

### targetDistance

```c#
float targetDistance
```
Distance to the target object.

## Properties

### ArmModel

```c#
GvrBaseArmModel ArmModel
```
Gets or sets the arm model used to control the visual.

The arm model used to control the visual.

### CurrentDistance

```c#
float CurrentDistance
```
Gets the current distance to the visual.

The current distance to the visual.

### GetPointForDistanceFunction

```c#
GetPointForDistanceDelegate GetPointForDistanceFunction
```
Gets or sets the function to use for determining the point at a distance.

The function to use for determining the point at a distance.

### Laser

```c#
LineRenderer Laser
```
Gets a reference to the laser's line renderer.

The laser's line renderer.

## Public functions

### GetPointForDistanceDelegate

```c#
delegate Vector3 GetPointForDistanceDelegate(
  float distance
)
```
Optional delegate for customizing how the currentPosition is calculated based on the distance.

If not set, the `currentPosition` is determined based on the distance multiplied by the forward direction of the transform added to the position of the transform.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `distance` | The distance to use in calculating the `currentPosition`. | |
| **Returns** | Default: The distance mutliplied by the forwrad direction of the transform added to the position of the transform. Overridden: An implementation for calculating `currentPosition` from distance. |

### SetDistance

```c#
virtual void SetDistance(
  float distance,
  bool immediate
)
```
Set the distance of the laser.

Clamps the distance of the laser and reticle.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `distance` | Target distance from the pointer to draw the visual at. | | `immediate` | If `true`, the distance is changed immediately. Otherwise, it will lerp. | |

## Protected functions

### GetSpeed

```c#
virtual float GetSpeed()
```
Gets the speed of the moving pointer visual.

<br />

| Details ||
|---|---|
| **Returns** | The lerp speed of the moving pointer visual. |

### UpdateControllerOrientation

```c#
virtual void UpdateControllerOrientation()
```
Updates the rotation of the controller based on the current local rotation.

### UpdateCurrentPosition

```c#
virtual void UpdateCurrentPosition()
```
Updates the current position of the visual.

### UpdateLaserAlpha

```c#
virtual void UpdateLaserAlpha()
```
Updates the alpha of the laser beam.

### UpdateLaserEndPoint

```c#
virtual void UpdateLaserEndPoint()
```
Updates the endpoint of the laser based on max distance.

### UpdateReticlePosition

```c#
virtual void UpdateReticlePosition()
```
Updates the position of the reticle to the current position.