59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using Fusion;
|
|
using UnityEngine;
|
|
|
|
namespace BNG
|
|
{
|
|
public class GrabManager : GrabbableEvents
|
|
{
|
|
public bool grabed;
|
|
|
|
public override void OnGrab(Grabber grabber)
|
|
{
|
|
|
|
GetComponent<NetworkObject>().RequestStateAuthority();
|
|
base.OnGrab(grabber);
|
|
grabed = true;
|
|
}
|
|
|
|
public override void OnRelease()
|
|
{
|
|
|
|
|
|
|
|
base.OnRelease();
|
|
grabed = false;
|
|
if(GetComponentInParent<Rigidbody>()){
|
|
if( (GetComponentInParent<Rigidbody>().isKinematic)){
|
|
NetworkObject netObj = GetComponent<NetworkObject>();
|
|
netObj.ReleaseStateAuthority();
|
|
netObj.RemoveInputAuthority();
|
|
}
|
|
}else{
|
|
NetworkObject netObj = GetComponent<NetworkObject>();
|
|
netObj.ReleaseStateAuthority();
|
|
netObj.RemoveInputAuthority();
|
|
}
|
|
|
|
|
|
}
|
|
public void OnCollisionEnter(Collision collision)
|
|
{
|
|
if (!grabed && collision.gameObject.tag.Equals("remover"))
|
|
{
|
|
if (Object)
|
|
Runner.Despawn(Object);
|
|
/* NetworkObject netObj = GetComponent<NetworkObject>();
|
|
netObj.ReleaseStateAuthority();
|
|
netObj.RemoveInputAuthority();*/
|
|
}
|
|
}
|
|
public void Update()
|
|
{
|
|
mine = GetComponent<NetworkObject>().HasInputAuthority;
|
|
|
|
}
|
|
public bool mine;
|
|
}
|
|
|
|
}
|