Restricting Rotation Of an Object in VR
Hello, İm making a jenga game for VR but i have some problems with unity physics .
if the controller is close enough and i press trigger button, jenga block gets child of controller (is grabbed) and it gets unstopable .The Drawing on the left side is what is currenlty happening .Vive Controller is a real object and cant be stopped in VR (i guess).
When you pull a jenga block in real life, You cant rotate it too much unless you apply a certain amount of force but in VR its not the same. Once you Grabbed the Block you can do crayz movement without any restrictions.
Is there a way to limit the rotation of the jenga block im holding ? Like if its grabbed and is inside the Trigger Collider its wont rotate more than 15 degress for example. Or any better solutions ?
Note:
Addaptive Force is Enabled in physics setting
I use break force (grabbed object drops if x amount of force is applied) to avoid grabbed objects from clipping the ground but its game breaking for this problem.
Sciprts:
Grab Script:
{ using UnityEngine;
/// <summary>
/// The Fixed Joint Grab Attach script is used to create a simple Fixed Joint connection between the object and the grabbing object.
/// </summary>
/// <example>
/// `VRTK/Examples/005_Controller_BasicObjectGrabbing` demonstrates this grab attach mechanic all of the grabbable objects in the scene.
/// </example>
public class VRTK_FixedJointGrabAttach : VRTK_BaseJointGrabAttach
{
[Tooltip("Maximum force the joint can withstand before breaking. Infinity means unbreakable.")]
public float breakForce = 1500f;
protected override void CreateJoint(GameObject obj)
{
givenJoint = obj.AddComponent<FixedJoint>();
givenJoint.breakForce = (grabbedObjectScript.IsDroppable() ? breakForce : Mathf.Infinity);
base.CreateJoint(obj);
}
}