Skip to content

Physical Hands

Josef LaFranchise edited this page Oct 16, 2023 · 1 revision

Basic Setup

For physical hands to work, you will need to add colliders and a rigid body to each of your hands. For now, set the rigid body to kinematic.

You will now see that other physics bodies with rigid bodies can now interact with your hands. However, your hands will still pass through static colliders, such as the table or the floor.

Physics Settings

To get more realistic collision results, try changing the settings to the following.

Set default solver iterations to 25, the default solver velocity iterations to 15, and make sure that enable adaptive force is active.

image

Change the friction type to one directional.

image

Change the solver to Temporal Gauss.

image

Finally, in the time settings, change the time step from 0.02 seconds to 0.01 seconds.

image

Adding Proper Static Collisions

In order to have our hands collider with static objects, we will need to move them with velocity, as opposed to having them parented to the controllers.

Therefore, the first step we will take is to unparent the models from the controllers.

image

On each of the hand presences, add a rigid body and new hand presences physics script.

image

In the newly created script, change update to fixedUpdate.

image

Add a public transform field called target and a private rigid body field. Set the rigid body to the game objects rigid body on start.

image

On every fixed update, set the velocity of the rigid body to the distance to the target over the fixed delta time.

image

Now just assign the correct controllers as the targets, set the hands rigid bodies to non-kinematic and the models will be tracked to their position. However, there are still a few things that need to be fixed.

Fixing Collision and Rotation Errors

The first issue you will notice is that the hands are colliding with each other. To address this, we will assign each hand to their own layer as follows.

While we are here, lets also create a Player layer so that our hands do not collide with our character controller collider.

image

In physics settings, uncheck both for player and self-collision for left and right hand layers.

image

In order to fix the rotation as well, we will need to update the angular velocity of the object as follows.

image

We now should be able to move our hands around and have them interact with static colliders.

Clone this wiki locally