24 private Vector3 _lastSolvedCoMPosition = Vector3.zero;
25 protected AnimationCurve
_strengthByDistance =
new AnimationCurve(
new Keyframe(0.0f, 1.0f, 0.0f, 0.0f),
26 new Keyframe(0.02f, 0.3f, 0.0f, 0.0f));
28 public void MoveTo(Vector3 solvedPosition, Quaternion solvedRotation,
30 Vector3 solvedCenterOfMass = solvedRotation * intObj.
rigidbody.centerOfMass + solvedPosition;
33 Vector3 targetVelocity = PhysicsUtility.ToLinearVelocity(currCenterOfMass, solvedCenterOfMass, Time.fixedDeltaTime);
35 Vector3 targetAngularVelocity = PhysicsUtility.ToAngularVelocity(intObj.
rigidbody.rotation, solvedRotation, Time.fixedDeltaTime);
39 float targetSpeedSqrd = targetVelocity.sqrMagnitude;
40 if (targetSpeedSqrd > maxScaledVelocity * maxScaledVelocity) {
41 float targetPercent = maxScaledVelocity / Mathf.Sqrt(targetSpeedSqrd);
42 targetVelocity *= targetPercent;
43 targetAngularVelocity *= targetPercent;
46 float followStrength = 1F;
48 float remainingDistanceLastFrame = Vector3.Distance(_lastSolvedCoMPosition, currCenterOfMass);
52 Vector3 lerpedVelocity = Vector3.Lerp(intObj.
rigidbody.velocity, targetVelocity, followStrength);
53 Vector3 lerpedAngularVelocity = Vector3.Lerp(intObj.
rigidbody.angularVelocity, targetAngularVelocity, followStrength);
55 intObj.
rigidbody.velocity = lerpedVelocity;
56 intObj.
rigidbody.angularVelocity = lerpedAngularVelocity;
58 _lastSolvedCoMPosition = solvedCenterOfMass;
InteractionBehaviours are components that enable GameObjects to interact with interaction controllers...
Pose? latestScheduledGraspPose
Nonkinematic grasping motion applies clamped velocities to Interaction Behaviours when they are grasp...
Rigidbody rigidbody
The Rigidbody associated with this interaction object.
InteractionManager manager
float SimulationScale
A scale that can be used to appropriately transform distances that otherwise expect one Unity unit to...
This implementation of IGraspedMovementHandler moves an interaction object to its target position and...
void MoveTo(Vector3 solvedPosition, Quaternion solvedRotation, InteractionBehaviour intObj, bool justGrasped)
Called by an interaction object when its grasped pose handler has determined a target pose; this meth...
AnimationCurve _strengthByDistance
An IGraspedMovementHandler takes in a target position and rotation (a "pose", usually provided by an ...
A position and rotation. You can multiply two poses; this acts like Matrix4x4 multiplication,...