Created
January 12, 2019 11:26
-
-
Save scottyob/776ae1b6b2dc993bde1418383c478aeb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class VRTK_CursorMouse : VRTK.VRTK_StraightPointerRenderer { | |
public Camera camera; | |
public Transform hand; | |
protected override Transform GetOrigin(bool smoothed = true) { | |
return camera.transform; | |
} | |
protected override float CastRayForward() | |
{ | |
RaycastHit hit; | |
Ray pointerRaycast = camera.ScreenPointToRay(Input.mousePosition); | |
Transform origin = GetOrigin(); | |
RaycastHit pointerCollidedWith; | |
bool rayHit = VRTK.VRTK_CustomRaycast.Raycast(customRaycast, pointerRaycast, out pointerCollidedWith, defaultIgnoreLayer, maximumLength); | |
if (pointerCollidedWith.collider) | |
{ | |
hand.LookAt(pointerCollidedWith.point); | |
} | |
else | |
{ | |
hand.localRotation = Quaternion.identity; | |
} | |
CheckRayMiss(rayHit, pointerCollidedWith); | |
CheckRayHit(rayHit, pointerCollidedWith); | |
float actualLength = maximumLength; | |
if (rayHit && pointerCollidedWith.distance < maximumLength) | |
{ | |
actualLength = pointerCollidedWith.distance; | |
} | |
return OverrideBeamLength(actualLength); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment