i3e-asg2/Assets/Scripts/GunPickable.cs

41 lines
860 B
C#
Raw Normal View History

2024-07-01 03:11:10 +00:00
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 Interact()
2024-07-01 03:11:10 +00:00
{
base.Interact();
2024-07-01 03:11:10 +00:00
gameObject.GetComponent<Gun>().enabled = true;
InHand = true;
}
public override void Drop()
{
base.Drop();
gameObject.GetComponent<Gun>().enabled = false;
InHand = false;
}
public override void Update()
2024-07-01 03:11:10 +00:00
{
if (InHand)
{
Vector3 currentRotation = transform.eulerAngles;
currentRotation.x = Camera.transform.eulerAngles.x;
transform.eulerAngles = currentRotation;
}
base.Update();
2024-07-01 03:11:10 +00:00
}
2024-07-01 03:11:10 +00:00
}