File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Packages/webxr-interactions/Runtime/Scripts Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ public class MouseDragObject : MonoBehaviour
9
9
private Rigidbody m_rigidbody ;
10
10
private Vector3 m_screenPoint ;
11
11
private Vector3 m_offset ;
12
+ private Vector3 currentVelocity ;
13
+ private Vector3 previousPos ;
12
14
13
15
void Awake ( )
14
16
{
@@ -27,6 +29,7 @@ void OnMouseDown()
27
29
28
30
void OnMouseUp ( )
29
31
{
32
+ m_rigidbody . velocity = currentVelocity ;
30
33
m_currentCamera = null ;
31
34
}
32
35
@@ -37,6 +40,9 @@ void FixedUpdate()
37
40
Vector3 currentScreenPoint = GetMousePosWithScreenZ ( m_screenPoint . z ) ;
38
41
m_rigidbody . velocity = Vector3 . zero ;
39
42
m_rigidbody . MovePosition ( m_currentCamera . ScreenToWorldPoint ( currentScreenPoint ) + m_offset ) ;
43
+
44
+ currentVelocity = ( transform . position - previousPos ) / Time . deltaTime ;
45
+ previousPos = transform . position ;
40
46
}
41
47
}
42
48
You can’t perform that action at this time.
0 commit comments