I'm trying to write a script that let's me pickup a gun in my game but I'm getting an error that I can't seem to diagnose.
The error:
Assets/Scripts/M9Pickup.cs(37,24): error CS0119: Expression denotes a type, where a variable, value or method group was expected
My script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class M9Pickup : MonoBehaviour {
public float TheDistance = PlayerCasting.DistanceFromTarget;
public GameObject TextDisplay;
public GameObject GunPickup;
public GameObject PlayerGun;
public GameObject AmmoDisplay;
public AudioSource PickUpAudio;
void Update () {
TheDistance = PlayerCasting.DistanceFromTarget;
if (Input.GetButtonDown("Action")) {
if (TheDistance <= 2 ) {
StartCoroutine(PickupGun());
}
}
}
void OnMouseOver () {
if (TheDistance <= 2 ) {
TextDisplay.GetComponent().text = "Take Gun";
}
}
void OnMouseExit () {
TextDisplay.GetComponent().text = "";
}
IEnumerator PickupGun () {
PickUpAudio.Play();
transform.position = Vector3(0, -1000, 0);
GunPickup.SetActive(false);
PlayerGun.SetActive(true);
AmmoDisplay.SetActive(true);
yield return new WaitForSeconds(0.1f);
}
}
↧