#null GameOBject
1 messages · Page 1 of 1 (latest)
Show your code for the weapon controller.
the error is on line 16, so the variable you're using there will be the thing to look at
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
ah yeah, ownedWeapons is static
when you go to the main menu, all objects in the old scene are destroyed
ownedWeapons will now be a list of destroyed objects
You could put references to prefabs into that list, perhaps
I'll try that
Do you want to preserve the list of weapons when you quit and start a new game?
Nah I want to go back to only the starting weapon, being the pistol
This game will basically be like call of duty zombies
Once you exit game or die, everything resets
Yeah I dont think it will be possible, the issue I am facing is my muzzle flash as I cannot assign it to my scripts since it is a child of each weapon prefabs
Ah, that's simple enough
(this is a very common problem)
do you have a Weapon component right now?
if so, add a field on it for the muzzle flash, and then, for each prefab, assign the muzzle flash component into that field
now you can just access it directly from the Weapon
Yeah sort of misread what you said, I tried to put it into the available weapons list, the issue is that I have a buying system and I need it to be static for that reason. Which I shoulda mentioned before. https://hastebin.com/share/oyewedutil.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Perhaps you can use ScriptableObjects for this. Each one would store a reference to a weapon prefab and a cost
or, really
[System.Serializable]
public struct ShopItem {
public Weapon prefab;
public float cost;
}
give your shop a list of that ShopItem struct and throw prefabs in there
Yeah my brain hurts
Like I thought I could just check if it was null, something simple, yeah maybe this is too complicated for my second ever game lol
Thank you for trying to help, I am just going to remove the buying stations in my game, I think I am just going overboard for my second ever game. And when I gain more knowledge I could maybe come back to this
It would be simpler to just have a few bools on the player that say if you have a weapon unlocked or not