Question by
Squirtle439 · May 02, 2020 at 06:53 AM ·
scripting problemscripting beginner
Why Does this not work? please someone help me i am new to coding.
using System; using System.Collections; using UnityEngine;
public class GunFire {
void Update() {
if (Input.GetButtonDown("Fire1"))
{
AudioSource gunsound = GetComponent<AudioSource>();
gunsound.Play();
GetComponent<Animation>().Play("GunShot");
}
}
public GunFire()
{
}
}
Comment
Answer by highpockets · May 02, 2020 at 06:52 AM
This class is not inheriting from any other class.
At the top of the script, add MonoBehaviour inheritance :
public class GunFire : MonoBehaviour
Your answer
Follow this Question
Related Questions
Need help disabling a script in another GameObject 1 Answer
How To change a Text Object's Color Randomly using Color 32? 2 Answers
Please Help With Script 1 Answer
Issue with if-statements requiring two conditions. 1 Answer
Continuing a Dialogue 0 Answers