LinePointer shows overshooted after teleport
Overview
The straight LinePointer does overshoot for one frame when reappearing after the teleport arch hides
Expected Behavior
LinePointer is correct
Actual Behavior
LinePointer overshoots
Steps to reproduce
- show the teleport arch
- move the controller a little
- stop teleport
notice how the overshoot reliably lies in extended direction of the controller movement
Unity Editor Version
2018.3.7f1
Mixed Reality Toolkit Release Version
mrtk_development
Could please we get some screenshots to compare the differences?
Sure, here you go:
- shows the initiation of the Teleport (notice the cup is in view)
- shows the release of the teleport a little to the left of the initiating position (cup not visible anymore) The straight beam is clearly off, as if the whole controller motion was extrapolated in that direction. Start position, endposition and therefore the angle of the beam relative to the controller orientation all look like that
- is the frame after that where the controller is totally fine again.
I guess it's a race condition of visibility and positioning in Update or something. Funny though, that the beam is updated to a position not encountered before.
The beam always appears in an extended position of the movement of the controller.

@StephenHodgson this problem does not happen when BaseMixedRealityLineDataProvider is configured to use the transform provided. The default case is using local matrix, which is set too late and wrong for some reason. Investigating further
Ok I think I know what's happening. The matrix is Updated in OnEnable, Update and OnValidate. The Motion Controller is moved during Update of the MixedRealityToolkit. This means we have a race condition here. The controller could be repositioned after the matrix has been updated. Since the LineRenderer updates after the two and uses the matrix it's an overshooted version.
So currenty the thing is the following: The Controller, it's matrix and the LineRenderer all had independent Updates, hence race conditions (I fixed the LineRenderer to update in LateUpdate). Ordering Controller and matrix update is the currently left task here.
I suspect that for this to be bullet-proof the matrix will need to be refreshed during Update AND during LateUpdate, and script execution time will have to be set to take place very early.
Great investigation @Alexees.
@Railboy I disagree. The matrix should be updated once after the motion controller has moved during the frame. The movement is initially realised by the MixedRealityToolkit and it's services (not sure which one right now). I think positioning and matrix saving should be done in one go. The matrix is currently saved in OnValidate, Update and OnEnable, which already looks kind of dumb 😛
@StephenHodgson @Railboy I have the situation layed out and need a hint how to solve it:
- MixedRealityInputSystem Update: updates pointers and motion controller visuals via
class ControllerPoseSynchronizer : InputSystemGlobalListener - BaseMixedRealityLineRenderer LateUpdate: updates the LineRenderer based on a BaseMixedRealityLineDataProvider
- BaseMixedRealityLineDataProvider Update: updates its internal matrix
to resolve the Update issue between controller Position and DataProvider I wanted to derive the DataProvider from InputSystemGlobalListener as well, so it would get updated the same as the visualizers and pointers. Unfortunately the InputSystemGlobalListener in is MRTK.Services namespace and LineRenderers and DataProviders are directly part of the MRTK namespace, hence wrong dependency direction. This would solve the problem the easiest.
Since all relevant components are on the same gameobject another solution could be to introduce a cross reference from BaseMixedRealityLineDataProvider to BaseControllerPointer, to get an update whenever it updates.
What do you think?
Closing myself as #3612 is also closed and it doesn't look like this problem is still there