Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Interactable : MonoBehaviour
  6. {
  7.     private VRHand activeHand = null;
  8.     private GameObject stuckSurface = null;
  9.     private Vector3 stuckPosition = Vector3.zero;
  10.     [SerializeField]
  11.     private float mass;
  12.     [SerializeField]
  13.     private Socket socket;
  14.     private void OnEnable()
  15.     {
  16.         ActionCentre.Instance().SpawnPlayerCompleted += SetPlayerCollisionIgnore;
  17.     }
  18.  
  19.     private void OnDisable()
  20.     {
  21.         ActionCentre.Instance().SpawnPlayerCompleted -= SetPlayerCollisionIgnore;
  22.     }
  23.     // Start is called before the first frame update
  24.     void Start()
  25.     {
  26.         gameObject.tag = DefaultValues.NAME_TAG_INTERACTABLE;
  27.         InitialiseRigidbody();
  28.     }
  29.  
  30.     private void InitialiseRigidbody()
  31.     {
  32.         Rigidbody rigidbody = GetComponent<Rigidbody>();
  33.         if (rigidbody != null)
  34.         {
  35.             Debug.Log("Destroy existing RGBD on " + gameObject.name);
  36.             Destroy(rigidbody);
  37.         }
  38.         Debug.Log("Adding RGBD to " + gameObject.name);
  39.         rigidbody = gameObject.AddComponent<Rigidbody>();
  40.         rigidbody.mass = mass;
  41.     }
  42.  
  43.     // Update is called once per frame
  44.     void Update()
  45.     {
  46.    
  47.     }
  48.  
  49.     public VRHand ActiveHand
  50.     {
  51.         get { return activeHand; }
  52.         set { activeHand = value; }
  53.     }
  54.  
  55.     private void SetPlayerCollisionIgnore()
  56.     {
  57.         Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), GameObject.FindGameObjectWithTag(DefaultValues.NAME_TAG_PLAYER).GetComponent<CharacterController>());
  58.         //Debug.Log("Ignored Collisions between " + gameObject.name + " and " + GameObject.FindGameObjectWithTag(DefaultValues.NAME_TAG_PLAYER).name);
  59.     }
  60.  
  61.     public Socket Socket
  62.     {
  63.         get { return socket; }
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement