Forum Discussion
kevakic
1 year 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 I achieve this through hand tracking using hand grab. Any and all help is much appreciated(I don'twanttousexr interaction toolkit due to other factors).
Thank you 😊
4 Replies
Replies have been turned off for this discussion
- Big_FlexMeta Employee
Hi kevakic, if you have v62 of Interaction SDK, then you can use QuickActions to add a grab interactable to each part of your ladder that should be grabbable with hands or controllers. If you want to adjust how the hand grabs the ladder, you can use the Create Hand Grab Pose tutorial for either Mac or PC.
I write the developer docs for the Interaction SDK, so please let me know if you have any additional questions or need me to clarify 🙂
- kevakicHonored 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?
- SirLuicelotExplorer
Hi, excuse me. Did you get it to work? I'm struggling with the same problem
- kevakicHonored Guest
I found a workaround to implement climbing with hands. Since the previous method only worked with controllers and not hands, I have used an alternative solution. I check if both hands are grabbed and, only then, use Vector3.MoveTowards to move the player in the y-direction. However, this movement does not perfectly mimic the natural motion of climbing a ladder and serves only as a temporary solution.
if anybody has better solution their help is appreciated.
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
- 2 months ago