-
Notifications
You must be signed in to change notification settings - Fork 0
Physical Hands
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.
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.
Change the friction type to one directional.
Change the solver to Temporal Gauss.
Finally, in the time settings, change the time step from 0.02 seconds to 0.01 seconds.
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.
On each of the hand presences, add a rigid body and new hand presences physics script.
In the newly created script, change update to fixedUpdate.
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.
On every fixed update, set the velocity of the rigid body to the distance to the target over the fixed delta time.
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.
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.
In physics settings, uncheck both for player and self-collision for left and right hand layers.
In order to fix the rotation as well, we will need to update the angular velocity of the object as follows.
We now should be able to move our hands around and have them interact with static colliders.