hello can someone fix me please and also tell me why im dumb
public class PlayerGUI : MonoBehaviour
{
public float playerMoveSpeed; public float playerLives; public float playerProjectileSpeed; public float reloadSpeed = 20f; void start(){ PlayerStats = new PlayerGUI(); }
void Update() {
} public float GetReloadSpeed() { PlayerStats.reloadSpeed = reloadSpeed; return PlayerStats.reloadSpeed; } }
public float playerMoveSpeed; public float playerLives; public float playerProjectileSpeed; public float reloadSpeed = 20f; void start(){ PlayerStats = new PlayerGUI(); }
void Update() {
} public float GetReloadSpeed() { PlayerStats.reloadSpeed = reloadSpeed; return PlayerStats.reloadSpeed; } }
18 Replies
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
says dosnt exist in current contexed the PlayerStats
can u show the error message exactly?
yeah
well your class does not have a field or a property called
PlayerStats
definedlike this PlayerGUI PlayerStats = new PlayerGUI();?
yes
yeah was doing that searched online they said not 2 but they both dont work and say same thing
Assets\Scripts\ShootProjectile.cs(28,24): error CS0103: The name 'PlayerStats' does not exist in the current context
Assets\Scripts\PlayerGUI.cs(23,9): error CS0103: The name 'PlayerStats' does not exist in the current context
you have to define them first
how do i do that?
just like how you defined reloadSpeed, playerProjectileSpeed, and the rest
sorry i think i did this all wrong i wanted PlayerStats to be an object that holds it own reloadSpeed?
do that then
sorry how this is how i thought you did it?
look i suggest u learn the basics of C# before you start unity or ur gonna have a real hard time
try checking out these links $helloworld
Written interactive course https://learn.microsoft.com/en-us/users/dotnet/collections/yz26f8y64n7k07
Videos https://dotnet.microsoft.com/learn/videos
thanks