forked from MicroGSD/RoadArchitect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGSDRigidBody.cs
50 lines (47 loc) · 1.2 KB
/
GSDRigidBody.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using UnityEngine;
public class GSDRigidBody : MonoBehaviour{
public float MinCollVelocity = 2f;
// bool bIsForcedSleeping = false;
Rigidbody RB;
// bool bIgnoreRB = false;
void Awake(){
RB = transform.GetComponent<Rigidbody>();
if (RB != null) {
DestroyImmediate(RB);
}
}
// void OnCollisionEnter(Collision collision) {
// if(bIgnoreRB || !bIsForcedSleeping){ return; }
// Debug.Log (collision.relativeVelocity.magnitude);
// if(RB != null){
// if(collision.relativeVelocity.magnitude <= MinCollVelocity){
// RB.Sleep();
// }else{
// //RB.isKinematic = false;
// bIsForcedSleeping = false;
// //RB.AddForce(collision.relativeVelocity*collision.relativeVelocity.magnitude*(RB.mass*0.3f));
// }
// }
// }
//
// void OnCollisionExit(Collision collisionInfo) {
// if(bIgnoreRB || !bIsForcedSleeping){ return; }
// if(bIsForcedSleeping && RB != null){
// RB.Sleep();
// }
// }
//
// float TimerMax = 0.1f;
// float TimerNow = 0f;
// void Update(){
// if(bIsForcedSleeping){
// TimerNow += Time.deltaTime;
// if(TimerNow > TimerMax){
// if(RB != null && !RB.IsSleeping()){
// RB.Sleep();
// }
// TimerNow = 0f;
// }
// }
// }
}