first commit
This commit is contained in:
32
Assets/Scripts/DrawerContent.cs
Normal file
32
Assets/Scripts/DrawerContent.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DrawerContent : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Drawer _drawer;
|
||||
|
||||
private Rigidbody _rb;
|
||||
private Collider _collider;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_rb = GetComponent<Rigidbody>();
|
||||
_collider = GetComponent<Collider>();
|
||||
SetPhysics(false);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_drawer.IsOpen)
|
||||
SetPhysics(true);
|
||||
else
|
||||
SetPhysics(false);
|
||||
}
|
||||
|
||||
void SetPhysics(bool active)
|
||||
{
|
||||
_rb.isKinematic = !active;
|
||||
_collider.enabled = active;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user