Mixedrealitytoolkit-unity: Moving objects in HandDraggable.cs

Created on 27 Jun 2017  路  2Comments  路  Source: microsoft/MixedRealityToolkit-Unity

In line 225 and 227, the position and the rotation of the targeted object are manipulated directly. However, this causes some ugly glitches if you e. g. try to push your dragged object against a static, kinematic object. The problem seems to be this issue here.

So instead of

// Apply Final Position
HostTransform.position = Vector3.Lerp(HostTransform.position, draggingPosition + mainCamera.transform.TransformDirection(objRefGrabPoint), PositionLerpSpeed);

I suggest using some thing like

// Apply Final Position
Vector3 movePosition = Vector3.Lerp(HostTransform.position, draggingPosition + mainCamera.transform.TransformDirection(objRefGrabPoint), PositionLerpSpeed);
HostTransform.gameObject.GetComponent<Rigidbody>().MovePosition(movePosition);

Or are there any other reasons (like performance) that made you choose to manipulate the transform directly?

Most helpful comment

I think its probably just that there are no requirements that the object you are moving has a rigid body component.

All 2 comments

I think its probably just that there are no requirements that the object you are moving has a rigid body component.

@thebanjomatic is correct.

Was this page helpful?
0 / 5 - 0 ratings