VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
void AVR.Phys.AVR_Hand.FixedUpdate ( )
inlineprivate

Definition at line 149 of file AVR_Hand.cs.

149  {
150 #if AVR_NET
151  if (IsOnline && !IsOwner) return;
152 #endif
153  if (fake_parent==null && physical_hand) {
154  //TODO: Make HandVisualTransform() follow ControllerTransform() as if it was a grabbed object
155  //pos
156  Vector3 pDelta = (HandControllerTransform().position - HandVisualTransform().position);
157  Vector3 vel = pDelta / Time.fixedDeltaTime;
158 
159  physical_hand_rb.velocity = vel;
160 
161  //ang
162  Quaternion rotationDelta = HandControllerTransform().rotation * Quaternion.Inverse(HandVisualTransform().rotation);
163 
164  rotationDelta.ToAngleAxis(out float angle, out Vector3 axis);
165  while (angle > 180) angle -= 360; // Prevent object from doing sudden >180° turns instead of negative <180° ones
166 
167  physical_hand_rb.maxAngularVelocity = 99999.0f;
168 
169  Vector3 angvel = (angle * axis * Mathf.Deg2Rad) / Time.fixedDeltaTime;
170  if (!float.IsNaN(angvel.z)) physical_hand_rb.angularVelocity = angvel;
171  }
172  else {
173 
174  }
175  }
Transform HandControllerTransform()
Definition: AVR_Hand.cs:37
Rigidbody physical_hand_rb
Definition: AVR_Hand.cs:27
Transform HandVisualTransform()
Definition: AVR_Hand.cs:32
Transform fake_parent
Definition: AVR_Hand.cs:20
bool physical_hand
Definition: AVR_Hand.cs:26