Generally you can your GetComponent() to find objects on the same GameObject, GetComponentInChildren() to get access to a component on a child object or GetComponentInParent() to find it in any parent of a GameObject. I hope it helps!
Oh that is because we want to know when health value is not set. With int (value types that can't be null) we often use -1 to indicate that something has no valid value / was never set properly. It is much better to use more explicate null value or bool true / false to indicate that we don't have the health value saved. This would be useful in a more advanced example where we have extra parameters like tank modifier which can be null or something like "faster shooting" etc.
Hi , I have I little issue , when I press play for the first time is ok it s reset all the data , but if I go press play when I use the back to the menu and returns me to the main menu , the play does what continue do , any tips?
Maybe I forgot to set "Time.timeScale = 1" ? If we have set timeScale = 0 the time is frozen and no Update function is running until we set it back to 1
Sorry to hear that! It is my older tutorial so I can't be sure what is going on. Usually it is caused by some error in the code. It also might be something simple like assigning in the inspector the buttons the other way around.
Why doesn't in my SaveSystem object Ispector appear the UnityEvent "OnDataLoadedResult" if in the code is written down "UnityEvent", but it appears if I write down only "UnityEvent"?
Hey! If you can see the event try writing it as *public UnityEvent myEvent;"* It should show up in the inspector this way. As for the parameter when you try assigning a method to it the methods that takes the value type defined in ex bool will appear at the top of the list.
Are you instantiating a new player prefab? Consider that each level / scene is "separate". The player usually is in it already so you just need to place it in the correct spot. Like if your level hase multiple "entrances" you just save the "entrance index" in PlayerPrefs and when you load a new scene you teleport the player prefab that ALREADY IS in the scene to the correct position. I cover this and much more in my newest 2D Farm Game in Unity course courses.sunnyvalleystudio.com/p/2d-farm-game-in-unity-2022 🙂
It might be a code bug / you might not be calling the save logic or load logic. It is really hard to tell. Try debugging your save system code - here is a tutorial about debugging th-cam.com/video/zP9GjLnRF8I/w-d-xo.html
TO implement it you would want to connect spawn points using some ID so that if your drive from level 2 to level 1 level 2 has the ID and saves it. Next level 1 gets the date and moves the player tank to the correct spawn point. I will be explaining this system in my 2D farm game course when it comes out courses.sunnyvalleystudio.com/p/2d-farm-game-in-unity-2022
Just completed the tutorial honestly thank you so much for uploading this dude incredibly helpful and informative!
I'm glad it helped!
Thank you so much. I've learned a lot and the code in this video was clean and well organized.
Glad to hear it!
I finally have done it ) after so many months) thank you so much) it was very useful and inspiring)
Great job! 👍 I really hope it will help you 🙂 And thanks for watching!
I find this tutorial so many month
Finally i found it ;) thks u
Glad I could help! 🙂
Thanks sir, you saved my Unity project :)
Hi, at 17:21 what if i have all script in player instead of in children? What should i do in order to get findobjectype in GameManager? Thanks!
Generally you can your GetComponent() to find objects on the same GameObject, GetComponentInChildren() to get access to a component on a child object or GetComponentInParent() to find it in any parent of a GameObject.
I hope it helps!
@@SunnyValleyStudio Thanks!
But why It not go to level 3?
It only work for 2 level?
You can have as many levels as you like. You just need to trigger the transition and specify which level to load 🙂
why at 7:52, by default is minus one? please explain for dummy such as I...
Oh that is because we want to know when health value is not set. With int (value types that can't be null) we often use -1 to indicate that something has no valid value / was never set properly. It is much better to use more explicate null value or bool true / false to indicate that we don't have the health value saved. This would be useful in a more advanced example where we have extra parameters like tank modifier which can be null or something like "faster shooting" etc.
Hi , I have I little issue , when I press play for the first time is ok it s reset all the data , but if I go press play when I use the back to the menu and returns me to the main menu , the play does what continue do , any tips?
Maybe I forgot to set "Time.timeScale = 1" ? If we have set timeScale = 0 the time is frozen and no Update function is running until we set it back to 1
thx help me allot but the cuntinue button work as start button
Sorry to hear that! It is my older tutorial so I can't be sure what is going on. Usually it is caused by some error in the code. It also might be something simple like assigning in the inspector the buttons the other way around.
@@SunnyValleyStudio OK Thanks for the help
Why doesn't in my SaveSystem object Ispector appear the UnityEvent "OnDataLoadedResult" if in the code is written down "UnityEvent", but it appears if I write down only "UnityEvent"?
Hey! If you can see the event try writing it as *public UnityEvent myEvent;"* It should show up in the inspector this way. As for the parameter when you try assigning a method to it the methods that takes the value type defined in ex bool will appear at the top of the list.
There are 2 player in my scene can someone help me😅
Are you instantiating a new player prefab? Consider that each level / scene is "separate". The player usually is in it already so you just need to place it in the correct spot. Like if your level hase multiple "entrances" you just save the "entrance index" in PlayerPrefs and when you load a new scene you teleport the player prefab that ALREADY IS in the scene to the correct position.
I cover this and much more in my newest 2D Farm Game in Unity course courses.sunnyvalleystudio.com/p/2d-farm-game-in-unity-2022 🙂
your work is the best, but if i want to go back to level 1 and come out at the entry of level 2, how to do that sir
and one more problem, i follow you code but somehow it wont save after i exit, it did save when playing and moving to another level
It might be a code bug / you might not be calling the save logic or load logic. It is really hard to tell. Try debugging your save system code - here is a tutorial about debugging th-cam.com/video/zP9GjLnRF8I/w-d-xo.html
TO implement it you would want to connect spawn points using some ID so that if your drive from level 2 to level 1 level 2 has the ID and saves it. Next level 1 gets the date and moves the player tank to the correct spawn point.
I will be explaining this system in my 2D farm game course when it comes out courses.sunnyvalleystudio.com/p/2d-farm-game-in-unity-2022