Tanoda
RestArea.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class RestArea : MonoBehaviour
6{
7 private bool usePhysics = true;
8 private void OnCollisionEnter(Collision collision)
9 {
10 if (SavedUser.instance.isEditor)
11 return;
12#if !UNITY_WEBGL
13 var tcd = collision.gameObject.GetComponentInParent<ThrowableCanDisable>();
14 if (tcd && tcd.IsAttachedToHand())
15 {
16 tcd.ForceDrop();
17 if (usePhysics)
18 {
19 try
20 {
21 collision.gameObject.GetComponentInParent<Rigidbody>().isKinematic = false;
22 collision.gameObject.GetComponentInParent<Rigidbody>().useGravity = true;
23 }
24 catch (System.Exception)
25 {
26 // ignored
27 }
28 }
29 }
30#endif
31
32 }
33}