I am using a weapon system where the weapon prefabs are dragged into the inspector slots, these are the prefabs from the assets windo not from the game heirarchy, the values of the weapons change during gameplay but i need to reset them when the game restarts, i have tried to use anothe variable to reset them to the values but they do not update in the inspector window, can this be done without making them static variables, they are all public int variables.
bit stuck thanks
So you’re changing values on the original prefab instead of an object in the scene? Why not just instantiate the prefab, modify values on the instantiated object instead of the prefab, then when you restart the game you just instantiate the clean prefab again?
because i am using a purchased asset and when i press mouse key to fire the bullet gets instatiated and then destroyed upon hit or time delay, there is no way to use the object by dragging it into the object list, it will just delete itself when play is pressed, with a normal prefab the values are reset when game is stopped but with this the values are changed in game but when game is stoppd the values do not get reset they stay altered so i need to reset them back to the starting values
anyone got an idea how to do this or is this impossible to do in unity, seeing as the asset cost money and now it is basically not usable if i can not reset the values of the prefab
Contact the author of the asset. We can’t help much without any code, which you’re not allowed to share.
thanks i have contacted the seller, if he has no problem with me posting the code i will post it here, i change the variables runtime but they just dont reset when the game is stopped, i thought they would
i have managed to replicate the problem in a small project ( file atached ), load the project and then select the cube in the assets so that it is displayed in the inspector, it has a script called test atached to the cube prefab, there are 2 variables, number is set by me to 10, when you press play new number will be equal to number, when press spacebar the cube is intantiated by the gun object, when the bullet hits the target it adds 1 to newnumber which can be seen in the inspector of the cube prefab ( not the instantiated cube bullet ) but the prefab in the assets, so now newnumber increases, now the problem is this when the game is stopped and restarted the newnumber is not reset back to 10 it keeps the increased number, i need a way to reset the nemnumber of the prefab cube every time the game is restarted but it seems impossible to do, if anyone can help me with this i would be grateful as the asset i purchased operates in this way and i have to try to reset a number on a prefab as in the example here
thank you
7540999–931564–test prefab varable update 1.rar (3.13 MB)