I Have an error that is holding my game development back error
Assets\Scripts\Battery.cs(46,9): error CS0122: ‘Flashlight.AlterEnergy(int)’ is inaccessible due to its protection level
. Here is the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Battery : MonoBehaviour
{
public Flashlight fL;
bool buttonInRange;
bool buttonActivated;
AudioClip batterySound;
private static float batteryPower = 10;
public GUISkin guiSkin;
private bool hasPlayed = false;
void OnTriggerEnter(Collider c)
{
buttonInRange = true;
}
void OnTriggerExit(Collider c)
{
buttonInRange = false;
}
void OnGUI()
{
if (buttonInRange == true)
{
GUI.skin = guiSkin;
GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 55, 120, 50), "Pick up batteries");
}
}
void Update()
{
if (buttonInRange == true)
{
if (Input.GetKeyDown("e"))
{
if (!hasPlayed)
{
AudioSource.PlayClipAtPoint(batterySound, transform.position);
fL.AlterEnergy(batteryPower);
Destroy(gameObject);
hasPlayed = true;
}
}
}
}
}