Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Interactable : MonoBehaviour
- {
- private VRHand activeHand = null;
- private GameObject stuckSurface = null;
- private Vector3 stuckPosition = Vector3.zero;
- [SerializeField]
- private float mass;
- [SerializeField]
- private Socket socket;
- private void OnEnable()
- {
- ActionCentre.Instance().SpawnPlayerCompleted += SetPlayerCollisionIgnore;
- }
- private void OnDisable()
- {
- ActionCentre.Instance().SpawnPlayerCompleted -= SetPlayerCollisionIgnore;
- }
- // Start is called before the first frame update
- void Start()
- {
- gameObject.tag = DefaultValues.NAME_TAG_INTERACTABLE;
- InitialiseRigidbody();
- }
- private void InitialiseRigidbody()
- {
- Rigidbody rigidbody = GetComponent<Rigidbody>();
- if (rigidbody != null)
- {
- Debug.Log("Destroy existing RGBD on " + gameObject.name);
- Destroy(rigidbody);
- }
- Debug.Log("Adding RGBD to " + gameObject.name);
- rigidbody = gameObject.AddComponent<Rigidbody>();
- rigidbody.mass = mass;
- }
- // Update is called once per frame
- void Update()
- {
- }
- public VRHand ActiveHand
- {
- get { return activeHand; }
- set { activeHand = value; }
- }
- private void SetPlayerCollisionIgnore()
- {
- Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), GameObject.FindGameObjectWithTag(DefaultValues.NAME_TAG_PLAYER).GetComponent<CharacterController>());
- //Debug.Log("Ignored Collisions between " + gameObject.name + " and " + GameObject.FindGameObjectWithTag(DefaultValues.NAME_TAG_PLAYER).name);
- }
- public Socket Socket
- {
- get { return socket; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement