C
C#2y ago
benny9952

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; } }
18 Replies
TheRanger
TheRanger2y ago
$details
MODiX
MODiX2y ago
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)
benny9952
benny99522y ago
says dosnt exist in current contexed the PlayerStats
TheRanger
TheRanger2y ago
can u show the error message exactly?
benny9952
benny99522y ago
yeah
TheRanger
TheRanger2y ago
well your class does not have a field or a property called PlayerStats defined
benny9952
benny99522y ago
like this PlayerGUI PlayerStats = new PlayerGUI();?
TheRanger
TheRanger2y ago
yes
benny9952
benny99522y ago
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
TheRanger
TheRanger2y ago
you have to define them first
benny9952
benny99522y ago
how do i do that?
TheRanger
TheRanger2y ago
just like how you defined reloadSpeed, playerProjectileSpeed, and the rest
benny9952
benny99522y ago
sorry i think i did this all wrong i wanted PlayerStats to be an object that holds it own reloadSpeed?
TheRanger
TheRanger2y ago
do that then
benny9952
benny99522y ago
sorry how this is how i thought you did it?
TheRanger
TheRanger2y ago
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
benny9952
benny99522y ago
thanks