i3e-asg2/Assets/Scripts/GunPickable.cs
2024-07-01 11:11:10 +08:00

39 lines
819 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunPickable : Pickable
{
private bool InHand;
public override void Start()
{
base.Start();
gameObject.GetComponent<Gun>().enabled = false;
}
public override void PickUp()
{
base.PickUp();
gameObject.GetComponent<Gun>().enabled = true;
InHand = true;
}
public override void Drop()
{
base.Drop();
gameObject.GetComponent<Gun>().enabled = false;
InHand = false;
}
public void Update()
{
if (InHand)
{
Vector3 currentRotation = transform.eulerAngles;
currentRotation.x = Camera.transform.eulerAngles.x;
transform.eulerAngles = currentRotation;
}
}
}