File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
Packages/webxr-interactions Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
## [ Unreleased]
8
8
### Added
9
9
- Support for AR headsets in SceneHitTest.
10
+ - Velocity for interactables when dropped.
10
11
11
12
## [ 0.13.0] - 2021-10-18
12
13
### Changed
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ public class ControllerInteraction : MonoBehaviour
33
33
private Dictionary < int , Transform > handJoints = new Dictionary < int , Transform > ( ) ;
34
34
public GameObject inputProfileHandModelParent ;
35
35
36
+ private Vector3 currentVelocity ;
37
+ private Vector3 previousPos ;
38
+
36
39
#if WEBXR_INPUT_PROFILES
37
40
private InputProfileLoader inputProfileLoader ;
38
41
private InputProfileModel inputProfileModel ;
@@ -125,6 +128,9 @@ private void Update()
125
128
Drop ( ) ;
126
129
}
127
130
131
+ currentVelocity = ( transform . position - previousPos ) / Time . deltaTime ;
132
+ previousPos = transform . position ;
133
+
128
134
#if WEBXR_INPUT_PROFILES
129
135
if ( loadedModel && useInputProfile )
130
136
{
@@ -512,7 +518,7 @@ public void Drop()
512
518
{
513
519
if ( ! currentRigidBody )
514
520
return ;
515
-
521
+ currentRigidBody . velocity = currentVelocity ;
516
522
attachJoint . connectedBody = null ;
517
523
currentRigidBody = null ;
518
524
}
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 m_currentVelocity ;
13
+ private Vector3 m_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 = m_currentVelocity ;
30
33
m_currentCamera = null ;
31
34
}
32
35
@@ -37,6 +40,8 @@ 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
+ m_currentVelocity = ( transform . position - m_previousPos ) / Time . deltaTime ;
44
+ m_previousPos = transform . position ;
40
45
}
41
46
}
42
47
You can’t perform that action at this time.
0 commit comments