I get this error when i build my Application warning CS0108: ‘PlaneScript.audio’ hides inherited member ‘Component.audio’. Use the new keyword if hiding was intended
i only added ads to my App and now i get this error
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlaneScript : MonoBehaviour
{
public float forwardSpeed = 3f;
public float boostSpeed = 4f;
private bool didFlap;
private Rigidbody2D myRigidbody;
private AudioSource audio;
public GameManager gameManager;
// Use this for initialization
void Start()
{
myRigidbody = this.GetComponent<Rigidbody2D>();
audio = GetComponent<AudioSource>();
// Einfrieren deaktivieren
Time.timeScale = 1f;
}
// Update is called once per frame
void Update()
{
// Flugzeug fliegt entlang der X-Achse
// Entsprechend gewünschter Geschwindigkeit
Vector3 temp = transform.position;
temp.x = temp.x + forwardSpeed * Time.deltaTime;
transform.position = temp;
if (didFlap)
{
// Button wurde gedrückt
// Logik zum Aufsteigen des Flugzeugs
myRigidbody.velocity = new Vector2(0, boostSpeed);
// didFlap false
didFlap = false;
}
}
public void FlapThePlane()
{
Debug.Log("Button geklickt");
didFlap = true;
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "RockHolder")
{
// Sound abspielen
Debug.Log("Sound abspielen");
audio.Play();
// Punktestand +1 erhöhen
gameManager.AddScore();
}
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Ground" || other.gameObject.tag == "Obstacle")
{
// Runde zu Ende
gameManager.EndRound();
}
}
}