Not even making your Zelda game, but applied this to my game. The fact that your video is so easy to follow and usable for different games is awesome! Keep it up!
3:22 Note for some people: Don't forget to had add the "Player" tag for the character. You can do this finding the object and in "Inspector" top left in the panel, there is the tag selection option. "Player" is a default tag by Unity.
Thanks man, you' re a lifesaver. I used this tutorial to implement correct scene changes in my platformer, and it's THE ONLY tutorial that worked for me, for my needs. Again, thanks!
Gradually progressing through these tutorials. They are absolutely wonderful. The pacing is great, and you do an excellent job explaining things. These tutorials have answered so many questions about how to do things that I had no idea how to approach previously. 10/10.
If you want the Player to be facing the correct direction after entering the house, you can make another Vector2 field (ie: playerDirection) and set it up in the SceneTransition script the same way that you did for playerPosition. You’ll need another field in the VectorValue script to store that value as well. When you enter the X and Y values for playerDirection in the inspector, you will want to set X at 0 and Y at 1. This will ensure Player is looking into the house (up) after entering. For the transition out of the house, you’ll set Y to be -1, so Player is looking down. In order to apply the direction in the PlayerMovement script, you will access the animator in the Start() and use animator.SetFloat()… animator.SetFloat(“moveX”, startingPosition.startingDirection.x); animator.SetFloat(“moveY”, startingPosition.startingDirection.y); You can see at 9:12 in the video that he already has animator.SetFloat methods set up. So you can modify them with the above code.
heads up! any modification you want to apply to all instances of a prefab, you should always do it in the prefab editor and not on the scenes. This can cause headaches especially if you remove or add components to the instance and not the prefab itself.
Thank you so much for this! It was exactly what I was looking for! I also found it useful to see the troubleshooting, so thanks for not editing that out.
I originally did this by saving the player position using the unity save system and loading it on the scene start....this seems like a much better way thank you
I am really enjoying this series and I hope that you continue working on it. I had an issue with getting the Scene Transition to work and then when we got the error about the HouseInterior not being loaded I realized that I had never added SampleScene. Fixed both problems.
Hi, I just wanted to say I really enjoy and appreciate your tutorials. They're very helpful, and just wanted to offer my encouragement. Keep up the good work :)
AVOID MY MISTAKE: I created a player prefab to have in each scene, and I dragged the prefab from my assets into my vcam follow slots, and the vcams I did this for stopped working but I didn't catch this immediately and then spent like 3 hours trying to debug. ONLY ONLY ONLY set vcam follows to instantiated instances, not asset prefabs. It is now 4:42am, what a horrible night haha.
Hey you can simplify the scriptable object here. Just have it store the value of your transform. Position outside the house before you enter. Then you can use that on scene load when you leave. That way you dont need to find the position for every single door you wanna make and itll just overwrite the previous position stored in memory when you trigger a new door in your over world.
yes, you want to include a Vector2 offset that you can adjust in the inspector to be safe that you don't spawn in directly on the trigger outside. usually, just make the trigger box collider thin and include a 0.5f offset in whichever direction you're supposed to be spawning in from.
Btw at the end, the player didn't immediately trigger it- otherwise the scene would switch. The scriptable object had just shifted its value on the previous run without ever switching scenes. (Because of the error Unity threw.)
Pff this was a tough follow. It took me until 15:45 in the video to found out why my Transition trigger didn't work! With our current code, we can only enter the Player Position Initial Value once. So if I make it work for my overworld (scene with th house), it doesn't work for the House Interior scene. This isn't much of a problem since we would always start the game at the same place, but I guess later when we add "Save Game" and "Load" our last position, this could be a challenge. As with all previous videos, i'd would recommend new followers to wait with troubleshooting until the end of the clips if possible. Anyway great video!
For anyone struggling and hasn't considered this particular issue, I hit a wall for weeks but turned out I needed to set the player's rigidbody to kinetic. two static objects can't interact as the physics engine expects them to remain still so if the trigger is static then make sure the player is not static too
Ha, thanks. This series was a work in progress and I'd do a few things differently now, but yeah, this was my first attempt at using SO's for an architecture.
@@MisterTaftCreates I would love to hear more about what you would do differently now. If you have more videos about that please point me in the right direction!
ooo very cool set up for making sure the player can enter from different locations! I hope in the future you show how to make it so I don't need to manually reset player position after each playtest but it's not even that big a hassle.
While in SampleScene and you have all the values set up for transitioning between scenes go to your scriptable objects and in the "PlayerPosition" change the InitialValue (in the inspector) to what ever you want your players position to be in the overworld
@@DannsArmy This is what I do but everytime the scenes transition, the initial value just changes back to where the transitions take place. For example, I start on one side of the map and in my game I walk a bit before touching a door to a house which changes the scene to inside the house. I can walk back out just fine, but when I come out of play mode and back in, the value changes it starts me in front of the house instead of my starting point.
I just wanted to add to the comments in case someone else notices it (not sure if it's seen/covered in a later vid). The reason the camera still jumped after you set the position in the start is because the left side of the camera would be "out of bounds" when the scene loads, so it shifts right it it's in bounds. With the exception of moving the whole house to the right (if it was only that easy IRL) or doing some kind of zooming effect, i can't think of a way to stop that.
you can add a quick little method to center the camera on the player's position in the start method, but then you might end up with a race condition between the camera's position and the player's position.
So I have an issue. The values we set for the position during the transition are apparently permanent values. When I start with scene A it goes directly to the door that goes to scene B, instead of the original position in the scene. How do I change this?
Im so confused because whenever i make the scene transition a trigger then write all the code and do whatever the tutorial says then walk into the door, it just makes my player do the crouch animation! This is driving me INSANE!
One thing: Is it possible to make multiple scenes use only one instance of the character? For example: the way it is now, if u take damage in the overworld, u lose half a heart, but if u go into the house, it doesn't save that, and the hearts max out again, but if we use the same instance of player, I imagine it would use the same data and info (eg the health) globally and not locally for each scene
so when i do a scene transfer from overworld to house interior after doing a room transition and transfer back to the overworld the camera jumps to the starting position of where the player started from before the room transition. anyone else having this issue?
@@miadevv1505 it was solved in the Cinemachine tutorial later on but the camera movement script and the room transfers are no longer needed because they are replaced with Cinemachine's virtual camera system Cinemachine is a package on unity
I dont know if i think correctly that the scriptable obj will modifed the value even I had ended the game , it means I have to change back for the scriptable obj PlayerPosition to the default value
I'm working on making a 3d version of the Nes game Crystalis and your tutorial was just what I was looking for. but I did run into an issue with loading the scene. its fine when you first walk through the door but if you do it again the player wont be set to the proper location. instead going back to the original place the player was. not sure if its just a version thing or if its because I'm making a 3d game.
Hi Mister Taft! Amazing tutorial, but i have a doubt.. Vector Value doesnt shows in my menu when i try to create. Do you know why? I 'll appreciate too much your help :)
Amazing tutorial, but is there any workaround if you want to only load these position values when transitioning between certain scenes. Because now everytime I hit play, my character loads at the Vector Value, same if my character dies. It reloads the scene, and spawns my Player at the last Vector Value.
new to unity, followed the instructions sometimes all it says trigger entered and nothing happens and sometimes goes to another scene but without the character.
this realy help me with one scene but when i tried to create for multipol scenes it didn't work (only for one) Can u pls give me a hint or if u have a video for the issue I have I be happy to see thank u
I am very new to programing i wanted to do a scene transition and have spent the past two days after work trying to make it work. Spent hours watching 5 diffrent videos trying to see if any of them worked. But it didn't. Why? because i forgot that boxcollider and boxcollider2D are two VERY diffrent things. But i found this great video because of it so im glad!
Anyone having issue with this method after creating a build ? My scriptableobject VectorValue doesn't seem to work (But in the editor it works prefectely)
This has been the best tutorial for making this type of game. Great way of explaining the code. When will you release the next video? Also, do you have any experience with creating a battle system (similar to pokemon red/blue or undertale?)
Thanks so much. The next few videos are recorded but not edited yet. I'll try to get them out over the holiday weekend, since I should have some extra time. I'm currently helping a student of mine make a battle system similar to that, and will probably add that to my list of possible tutorials for the future.
simple on the canvas add the code public void Awake() { DontDestroyOnLoad(this); } this will make sure the state of ur health coins ect will stay the some (u buy or sell the amount will stay the some u took damage the HP will stay the some)
Help pls I added a dungeon but its in a different area from the original start of the SampleScene so when I teleport out of the scene my sprite goes there but my camera goes near the house that you have in that area pls help;(
Hey there. It sounds like you're not resetting the camera. I change the camera system entirely later in the series, so if you jump ahead to video 46 - Observer Objects, then video 48 - Cinemachine, then it should work better.
MTC just to make things easier for myself. when i swap scenes in the trigger can't i just place i game object at that potition on that scene and the player will appear on that game object when they go from one scene to another isn't there a way to do that instead of having to pass in the cordinates in the inspector??
Hi i have a problem i would like my charachter to be on a specific place when i start the game (play the play button) but player position makes my charachter be on a postion that i only want when i go through a door
@@gabrielpesch5247 I did actually. Someone on discord helped me on it. So basically just make sure the sprite's Z axis is 0 and the sorting layer is above the ground
this series is so awesome. I'm looking forward to the next set. This deserves so many more views. I'm kind of waiting for it to finish though before I begin it (like the candy crush one you did) so I know what i am aiming for. Is there any reason that you are releasing these one at a time? Thanks again for your knowledge!
Hey there. I was trying to release one a week, but I've had some personal life issues come up and they haven't gone away. I'll try to get a video or two up over this long weekend, though. Thanks.
Edit: fixed it, my dumdum plugged 2 SceneTransition scripts into the SceneTransition and didn't plug the position and the PlayerStorage into one of them. I have a weird problem: everytihng works, the code is the same, but whenever I go out of the house it shows "NullReferenceException: Object reference not set to an instance of an object SceneTransition.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/SceneTransition.cs:17)" But everything works perfectly. What could it refer to? Line 17 is the " playerStorage.initialValue = playerPosition;" and I've plugged everything in the Inspector, SampleScene, position and PlayerStorage 0-0
Hi. I played around with the code to see if I could make the player face the right way when entering the house - as in into the house not facing where he came from. I'm going to share it if anyone else wants to use it: In Vector Values add in public Vector2 whichDirectionFacing; In Scene Transitions add playerStorage.whichDirectionFacing = playerFacing; to the if In Player Movement change the Start to this: animator.SetFloat("moveX", startingPosition.whichDirectionFacing.x); animator.SetFloat("moveY", startingPosition.whichDirectionFacing.y); Then the direction can be set in the Scene Transitions in Unity
Hey there. You actually don't need to do that. Just change the default sprite on the player in the scene that you enter a door from. Just choose the upward facing player sprite and put that in the sprite renderer. The animation will still work and change when you move.
Not the way I ended up doing it, but definitely pointed me in a better direction. *Check the reply for some neat code* I was looking to see how other people do it, because setting it up, switching from scene to scene is tedious, and time consuming. Which is what you do here... :( But seeing you using Scriptable objects, inspired me to make a better solution (in my opinion). Make an editor extension script (easier than it sounds), adding an option in the context menu (the three dots) of your TeleportScript (or whatever you call it). This will make it a lot easier to reproduce this process, so you can map out your entire scene in 10 minutes. In the context menu method you will be able to access the properties of the component, adding new scripts to the GameObject, and create assets from script. What the context method will do is create a scriptable object asset using the transform's GameObject name, the scene name (all objects have a reference to their scene), and the coordinates (I'm working on a 3d project, so I also record the transform's rotation, for a proper portal). The TeleportScript will simply have a reference to a Destination scriptable object, slot in any you've created using the method above, and presto, you're done. It may have taken you an hour to get this set up, but now you can create the destination points in a matter of minutes, and you will have many in this sort of game, so it's worth it. Finally, your workflow will look something like this: Go to a scene, position transition points (they don't have a destination yet), click the context menu to create the scriptable object for those points, as above. You now have the assets to teleport to these points... but not from them. Repeat for another scene (or use the assets you've made so far to teleport within the same scene). Once you have 2 sets of assets, you can connect your scenes. Assign the desired destination scriptable object to a TeleportScript, and you just saved yourself hours of tedious work. Pro tip: position all your teleport destinations, select all of them, and then invoke the context method on all of them at once.
The following is a method that needs to go to a *static class* and the file of that class *has to be in a folder named "editor"* Doesn't matter where the folder is, as long as it's called "editor" and you put your class file in it, it's a Unity feature. This method will create an asset file using the data of a GameObject that has the Teleporter script attached to it. A scriptable object is created, along any folders needed on its path. Slot-in your own class, and change the path variable to whatever you need. *Unity knows which type of component the method appears on by name!* *Change the MenuItem attribute to match your class name.* [MenuItem("CONTEXT/YourClassName/Your Method Name")] *Code starts here:* [MenuItem("CONTEXT/Teleporter/Create Destination")] static void CreateDestinationAsset(MenuCommand command) { var comp = (Component) command.context; var tpp = ScriptableObject.CreateInstance(); tpp.targetSceneName = comp.gameObject.gameObject.scene.name; tpp.worldPosition = comp.transform.position; tpp.worldRotation = comp.transform.rotation; string path = "Assets\\Scriptables\\Transitions\\Levels\\" + tpp.targetSceneName; Debug.Log(path); new FileInfo(path+"\\asd.text").Directory.Create(); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + comp.name + ".asset"); Debug.Log(assetPathAndName); AssetDatabase.CreateAsset(tpp, assetPathAndName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); Selection.activeObject = tpp; }
Yeah I had that problem, also a weird blue sprite edge at the top right of it. Seemed to fix these issues by clicking on the objects spritesheet and changing the mesh type from tight to full rect
Heeelp >\\\< Since I added the first Scene transition (House) to the game, my log doesn't work anymore. It doesn't chase the player neither can't the player attack it
hi I had a similar problem I found that if you select your character and under Tag change it to player this might help also make sure the scene transition box collider is set to (is trigger) also you need a character in the new scene that you are going to transfer to other wise it won't work
@@sev9854 sorry, but its been a year since i posted this and I'm not even sure what this post was about anymore, my suggestion for what ever issue you have with your game is to keep searching on RUclips and im sure you will find your answer or you could do what i did and jump over to rpg maker mv or mz its a much better set up with much more control over your game through mods
Would it not be a good idea to set up the scene to load so that you're able to just drop the scene into the inspector instead of having to type it in, and how would we go about setting it up like that?
Any idea why I might be getting a NullReferenceException? The scene transitions perfectly fine. Says it is at just after the if statement for CompareTag for Player && !other.isTrigger. the line: playerPosition.initialValue = playerPosition; I checked, and all my fields in the inspector, they are all filled... How are we to know where a nullReferenceException is???
Okay, so, I have NO idea what happened. I think Unity just messes up sometimes and doesn't compile correctly or something. I just stopped showing up out of nowhere without me making any changes. Sorry for that. I have set up my version control (using Source Tree), so hopefully I no longer have these issues. Plus, now I will go first to your Git files first! Thanks for everything! @@MisterTaftCreates
Hi I'm having problems with the camera. I have created a scene transition in the adjacent tilemap 'area' of the game - call it Area B (west of Area A). if I move my character from Area A into Area B, the camera transitions fine. I then enter a building in area B and then leave, the camera gets stuck on the very west edges of Area A. How can I get the camera to find the player in Area B?
is there any easy way to make a multiple vector value? The thing about my game is player need to go back and forth with 3 different scene. I'm kinda stuck on how to set the value of starting position.
@@Agarm122 I didn't find any solution back then. What I did was, I make all of my scenes into one scene. This way I don't need to go back and forth on different scenes.
Great vids! one issue I'm having is the health bar resets after the transition to a new location... will we be getting to this in a different video? or should I tackle it? Seems like there needs to be some pub/sub between the two scenes to relay information. Or maybe keep the player? seems like something important
Edit: Found out why. it's because when the game starts in heartManager we always call "initHearts" which hardcodes the value back to a fullHeart even tho we are passing the floatValue around correctly and the info is there. You can work around this buy taking out the `hearts[i].sprite = fullHeart` from the InitHearts and adding a call to updateHearts after the for loop. There is also a way to pass around the values using the pub sub but it's a lot more involved.
Hey there. Tutorials on sound effects and music are definitely coming. The tutorials on Inventory will probably be a separate topic to be covered later.
whenever I move to the next area, my initial value changes and then sticks in the InitialValue when I hit stop. How do I fix this so that when I hit play for the first time, I always end up at the proper point? Currently, i have the code int run = 0; if (run < 1) { startingPosition.initialValue.x = -345.7399f; startingPosition.initialValue.y = 163.2162f; run = 2; } else if (run == 2) { startingPosition.initialValue.x = -328.27f; startingPosition.initialValue.y = 156.46f; } but I'm always ending up at -345 even with the scene2 values matching the code in the run 2
Hi I don't expect you to respond but I've encountered an error at 7:30 involving Vector value that I have no clue how to solve. it tells me line 16 that VectorValue doesn't contain a definition for initial value and no accessible extension method 'intialValue'. I have no clue how to solve this and have tried multiple time to no avail
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class loadleveloncollision : MonoBehaviour { [SerializeField] string strTag; [SerializeField] string strSceneName; private void OnCollisionEnter(Collision collision) { if (collision.collider.tag == strTag) SceneManager.LoadScene(strSceneName); } }
Hi. These tutorials are brilliant. Just wondering, if I had say five houses, would it be better to use one scene but set the coordinates to different places to maintain the illusion of different houses or have five separate scenes?
hey, if it helps you any, when Nintendo developed Link to the Past, they included pretty much all the overworld interiors on one layer (or scene in this case), and all the dungeon interiors also on one layer. So I think it is probably the best way to go. You could do it either way, but I think it would make your organization much easier within Unity to keep them all in one scene, and it would probably help with optimization as well (having fewer scenes to load in general I imagine would save on resources).
I came here looking for this exact debate, thanks. My method was to use “teleportation pad” objects on different exported tile grids that connected to each other, which works pretty well so far except for the lingering camera jerk. Might temporarily remove the smoothness to handle that.
Hey there, no, I've had an ongoing family emergency that's taken me out of town consistently for the last two weeks. I'll try to get a few more parts in this series up this week, though.
Hmm somehow i think this gameobject/transition/sprite renderer thing is not a good solution. you have to put the object 100% exactly to not have gaps. better solution would be make a PREFAB BRUSH of the room transition object. just my opinion :-P
Not even making your Zelda game, but applied this to my game. The fact that your video is so easy to follow and usable for different games is awesome! Keep it up!
Glad I could help!
Same here!
3:22 Note for some people: Don't forget to had add the "Player" tag for the character.
You can do this finding the object and in "Inspector" top left in the panel, there is the tag selection option.
"Player" is a default tag by Unity.
THANK YOU I FORGOT
You saved me. Thanks.
Just what I needed! This is great! Now we can make towns, fields, etc. Thanks for sharing your knowledge!!
Thanks so much!
Thanks man, you' re a lifesaver.
I used this tutorial to implement correct scene changes in my platformer, and it's THE ONLY tutorial that worked for me, for my needs.
Again, thanks!
Gradually progressing through these tutorials. They are absolutely wonderful. The pacing is great, and you do an excellent job explaining things. These tutorials have answered so many questions about how to do things that I had no idea how to approach previously. 10/10.
If you want the Player to be facing the correct direction after entering the house, you can make another Vector2 field (ie: playerDirection) and set it up in the SceneTransition script the same way that you did for playerPosition. You’ll need another field in the VectorValue script to store that value as well.
When you enter the X and Y values for playerDirection in the inspector, you will want to set X at 0 and Y at 1. This will ensure Player is looking into the house (up) after entering. For the transition out of the house, you’ll set Y to be -1, so Player is looking down.
In order to apply the direction in the PlayerMovement script, you will access the animator in the Start() and use animator.SetFloat()…
animator.SetFloat(“moveX”, startingPosition.startingDirection.x);
animator.SetFloat(“moveY”, startingPosition.startingDirection.y);
You can see at 9:12 in the video that he already has animator.SetFloat methods set up. So you can modify them with the above code.
heads up! any modification you want to apply to all instances of a prefab, you should always do it in the prefab editor and not on the scenes. This can cause headaches especially if you remove or add components to the instance and not the prefab itself.
Your voice is so calming, i just love it. Also the tutorial is very good. Helped me a lot.
Most relaxing and easy to follow tutorial on Unity I've seen so far! Earned an easy subscription from me :)
Thank you so much for this! It was exactly what I was looking for! I also found it useful to see the troubleshooting, so thanks for not editing that out.
I originally did this by saving the player position using the unity save system and loading it on the scene start....this seems like a much better way thank you
I am really enjoying this series and I hope that you continue working on it.
I had an issue with getting the Scene Transition to work and then when we got the error about the HouseInterior not being loaded I realized that I had never added SampleScene. Fixed both problems.
Glad to know it got fixed!
This tutorial was super simple and easy to add to my game, thanks! Using it for a platformer and it works perfectly fine!
Hi,
I just wanted to say I really enjoy and appreciate your tutorials. They're very helpful, and just wanted to offer my encouragement. Keep up the good work :)
Thank you so much! I've had a family emergency come up, but I'm going to try to get some more videos up this weekend!
AVOID MY MISTAKE: I created a player prefab to have in each scene, and I dragged the prefab from my assets into my vcam follow slots, and the vcams I did this for stopped working but I didn't catch this immediately and then spent like 3 hours trying to debug. ONLY ONLY ONLY set vcam follows to instantiated instances, not asset prefabs. It is now 4:42am, what a horrible night haha.
Hey you can simplify the scriptable object here. Just have it store the value of your transform. Position outside the house before you enter. Then you can use that on scene load when you leave. That way you dont need to find the position for every single door you wanna make and itll just overwrite the previous position stored in memory when you trigger a new door in your over world.
Good point. Thanks for your suggestion!
Wouldn't this end in a endless transitioning, because the position it saves is on the transition position?
yes, you want to include a Vector2 offset that you can adjust in the inspector to be safe that you don't spawn in directly on the trigger outside. usually, just make the trigger box collider thin and include a 0.5f offset in whichever direction you're supposed to be spawning in from.
you helped me out so much! thanks for the tutorial
Btw at the end, the player didn't immediately trigger it- otherwise the scene would switch. The scriptable object had just shifted its value on the previous run without ever switching scenes. (Because of the error Unity threw.)
THIS CHANNEL IS GREAT! This legit the only tutorial that has worked! thanks!
Pff this was a tough follow. It took me until 15:45 in the video to found out why my Transition trigger didn't work! With our current code, we can only enter the Player Position Initial Value once. So if I make it work for my overworld (scene with th house), it doesn't work for the House Interior scene. This isn't much of a problem since we would always start the game at the same place, but I guess later when we add "Save Game" and "Load" our last position, this could be a challenge. As with all previous videos, i'd would recommend new followers to wait with troubleshooting until the end of the clips if possible. Anyway great video!
Please help me. I cannot create Vector Value. When choosing to create only Projectile Ability only. I am really hard 😓
i have watched like 20 tutorials and yours is the best one! love u so much
For anyone struggling and hasn't considered this particular issue, I hit a wall for weeks but turned out I needed to set the player's rigidbody to kinetic. two static objects can't interact as the physics engine expects them to remain still so if the trigger is static then make sure the player is not static too
thx
This is fantastic! Exactly what I wanted to do but I'm new enough I always forget to use the scriptable objects!
Ha, thanks. This series was a work in progress and I'd do a few things differently now, but yeah, this was my first attempt at using SO's for an architecture.
@@MisterTaftCreates I would love to hear more about what you would do differently now. If you have more videos about that please point me in the right direction!
ooo very cool set up for making sure the player can enter from different locations!
I hope in the future you show how to make it so I don't need to manually reset player position after each playtest but it's not even that big a hassle.
While in SampleScene and you have all the values set up for transitioning between scenes go to your scriptable objects and in the "PlayerPosition" change the InitialValue (in the inspector) to what ever you want your players position to be in the overworld
@@DannsArmy This is what I do but everytime the scenes transition, the initial value just changes back to where the transitions take place. For example, I start on one side of the map and in my game I walk a bit before touching a door to a house which changes the scene to inside the house. I can walk back out just fine, but when I come out of play mode and back in, the value changes it starts me in front of the house instead of my starting point.
I just wanted to add to the comments in case someone else notices it (not sure if it's seen/covered in a later vid). The reason the camera still jumped after you set the position in the start is because the left side of the camera would be "out of bounds" when the scene loads, so it shifts right it it's in bounds. With the exception of moving the whole house to the right (if it was only that easy IRL) or doing some kind of zooming effect, i can't think of a way to stop that.
you can add a quick little method to center the camera on the player's position in the start method, but then you might end up with a race condition between the camera's position and the player's position.
@@MisterTaftCreates pls show me how sigh..
So I have an issue. The values we set for the position during the transition are apparently permanent values. When I start with scene A it goes directly to the door that goes to scene B, instead of the original position in the scene. How do I change this?
Did you resolve this? if so how
Im so confused because whenever i make the scene transition a trigger then write all the code and do whatever the tutorial says then walk into the door, it just makes my player do the crouch animation! This is driving me INSANE!
Yeah my transition didn't do anything at all, I had to click File > Build Settings - then "Add Open Scenes" for each scene loaded
@@Jimmiejam87 I had to do this too
@@Jimmiejam87 Thanks for this. I was stuck here as well.
@@Jimmiejam87 Hi, Thanks. I was struggling. You need to drag both scenes to the Building Settings screen. Thanks a lot!
@@Jimmiejam87 That just saved me i couldnt figure out what it was @Jimmiejam87
One thing: Is it possible to make multiple scenes use only one instance of the character? For example: the way it is now, if u take damage in the overworld, u lose half a heart, but if u go into the house, it doesn't save that, and the hearts max out again, but if we use the same instance of player, I imagine it would use the same data and info (eg the health) globally and not locally for each scene
Bump
so when i do a scene transfer from overworld to house interior after doing a room transition and transfer back to the overworld the camera jumps to the starting position of where the player started from before the room transition. anyone else having this issue?
i have this problem too :(
@@miadevv1505 it was solved in the Cinemachine tutorial later on
but the camera movement script and the room transfers are no longer needed because they are replaced with Cinemachine's virtual camera system Cinemachine is a package on unity
I dont know if i think correctly that the scriptable obj will modifed the value even I had ended the game , it means I have to change back for the scriptable obj PlayerPosition to the default value
Sprite of the gate is not loading the transition is there and works perfectly
Good day! It says here in my Visual Studio 2019 that VectorValue could not be found. What will I do? Thanksss
There's a way to always start in one position after start the game before i make the switching scenes? it's the only problem i can't solve until now.
I'm working on making a 3d version of the Nes game Crystalis and your tutorial was just what I was looking for. but I did run into an issue with loading the scene. its fine when you first walk through the door but if you do it again the player wont be set to the proper location. instead going back to the original place the player was. not sure if its just a version thing or if its because I'm making a 3d game.
Hi Mister Taft! Amazing tutorial, but i have a doubt.. Vector Value doesnt shows in my menu when i try to create. Do you know why? I 'll appreciate too much your help :)
I spent so long using the previous method creating maps
Amazing tutorial, but is there any workaround if you want to only load these position values when transitioning between certain scenes. Because now everytime I hit play, my character loads at the Vector Value, same if my character dies. It reloads the scene, and spawns my Player at the last Vector Value.
Did you resolve this? can you tell me how
new to unity, followed the instructions sometimes all it says trigger entered and nothing happens and sometimes goes to another scene but without the character.
This video is a life saver, thank you!!
Thank you!!! I have needed right this! Big like!
this is literally everything i was looking for!!!
(also, using a mac? big respect man!)
why my 10th line in SceneTranstision, "public VectorValue playerStorage". identify as namespace, not a type... stuck on this one, any solution?
Very nice and helpful 😁👍
Thanks a lot
how do you create a vector value??
64 more episodes to go!
this realy help me with one scene but when i tried to create for multipol scenes it didn't work (only for one) Can u pls give me a hint or if u have a video for the issue I have I be happy to see thank u
I am very new to programing i wanted to do a scene transition and have spent the past two days after work trying to make it work. Spent hours watching 5 diffrent videos trying to see if any of them worked. But it didn't. Why? because i forgot that boxcollider and boxcollider2D are two VERY diffrent things. But i found this great video because of it so im glad!
Anyone having issue with this method after creating a build ?
My scriptableobject VectorValue doesn't seem to work
(But in the editor it works prefectely)
You are my hero, thank you a lot!
this is an amazing tutorial but the vector value optio wasnt popping up. did unity remove this feature in later versions? I am using 2021.3
This has been the best tutorial for making this type of game. Great way of explaining the code. When will you release the next video? Also, do you have any experience with creating a battle system (similar to pokemon red/blue or undertale?)
Thanks so much. The next few videos are recorded but not edited yet. I'll try to get them out over the holiday weekend, since I should have some extra time. I'm currently helping a student of mine make a battle system similar to that, and will probably add that to my list of possible tutorials for the future.
Thanks for the brilliant explanation. Just a question. When the player switches a room, how can I save its status? i.e. hearts, coins, ecc.
simple
on the canvas add the code
public void Awake()
{
DontDestroyOnLoad(this);
}
this will make sure the state of ur health coins ect will stay the some (u buy or sell the amount will stay the some u took damage the HP will stay the some)
can you make this for 3D pls
Help pls I added a dungeon but its in a different area from the original start of the SampleScene so when I teleport out of the scene my sprite goes there but my camera goes near the house that you have in that area pls help;(
Hey there. It sounds like you're not resetting the camera. I change the camera system entirely later in the series, so if you jump ahead to video 46 - Observer Objects, then video 48 - Cinemachine, then it should work better.
(Using unity 5.1.1f) when i out using UnityEngine.SceneManagement, it said it doesnt exist in unityEngine namespace…
Amazing. Thank you so much :)
Can you please show us how to add cutscenes?? Thanks so much for these tutorials man!!!
Thanks. I can add that to the list of stuff to add :)
hey nice tutorial! but i have a problem, when i load a scene and switch back to the other scene then i cant press any buttons can someone help pls??
I'm a bit lost. When I transition, I don't see my character at all.
MTC just to make things easier for myself. when i swap scenes in the trigger can't i just place i game object at that potition on that scene and the player will appear on that game object when they go from one scene to another isn't there a way to do that instead of having to pass in the cordinates in the inspector??
I have a problem, some of my sliced asset have lay on top of the floor or wall, but also make weird transition, like the window
My player now seems to only move around the collision blocks (forest, house etc) when I do the transition, any suggestion to solve this problem
Hi i have a problem i would like my charachter to be on a specific place when i start the game (play the play button) but player position makes my charachter be on a postion that i only want when i go through a door
Have you found the solution yet? I have the same problem as well.
@@faiz7180 i guess, because it saves the settings when you use a "scene transition". Just had the same problem :)
I have a problem. The sprite for the door when I made it into a scene transition isn't showing in the game scene. Help please.
Did you fixed it?
@@gabrielpesch5247 I did actually. Someone on discord helped me on it. So basically just make sure the sprite's Z axis is 0 and the sorting layer is above the ground
this transaction can use with another movement script?
I've been having a problem where my character is either moving normally or is sluggish every time I hit play.
this series is so awesome. I'm looking forward to the next set. This deserves so many more views. I'm kind of waiting for it to finish though before I begin it (like the candy crush one you did) so I know what i am aiming for. Is there any reason that you are releasing these one at a time? Thanks again for your knowledge!
Hey there. I was trying to release one a week, but I've had some personal life issues come up and they haven't gone away. I'll try to get a video or two up over this long weekend, though. Thanks.
i have a question for you, can you show us how to make a chest system pls i am very confused and i need your help
Hey there, and thanks for commenting. Yes, chests are coming soon :)
@@MisterTaftCreates thank you for replying, keep up the good work
Question
I dont have any of the prefab buttons like apply on the inspector. Im in a newer version i guess. What should i do?
there should be a drop down menu on your prefab called overrides where you can find the apply button
Edit: fixed it, my dumdum plugged 2 SceneTransition scripts into the SceneTransition and didn't plug the position and the PlayerStorage into one of them.
I have a weird problem: everytihng works, the code is the same, but whenever I go out of the house it shows
"NullReferenceException: Object reference not set to an instance of an object
SceneTransition.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/SceneTransition.cs:17)"
But everything works perfectly. What could it refer to? Line 17 is the " playerStorage.initialValue = playerPosition;" and I've plugged everything in the Inspector, SampleScene, position and PlayerStorage 0-0
Hi. I played around with the code to see if I could make the player face the right way when entering the house - as in into the house not facing where he came from. I'm going to share it if anyone else wants to use it:
In Vector Values add in public Vector2 whichDirectionFacing;
In Scene Transitions add
playerStorage.whichDirectionFacing = playerFacing; to the if
In Player Movement change the Start to this:
animator.SetFloat("moveX", startingPosition.whichDirectionFacing.x);
animator.SetFloat("moveY", startingPosition.whichDirectionFacing.y);
Then the direction can be set in the Scene Transitions in Unity
Hey there. You actually don't need to do that. Just change the default sprite on the player in the scene that you enter a door from. Just choose the upward facing player sprite and put that in the sprite renderer. The animation will still work and change when you move.
@Mister Taft Creates
Didn't work for me, Instantly starts facing towards the screen again when I run it.
btw thanks for this awesome tutorial you deserved a liked views and subs
Thank you so much!
Not the way I ended up doing it, but definitely pointed me in a better direction.
*Check the reply for some neat code*
I was looking to see how other people do it, because setting it up, switching from scene to scene is tedious, and time consuming.
Which is what you do here... :(
But seeing you using Scriptable objects, inspired me to make a better solution (in my opinion).
Make an editor extension script (easier than it sounds), adding an option in the context menu (the three dots) of your TeleportScript (or whatever you call it).
This will make it a lot easier to reproduce this process, so you can map out your entire scene in 10 minutes.
In the context menu method you will be able to access the properties of the component, adding new scripts to the GameObject, and create assets from script.
What the context method will do is create a scriptable object asset using the transform's GameObject name, the scene name (all objects have a reference to their scene), and the coordinates (I'm working on a 3d project, so I also record the transform's rotation, for a proper portal).
The TeleportScript will simply have a reference to a Destination scriptable object, slot in any you've created using the method above, and presto, you're done.
It may have taken you an hour to get this set up, but now you can create the destination points in a matter of minutes, and you will have many in this sort of game, so it's worth it.
Finally, your workflow will look something like this:
Go to a scene, position transition points (they don't have a destination yet), click the context menu to create the scriptable object for those points, as above.
You now have the assets to teleport to these points... but not from them.
Repeat for another scene (or use the assets you've made so far to teleport within the same scene).
Once you have 2 sets of assets, you can connect your scenes.
Assign the desired destination scriptable object to a TeleportScript, and you just saved yourself hours of tedious work.
Pro tip: position all your teleport destinations, select all of them, and then invoke the context method on all of them at once.
The following is a method that needs to go to a *static class* and the file of that class *has to be in a folder named "editor"*
Doesn't matter where the folder is, as long as it's called "editor" and you put your class file in it, it's a Unity feature.
This method will create an asset file using the data of a GameObject that has the Teleporter script attached to it.
A scriptable object is created, along any folders needed on its path.
Slot-in your own class, and change the path variable to whatever you need.
*Unity knows which type of component the method appears on by name!*
*Change the MenuItem attribute to match your class name.*
[MenuItem("CONTEXT/YourClassName/Your Method Name")]
*Code starts here:*
[MenuItem("CONTEXT/Teleporter/Create Destination")]
static void CreateDestinationAsset(MenuCommand command) {
var comp = (Component) command.context;
var tpp = ScriptableObject.CreateInstance();
tpp.targetSceneName = comp.gameObject.gameObject.scene.name;
tpp.worldPosition = comp.transform.position;
tpp.worldRotation = comp.transform.rotation;
string path = "Assets\\Scriptables\\Transitions\\Levels\\" + tpp.targetSceneName;
Debug.Log(path);
new FileInfo(path+"\\asd.text").Directory.Create();
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + comp.name + ".asset");
Debug.Log(assetPathAndName);
AssetDatabase.CreateAsset(tpp, assetPathAndName);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
EditorUtility.FocusProjectWindow();
Selection.activeObject = tpp;
}
Since this lesson the health bar (object 123) has been going backwards every time i run the program. has this happened to anyone?
Yeah I had that problem, also a weird blue sprite edge at the top right of it. Seemed to fix these issues by clicking on the objects spritesheet and changing the mesh type from tight to full rect
Heeelp >\\\<
Since I added the first Scene transition (House) to the game, my log doesn't work anymore. It doesn't chase the player neither can't the player attack it
that y i love SO, great video :))))
Any Ideas on why the trigger isn't working mate? I done the script correctly but nothings happening when I walk into the box collider
hi I had a similar problem I found that if you select your character and under Tag change it to player this might help also make sure the scene transition box collider is set to
(is trigger) also you need a character in the new scene that you are going to transfer to other wise it won't work
@@coreprimal1172 yeah I finally sorted it but thankyou ahah :)
@@Killaisking9999 Como você resolveu? how did you solve it?
@@coreprimal1172 how? My Character already in Player TAG and also my Collider also in isTrigger, but my Scene Transfer still didnt work
@@sev9854 sorry, but its been a year since i posted this and I'm not even sure what this post was about anymore, my suggestion for what ever issue you have with your game is to keep searching on RUclips and im sure you will find your answer or you could do what i did and jump over to rpg maker mv or mz its a much better set up with much more control over your game through mods
what about going into water tiles??
After scene transitions my enemy does not chase the player anymore:(
Would it not be a good idea to set up the scene to load so that you're able to just drop the scene into the inspector instead of having to type it in, and how would we go about setting it up like that?
You could totally do that. I'm not sure why but it just makes more sense to me to use a string like this.
Any idea why I might be getting a NullReferenceException? The scene transitions perfectly fine.
Says it is at just after the if statement for CompareTag for Player && !other.isTrigger.
the line: playerPosition.initialValue = playerPosition;
I checked, and all my fields in the inspector, they are all filled...
How are we to know where a nullReferenceException is???
Did you hook up the references to the canvas for the new area etc?
Okay, so, I have NO idea what happened. I think Unity just messes up sometimes and doesn't compile correctly or something. I just stopped showing up out of nowhere without me making any changes. Sorry for that. I have set up my version control (using Source Tree), so hopefully I no longer have these issues. Plus, now I will go first to your Git files first!
Thanks for everything! @@MisterTaftCreates
Hi
I'm having problems with the camera. I have created a scene transition in the adjacent tilemap 'area' of the game - call it Area B (west of Area A). if I move my character from Area A into Area B, the camera transitions fine. I then enter a building in area B and then leave, the camera gets stuck on the very west edges of Area A. How can I get the camera to find the player in Area B?
Is the room transition maybe finding both of the player's colliders?
is there any easy way to make a multiple vector value? The thing about my game is player need to go back and forth with 3 different scene. I'm kinda stuck on how to set the value of starting position.
did you find a solution?
@@Agarm122 I didn't find any solution back then. What I did was, I make all of my scenes into one scene. This way I don't need to go back and forth on different scenes.
Hiya! Would you ever consider making a tutorial on how to make turn-based RPG combat? Like in Pokemon.
Hello. That is one of the topics that will be on the possible list after I finish this one.
Great vids! one issue I'm having is the health bar resets after the transition to a new location... will we be getting to this in a different video? or should I tackle it? Seems like there needs to be some pub/sub between the two scenes to relay information. Or maybe keep the player? seems like something important
Edit: I realize that this is only the UI might be easier fix than I anticipated.
Edit: Found out why. it's because when the game starts in heartManager we always call "initHearts" which hardcodes the value back to a fullHeart even tho we are passing the floatValue around correctly and the info is there. You can work around this buy taking out the `hearts[i].sprite = fullHeart` from the InitHearts and adding a call to updateHearts after the for loop. There is also a way to pass around the values using the pub sub but it's a lot more involved.
Why my caracter does not appear in the next scene ?
Doing this has made it so that when I collide with pots, they break, the enemy doesnt move and all my hearts have dissapeared! Can someone pls help.
ACtually, the only problem is when I walk into pots they break
Muito Obrigado! Thank you!!!
I need some help. Could you do some tutorials on Inventory, sound effects and music? I would be so happy =D
Hey there. Tutorials on sound effects and music are definitely coming. The tutorials on Inventory will probably be a separate topic to be covered later.
whenever I move to the next area, my initial value changes and then sticks in the InitialValue when I hit stop. How do I fix this so that when I hit play for the first time, I always end up at the proper point? Currently, i have the code
int run = 0;
if (run < 1)
{
startingPosition.initialValue.x = -345.7399f;
startingPosition.initialValue.y = 163.2162f;
run = 2;
}
else if (run == 2)
{
startingPosition.initialValue.x = -328.27f;
startingPosition.initialValue.y = 156.46f;
}
but I'm always ending up at -345 even with the scene2 values matching the code in the run 2
Hello! have you figured it out? I am in the same situation right now.
@@alex_opr Try using the OnAfterDeserialize method
GRACIAAAAAAAAAAAS
Hi I don't expect you to respond but I've encountered an error at 7:30 involving Vector value that I have no clue how to solve. it tells me line 16 that VectorValue doesn't contain a definition for initial value and no accessible extension method 'intialValue'. I have no clue how to solve this and have tried multiple time to no avail
I think you misspelled "initialValue" in one of your scripts. Classic, but gut wrenching
can you make a tutorial just like this but on 3d
i got you bro
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class loadleveloncollision : MonoBehaviour
{
[SerializeField]
string strTag;
[SerializeField]
string strSceneName;
private void OnCollisionEnter(Collision collision)
{
if (collision.collider.tag == strTag)
SceneManager.LoadScene(strSceneName);
}
}
I dont understand why my scene transition is invisible
I don't know why either. Check the color value in the inspector while you play. Is that value changing?
Make sure the sorting layer is above the ground and the Z position is 0
Hi. These tutorials are brilliant. Just wondering, if I had say five houses, would it be better to use one scene but set the coordinates to different places to maintain the illusion of different houses or have five separate scenes?
That's a great idea. You could also have the houses be in this scene, and just change the player's position.
hey, if it helps you any, when Nintendo developed Link to the Past, they included pretty much all the overworld interiors on one layer (or scene in this case), and all the dungeon interiors also on one layer. So I think it is probably the best way to go. You could do it either way, but I think it would make your organization much easier within Unity to keep them all in one scene, and it would probably help with optimization as well (having fewer scenes to load in general I imagine would save on resources).
I came here looking for this exact debate, thanks. My method was to use “teleportation pad” objects on different exported tile grids that connected to each other, which works pretty well so far except for the lingering camera jerk. Might temporarily remove the smoothness to handle that.
What the heck is a VectorValue?
It was replaced in Unity 2019 with Vector Position
Hey man :) hope you're okay. Did you like take two weeks vacations or something ? ^^
Hey there, no, I've had an ongoing family emergency that's taken me out of town consistently for the last two weeks. I'll try to get a few more parts in this series up this week, though.
@@MisterTaftCreates Ow I hope you and your close ones are okay
They will be. It's kind of ongoing, but I'll try to get back to making videos soon.
@@MisterTaftCreates yeah look as much as I love your videos your family comes first. If you need anything just say. Be strong.
Hmm somehow i think this gameobject/transition/sprite renderer thing is not a good solution. you have to put the object 100% exactly to not have gaps. better solution would be make a PREFAB BRUSH of the room transition object. just my opinion :-P
...and. when startin in the house the player looks down. it should look up. so after transition you need to change the sprite to look up :-)
You're right. I think I address this in a future video by setting the last move x and y then calling update animation and move from the start method.
I have error