How to Make Physics Hands in VR - PART 1 - Unity VR Tutorial

How to Make Physics Hands in VR - PART 1 - Unity VR Tutorial

Valem Tutorials

2 года назад

84,547 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@KommissarKong
@KommissarKong - 03.12.2023 20:45

The Download Link is filled with empty folders so RIP

Ответить
@tompainter7167
@tompainter7167 - 10.11.2023 02:39

I tried this today with a scene I made following your 3 part quest 3 MR Tutorial and the OVRCameraRig hierarchy used there is so different that I couldn’t get it working , I tried to copy this and adapt where I could but utilise didn’t work. Could you add part 4 to the mixed really tutorial where you can pick up and throw the red balls? Or maybe you gave some quick advice? Thanks

Ответить
@danielericcardo9180
@danielericcardo9180 - 25.10.2023 14:18

hi! thanks amazing tutorial, but if I have controller in the project and want to hide or alternate btw hands and controller how can I do?

Ответить
@fashvr9961
@fashvr9961 - 12.10.2023 11:19

Hey valem. is it possible to combine this with two bone ik? i dont want to judt put a rigid body and collider on the target and move the target because the colliders on the hands are more accurate

Ответить
@judahhanes
@judahhanes - 18.09.2023 01:22

this worked so well, thank you. I really like how you put so much time into this.

Ответить
@olivername
@olivername - 14.08.2023 17:38

hi would this work for bows arrows climbing

Ответить
@carp4788
@carp4788 - 19.07.2023 12:23

I have a problem with the hands, when I rotate them, at some point they do a strange rotation to return to the original, what can I do?

Ответить
@TheSateef
@TheSateef - 19.07.2023 00:44

i found a far better and simpler way than the Valem tutorial. simply add collision handlers to the Pusher objects under each hand like this
Code (CSharp):
public class HandCollision : MonoBehaviour
{
[SerializeField] private GameObject _thisHandModel;
public void OnCollisionEnter(Collision collision)
{
if(collision.collider.gameObject.layer != 0)
{
return;
}

if (collision.collider.transform.GetComponent<XRGrabInteractable>())
return;
_thisHandModel.transform.parent = null;
}

public void OnCollisionExit(Collision collision)
{
if (collision.collider.gameObject.layer != 0)
{
return;
}


_thisHandModel.transform.position = transform.parent.position;
_thisHandModel.transform.rotation = transform.parent.rotation;
_thisHandModel.transform.parent = transform.parent;
}
}
then pass the hand model of the hand you are in in the inspector

it simply unparents the model from the controller when it hits a collider (on the default layer) and when it exits, it reparent to the controller, super simple

Ответить
@hunscripter635
@hunscripter635 - 18.07.2023 23:26

Great vid! I used a quest 2, and it worked, HOWEVER!- there is a problem, in the game if I rotate my hands a bit fast, than i will see my hands slooowly rotate to the real place of my hands...

Ответить
@3d-action
@3d-action - 12.06.2023 21:02

HandPresencePhysics script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HandPresencePhysics : MonoBehaviour
{

public Transform target;
private Rigidbody rb;

// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();

}

// Update is called once per frame
void FixedUpdate()
{
rb.velocity = (target.position - transform.position) / Time.fixedDeltaTime;

Quaternion rotationDifference = target.rotation * Quaternion.Inverse(transform.rotation);
rotationDifference.ToAngleAxis(out float angleInDegree, out Vector3 rotationAxis);

Vector3 rotationDifferenceInDegree = angleInDegree * rotationAxis;

rb.angularVelocity = (rotationDifferenceInDegree * Mathf.Deg2Rad / Time.fixedDeltaTime);
}
}

Ответить
@olivername
@olivername - 09.06.2023 22:38

adding the hands in but they pink

Ответить
@RitikAgarwal21
@RitikAgarwal21 - 16.05.2023 15:21

Hi,
For me this is working with controllers only. How can it work with Hands?

Ответить
@NexyDev
@NexyDev - 09.05.2023 04:35

The rotation is still messed up for me, how do i fix this?

Ответить
@ayoadeadeyemi6042
@ayoadeadeyemi6042 - 22.03.2023 12:55

@Valem Tutorials will this be able to work with the oculus hands just like the HPTK video you did?

Ответить
@dedsec1175
@dedsec1175 - 05.03.2023 12:10

i have a problem my hands do not align to the rotation of the controler its 90* off in both directions

Ответить
@greasygrape6270
@greasygrape6270 - 26.02.2023 03:50

hey

Ответить
@lucasillu
@lucasillu - 15.02.2023 00:27

every single game dev tutorial turns into coding

if you wanna make a game, go learn how to code. apparently learning unity is the easiest part.

Ответить
@genofelice6034
@genofelice6034 - 08.02.2023 21:05

Hello: I have been trying to follow your tutorial but using Action Based Controller as opposed to Device Based. All works well with Device based but can't get Physics hands to track using Action based controller. Any thoughts? Thanks

Ответить
@tottallyNot
@tottallyNot - 06.02.2023 21:51

Hi, for anyone having problems with the hand rotating uncontrolled here is a solution:

Quaternion rotationDifference = target.rotation * Quaternion.Inverse(transform.rotation);
rotationDifference.ToAngleAxis(out float angleInDegree, out Vector3 r);

if (float.IsInfinity(r.x))
return;

if (angleInDegree> 180f)
angleInDegree-= 360f;

// Here I drop down to 0.9f times the desired movement,
// since we'd rather undershoot and ease into the correct angle
// than overshoot and oscillate around it in the event of errors.
Vector3 angular = (0.9f * Mathf.Deg2Rad * angleInDegree/ Time.fixedDeltaTime) * r.normalized;

This solved the weird behavior for me, solution is not mine it's from gamedev stackexchange

Ответить
@agentallegator
@agentallegator - 15.01.2023 03:14

my brain is rock idiot this is the first game I ever made it looks shit but it is going to work

Ответить
@wompingdroid
@wompingdroid - 28.12.2022 21:21

I NEED HELP!! My object (currently a sphere not a hand) has its ridged body work properly but it looks like it foes through the block. I dont think that the mesh is binded to the ridged body or something

Ответить
@FoxyPlaysGames11
@FoxyPlaysGames11 - 08.12.2022 01:00

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Handphysics : MonoBehaviour
{

public Transform target;
private Rigidbody rb;

// Start is called before the first frame update
void Start()
{
rb = getcomponent<Rigidbody>();

}

// Update is called once per frame
void FixedUpdate()
rb.velocity = (target.position - Transform.position) / time.fixedDeltatime;
{


}
}

Ответить
@sergioml2000
@sergioml2000 - 07.12.2022 16:53

Very good video, I have done what you say, but my hands keep going through the objects, why?

Ответить
@zillieness
@zillieness - 06.12.2022 03:34

Both of these videos were super helpful and worked for me almost a year later. Thank you, Valem!! If anyone is using a Character Controller (which has a collider) on their XR Origin, you might notice your hands are hitting the invisible collider. I fixed this by putting the XR Origin on its own layer ("Player") and went to Edit > Project Settings > Physics, and under the Layer Collision Matrix, unchecked "Player" from both of the Left and Right Hand Physics.

Ответить
@erikmeurk5902
@erikmeurk5902 - 29.11.2022 21:34

When adding the hands with all the colliders and building the app to the Quest 2 I get a lot of performance issues when interacting with different objects. Do you have any tips on how to improve performance but still have nice physics? Great tutorials btw, I love your content.

Ответить
@aash3529
@aash3529 - 24.11.2022 16:15

HI love all your videos excellent work as always .. I seem to have a problem I've followed everything perfectly but I still seem to have 2 sets of hands when I grip I can still see the old static hands. I did uncheck them but can't seem to remove them?

Ответить
@azghanm
@azghanm - 04.11.2022 18:59

hello, i ahave a problem. you are not explaining in this tutorial which setup of XR you have. i am currently working with the oculus Asset and using a "oculusinteractionsamplerig" and you the XR interaction manager + xr origign, and i am still trying to figure out to apply this. other than that i love how you explain.

Ответить
@crealhiphop5808
@crealhiphop5808 - 27.10.2022 14:52

why does nobody add a point animation to their hands? Is essential in vr no? when you need to press button

Ответить
@user-gt3vn2mi1t
@user-gt3vn2mi1t - 20.10.2022 08:54

Excuse me. Does it work if I use the Action-based XR Controller? Because I did step by step but the hands model did't follow the hands controller.

Ответить
@IDontEvenKnow32
@IDontEvenKnow32 - 10.10.2022 22:20

im having a problem where the vr hands are spinning the wrong way to get to the original position

Ответить
@THE_ONLY_GOD
@THE_ONLY_GOD - 11.09.2022 07:29

Thanks! Proper XR breast fondling here I come!

Ответить
@fernandocgi3874
@fernandocgi3874 - 10.09.2022 22:11

Hey Valem, does the mesh collider works stead of using capsule colliders? ty

Ответить
@iambored9888
@iambored9888 - 07.09.2022 12:12

Bomboclat

Ответить
@iambored9888
@iambored9888 - 07.09.2022 12:11

Valem, this needs to stop. I just found out you now have a fourth series on this topic.

Which one do I follow? Which one is correct? Why do they reference eachother? Why!???!? I just want to make epic hentai VR game.

Ответить
@travisray5179
@travisray5179 - 04.09.2022 22:30

I've had issues with this angular velocity code causing errors that read out as "Input velocity is Vector {NaN, NaN, NaN}". Anyone else had something like that and maybe a solution? It doesn't seem to cause any actual gameplay issues but it is annoying

Ответить
@janisberzins7296
@janisberzins7296 - 16.08.2022 16:12

Is there a way to smooth the rotations of the hand? It's really snappy and jittery.

Ответить
@jimmychen0123
@jimmychen0123 - 13.08.2022 01:16

Hello, does this behaviour happen to anyone: the physics hands were stuck/blocked by objects like walls when teleporting to a different location?

Ответить
@mehblah4205
@mehblah4205 - 12.08.2022 14:01

Hi so is the oculus hands physics package open source? Can I use it in my own, non-oculus Unity XR project? Who made the package?

Ответить
@MaxDolotboy
@MaxDolotboy - 11.08.2022 03:06

Hey, thanks for your tutorial, the collision with non rigidbody object seems to works perfectly fine, the only thing is that my hand are spining like crazy when I set them to non kinematic, even if I made the script, I added the script as a component to them and I correctly set the target. I'm kinda lost, I followed exactly the tutorial.

Ответить
@jimmychen0123
@jimmychen0123 - 10.08.2022 23:33

Huge thanks for making those content!!

Ответить
@Mike-nz1dc
@Mike-nz1dc - 27.07.2022 22:16

can somebody tell me what´s wrong with my code?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HandPresencePhysics : MonoBehaviour
{

public Transform target;
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate()
{
rb.velocity = (target.position - transform.position) / Time.fixedDeltaTime;

Quaternion rotationDifference = target.rotation * Quaternion.Inverse(transform.rotation);
rotationDifference.ToAngleAxis(out float angleInDegree, out Vector3 rotationAxis);

Vector3 rotationDifference = angleInDegree * rotationAxis;

rb.angularVelocity = (rotationDifferenceInDegree * Mathf.Deg2Rad / Time.fixedDeltaTime);
}
}
because unity always says: ''The name 'rotationDifferenceInDegree' does not exist in the current context''
and ''A local variable or function named 'rotationDifference' is already defined in this scope''

Ответить
@coolcat1938
@coolcat1938 - 21.07.2022 13:50

hi can i have some help after i drag the hand with collider to hand pysics animation script its not making the hand with the collider animate

Ответить
@katebiel
@katebiel - 20.07.2022 09:14

Hm but when you walk they are moving weirdly. lagging...

Ответить
@iercan1234
@iercan1234 - 02.07.2022 22:19

i fixed the wrong axis hands with this:
Quaternion postRotation = transform.rotation * Quaternion.Euler(0, 0, -90);
Quaternion rotationDifference = target.rotation * Quaternion.Inverse(postRotation);

Ответить
@iercan1234
@iercan1234 - 02.07.2022 20:19

merci!

Ответить
@hantyumitheconfusedcyb0rg102
@hantyumitheconfusedcyb0rg102 - 13.06.2022 21:13

when using the Hands prefab with Colliders the animations don't work, Animator is not playing an AnimatorController, but in fact it's equal to the prefab without Colliders, and they actually work, dunno

Ответить
@thewalfordbros1210
@thewalfordbros1210 - 25.05.2022 05:35

@Valem Tutorials I copied your video exactly and I am on 2021.3 something but at the end of the video when I pick up a object my hands start rotating a lot. Could you pls help me fix this.

Ответить