Forum Discussion
kevakic
2 years agoHonored Guest
VR climbing system with hand tracking
Hi I am trying to implement a ladder system where the player can climb, using hand tracking. Note that im using oculus interaction sdk. I am able to achieve this by using controllers, but how can...
kevakic
2 years agoHonored Guest
I tried using these scripts to make a climbing system with controllers, but when I switched to hand tracking, I had trouble with the OVR grabbable. When I grab an object and move, the player's movement doesn't behave as expected.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Oculus.Interaction;
public class Hand : MonoBehaviour
{
public Climber climber = null;
public OVRInput.Controller controller = OVRInput.Controller.None;
public Vector3 Delta { private set; get; } = Vector3.zero;
private Vector3 lastPosition = Vector3.zero;
private GameObject currentPoint = null;
private List<GameObject> contactPoints = new List<GameObject>();
private MeshRenderer meshRenderer = null;
private void Start()
{
lastPosition = transform.position;
}
private void Update()
{
if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, controller))
GrabPoint();
if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger, controller))
Release Point();
}
private void Fixed Update()
{
lastPosition = transform.position;
}
private void LateUpdate()
{
Delta = lastPosition - transform.position;
}
public void GrabPoint()
{
currentPoint = Utility.GetNearest(transform.position, contactPoints);
if (currentPoint)
{
climber.SetHand(this);
//meshRenderer. Enabled = false;
}
}
public void Release Point()
{
if (currentPoint)
{
climber.ClearHand();
//meshRenderer.enabled = true;
}
currentPoint = null;
}
private void OnTriggerEnter(Collider other)
{
Add Point(other.gameObject);
}
private void Add Point(GameObject newObject)
{
if (newObject.CompareTag("ClimbPoint"))
contactPoints.Add(newObject);
}
private void OnTriggerExit(Collider other)
{
RemovePoint(other.gameObject);
}
private void RemovePoint(GameObject newObject)
{
if (newObject.CompareTag("ClimbPoint"))
contactPoints.Remove(newObject);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Climber : MonoBehaviour
{
public float gravity = 45.0f;
public float sensitivity = 45.0f;
private Hand currentHand = null;
private CharacterController controller;
private void Awake()
{
controller = GetComponent<CharacterController>();
}
private void Update()
{
CalculateMovement();
}
private void CalculateMovement()
{
Vector3 movement = Vector3.zero;
if (currentHand)
movement += currentHand.Delta * sensitivity;
if (movement == Vector3.zero)
movement.y -= gravity * Time.deltaTime;
controller.Move(movement * Time.deltaTime);
}
public void SetHand(Hand hand)
{
if (currentHand)
currentHand.ReleasePoint();
currentHand = hand;
}
public void ClearHand()
{
currentHand = null
}
}
I'm using the Oculus Integration version 57.0.1, specifically for hand tracking without controllers. I want to implement climbing system for these hands.
Could anyone provide assistance with this issue?
SirLuicelot
2 years agoExplorer
Hi, excuse me. Did you get it to work? I'm struggling with the same problem
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 2 years ago
- 6 months ago