I love your tutorials, but at 7:35 i have a problem where my GroundTest collider doesn't spawn in the same place as the square sprite, instead it spawns a bit to the right of it. what seems to be the problem here
@@superjustin5000 Yes it was, but don't worry I managed to fix it, turns out there was a mistake on the x object itself, thank you for the I guide I love it:)
After about 7:33 adding the duplicating platforms etc when i play my player drops down into the top bit of the platform but can jump out eventually to the next platform so everything is working fine but the player dropping down into the platform. Any ideas?
Could have something to do with the calculations of the right side of the screen. Your scene, camera, and objects could be different sizes than mine. Tough to say without seeing your project.
So for others, don't get caught out with accidentally using groundHeight instead of groundRight lol - I know from experience mistakes like that cost a lot of time XD also the math was going over my head but the end goal is what is important to me XD
Great tutorial, thanks! However, I was wondering how you could make sure that all platforms look different. Because it looks kind of weird when you jump from building to building but every building is the same, just with a different height. Do you know how I can do this? I'm just a beginner and I'm not really succeeding for now.... Thanks in advance :)
Definitely, one strategy, if you've worked with sprites. In your Ground script, you can have a public array of Sprites, then when instantiating the next ground game object, you can set it's sprite object's sprite renderer's sprite property to one of the sprites in the array randomly. That's the idea at least. spriteObject.GetComponent().sprite = myRandomSprite; In practice might be a bit tougher since they might also be different sizes, which will affect the colliders.
@@superjustin5000 Sorry for the questions, but my primary language isn't English so it's quite hard for me to understand all the specific technical terms... How can I make the script understand what those commands like myRandomSprite and spriteObject mean? Do I have to make a float out of them at the beginning of the script or do I have to do something else? And how can you make Unity understand which buildings need to be randomly spawned? Do you like have to put them under GroundTest? Thank you so, so much in advance!!! I really love your content, your video tutorials are very easy understandable and enjoyable to watch!
Ok so, I also stream game dev on twitch, and I think you've inspired me to do a Q & A stream. So I'll be streaming the answer to your question. I'm going live in about 10 minutes or so and the video will be archived. Twitch.tv/superjustin5000
@@superjustin5000 I am currently trying to implement platforms with different colliders. I managed to spawn them randomly just by creating an array but now I am facing a problem where the shortest platfrorm spawns too close and the longest spawns too far depending on which platform is next. Do you know how can this problem be solved? I've created a full mobile game with the help of your videos and want to improve it now. Also I wanted to thank you for your tutorials, they really helped me a lot.
You just have to position the camera based on it's orthographic size and aspect ratio. If the orthographic size is 5, then that's the y coordinate of the camera, since the orthographic size is half of it's full height. If your aspect ratio is 16x9 then multiply 5 by 16/9 (1.777777) which is approx. 8.8888 so that's your x coordinate.
That's correct, and intentional. It all depends on how your final Sprite will look, where you position the ray casts, and how you position the Sprite based on the ground height. Usually you want to add on half the Sprite height to the ground height on land, and lower the ray cast by the same distance.
(maybe my previous comment has been marked as spam) Hi, I got a problem that the first generated platform sometimes reaches the maximum y or the value of y that player cannot jump onto it. I have copied your ground code and this still happens. Could you please tell me what mistake I could have made?
Hmm tough to tell without your project files. The ground script also reads a few values off of the player. It might be helpful to make sure those are correct off the start. The ground would get generated too high if the something was off with one of the jump variables. Also be sure to check your scene setup, I hard coded a lot of value (Not good practice) based on the size and position of my camera relative to the scene.
Hey came across this tutorial a few days back and ive been trying to replicate it in godot for a while now but ive been running into unexpected errors .... anyone know of a good source i can refer??
currently following your videos, they have been very helpful. im trying to add something to the ground script to change the sprite of square if the y cord of the ground hitbox is above a certain threshold. how can i call the square and tell it to change its sprite? my code is all the same as yours to my knowledge.
Sure yes. I guess first, are you changing the sprite of the ground? You can probably do that in the Awake or start function of the ground. Grab a reference to the sprite renderer. I think the sprite is a sub-object of the gound and I think it was named "square", so that would be something like SpriteRenderer renderer = transform.Find("square").getComponent(); and after that you can edit the sprite at any time by doing renderer.sprite = someNewSpriteRef; Good luck and thanks for the feedback!
I read all the code of ground script... but there is an issue from my prespective, The hight(y) of the ground can go so high that the player would go out of screen when jump. So i calculated the (screenTop = Camera.main.transform.position.y * 2 - 10;) ScreenTop and made it less by 10 units as i thing that should be the possible maxHight(maxY) as not to make the player out of the screen from top... But i am not a great programmer as u r.. So plz can u just help me to impliment it, by just leting me know how can i do it... Thanks! Great Content❤
Maybe double check, I thought I made sure to prevent that, but I'll also double check. If anything you're free to send me your project and I can take a look, or you can download the project files in the description and compare. Thanks for reaching out.
@@lumen471 hmm dm's should totally work if you follow me, just tested that. But there's always discord in the description or my email is jfletch1787@gmail.com if you can't get it working.
great tutorial love to watch :) question: Isn't it also better to make the width of the platform depended on the player speed? If low speed small width platforms are possible and the higher the speed, the wider the platforms must become?
Thanks. Yea that's certainly something to consider. But I do like the other challenge that when you run too fast, you have to watch out not to jump too far. Give it a shot.
I don't understand how the loop works because there is nothing changing the didGroundgenerate back to false. So surely after one ground is generated and this Boolean is given the value true, no more ground will be generated as it doesn't pass the condition !didGroundgenerate.
Pretty good observation, but there is a bit of a trick. It's a ground that's responsible for generating only one other ground, then the next ground generates the next and so on. So each ground only needs the boolean flag once.
@@superjustin5000 I see so the ground generates one, and because the new ground is created with didGroundgenerate having a value of false, that will then generate one more ground and so on.
@@superjustin5000 woah - thanks for the reply man - really appreciate it - I've been messing with the initial values of the ground and it looks like everything matches what you were doing pretty much exactly gonna keep messing with it thanks again
Hey could you help me out I keep having a problem with the player whenever it touches the ground it goes up in the air for some reason and it keeps repeating and im not touching the jump button. It would mean a lot if you would help me out!!!! I could offer you more details if you ask me.
@@superjustin5000 I must be an error king or something cause the ground keeps spawning at WAY faster rate than should be and it spawning in the wrong places it overlapping and just plain wrong idk what I did I must be dense or something cause I cant figure it out. :(
You'd want to look up how to setup your unity project to build for Android or iOS. I'm sure there are plenty of tutorials for that out there. I don't usually do mobile but I'll help out if it's gameplay code specific. You're welcome on our discord anytime. There are plenty of others there who are also willing to help or learn.
hey, i really like your videos, please post more 2d game development tutorials with unity, and if you have any courses on Udemy or on any platform, just say that I will be the first to buy !!!!!
It's comments like this that keep me going. Cheers 🍻 . New series is coming soon I promise. If you have any suggestions for future videos I'm all ears.
@@superjustin5000 Well, if to suggest something, I think it's cool to watch about the game development itself, about how the game market works and etc ... It's also nice to have short videos teaching cool things, example: How to make a camera shake at unity. This kind of quick tutorial teaching these things is pretty cool. (Sorry if there is a lot of error in writing, I'm from Brazil and I don't speak English yet, so I'm using the Google translator).
Love it! Keep 'em coming!
You got it my man!
I love your tutorials, but at 7:35 i have a problem where my GroundTest collider doesn't spawn in the same place as the square sprite, instead it spawns a bit to the right of it. what seems to be the problem here
Are you saying the collider for the ground is in the wrong spot compared to the ground sprite??
@@superjustin5000 Yes it was, but don't worry I managed to fix it, turns out there was a mistake on the x object itself, thank you for the I guide I love it:)
After about 7:33 adding the duplicating platforms etc when i play my player drops down into the top bit of the platform but can jump out eventually to the next platform so everything is working fine but the player dropping down into the platform. Any ideas?
Awesome tutorial! I'd love to see tile version of it
Tile version? Like using the Unity tile map?
@@superjustin5000 Yes
@@superjustin5000 y e s
7:25
my ground is spawning in the middle and not on the right. can you help me?
Could have something to do with the calculations of the right side of the screen. Your scene, camera, and objects could be different sizes than mine. Tough to say without seeing your project.
@@superjustin5000 oh thanks. i fixed it. thanks for the quick respons
@@dattoproduction4450 awesome 😎
So for others, don't get caught out with accidentally using groundHeight instead of groundRight lol - I know from experience mistakes like that cost a lot of time XD also the math was going over my head but the end goal is what is important to me XD
Yea the variable names are a mess but, when I'm trying to go fast, I don't even think about it, but I'm glad you got there.
Great tutorial, thanks! However, I was wondering how you could make sure that all platforms look different. Because it looks kind of weird when you jump from building to building but every building is the same, just with a different height. Do you know how I can do this? I'm just a beginner and I'm not really succeeding for now.... Thanks in advance :)
Definitely, one strategy, if you've worked with sprites. In your Ground script, you can have a public array of Sprites, then when instantiating the next ground game object, you can set it's sprite object's sprite renderer's sprite property to one of the sprites in the array randomly. That's the idea at least.
spriteObject.GetComponent().sprite = myRandomSprite;
In practice might be a bit tougher since they might also be different sizes, which will affect the colliders.
@@superjustin5000 Sorry for the questions, but my primary language isn't English so it's quite hard for me to understand all the specific technical terms... How can I make the script understand what those commands like myRandomSprite and spriteObject mean? Do I have to make a float out of them at the beginning of the script or do I have to do something else? And how can you make Unity understand which buildings need to be randomly spawned? Do you like have to put them under GroundTest? Thank you so, so much in advance!!! I really love your content, your video tutorials are very easy understandable and enjoyable to watch!
Ok so, I also stream game dev on twitch, and I think you've inspired me to do a Q & A stream. So I'll be streaming the answer to your question. I'm going live in about 10 minutes or so and the video will be archived. Twitch.tv/superjustin5000
@@superjustin5000 Wow, thank you so much, I didn't even realise that you streamed, so awesome!! I'll definitely watch it today! Thanks so much man!
@@superjustin5000 I am currently trying to implement platforms with different colliders. I managed to spawn them randomly just by creating an array but now I am facing a problem where the shortest platfrorm spawns too close and the longest spawns too far depending on which platform is next. Do you know how can this problem be solved? I've created a full mobile game with the help of your videos and want to improve it now. Also I wanted to thank you for your tutorials, they really helped me a lot.
My Ground Is not Moving towards left
Tough to say without seeing your code / project. Have you downloaded the project files (link in description) to compare?
what are the maths used for set the bottom left corner in the 0,0 position?
You just have to position the camera based on it's orthographic size and aspect ratio. If the orthographic size is 5, then that's the y coordinate of the camera, since the orthographic size is half of it's full height.
If your aspect ratio is 16x9 then multiply 5 by 16/9 (1.777777) which is approx. 8.8888 so that's your x coordinate.
@@superjustin5000 thanks dude! i'm gonna try that operations, thanks again to make awesome videos
Half of the character I put stays in the ground.
That's correct, and intentional. It all depends on how your final Sprite will look, where you position the ray casts, and how you position the Sprite based on the ground height. Usually you want to add on half the Sprite height to the ground height on land, and lower the ray cast by the same distance.
(maybe my previous comment has been marked as spam)
Hi, I got a problem that the first generated platform sometimes reaches the maximum y or the value of y that player cannot jump onto it. I have copied your ground code and this still happens. Could you please tell me what mistake I could have made?
this is the screenshot of when it happened drive.google(.)com/file/d/1I5l7SeSxO0BtYLb8epZgfIYQBPrFSb88/view (remove the parenthesis)
Hmm tough to tell without your project files. The ground script also reads a few values off of the player. It might be helpful to make sure those are correct off the start. The ground would get generated too high if the something was off with one of the jump variables.
Also be sure to check your scene setup, I hard coded a lot of value (Not good practice) based on the size and position of my camera relative to the scene.
Hey came across this tutorial a few days back and ive been trying to replicate it in godot for a while now but ive been running into unexpected errors .... anyone know of a good source i can refer??
my platform is just following the player, any ideas on how to fix this?
currently following your videos, they have been very helpful. im trying to add something to the ground script to change the sprite of square if the y cord of the ground hitbox is above a certain threshold. how can i call the square and tell it to change its sprite? my code is all the same as yours to my knowledge.
Sure yes. I guess first, are you changing the sprite of the ground? You can probably do that in the Awake or start function of the ground. Grab a reference to the sprite renderer. I think the sprite is a sub-object of the gound and I think it was named "square", so that would be something like
SpriteRenderer renderer = transform.Find("square").getComponent();
and after that you can edit the sprite at any time by doing
renderer.sprite = someNewSpriteRef;
Good luck and thanks for the feedback!
I read all the code of ground script... but there is an issue from my prespective, The hight(y) of the ground can go so high that the player would go out of screen when jump. So i calculated the (screenTop = Camera.main.transform.position.y * 2 - 10;) ScreenTop and made it less by 10 units as i thing that should be the possible maxHight(maxY) as not to make the player out of the screen from top... But i am not a great programmer as u r.. So plz can u just help me to impliment it, by just leting me know how can i do it... Thanks! Great Content❤
Maybe double check, I thought I made sure to prevent that, but I'll also double check. If anything you're free to send me your project and I can take a look, or you can download the project files in the description and compare. Thanks for reaching out.
@@superjustin5000 I just followed u on twitter for a chat but not sure if u had turned ur dm's off..
@@lumen471 hmm dm's should totally work if you follow me, just tested that. But there's always discord in the description or my email is jfletch1787@gmail.com if you can't get it working.
great tutorial love to watch :) question: Isn't it also better to make the width of the platform depended on the player speed? If low speed small width platforms are possible and the higher the speed, the wider the platforms must become?
Thanks. Yea that's certainly something to consider. But I do like the other challenge that when you run too fast, you have to watch out not to jump too far. Give it a shot.
Awesome Tutorial! Just, why would you take your time with negative value 🤔 doesn't make sense to me.
I trying and Idk why the player falling down :/
I would like to help, but I'd need a better description of what your problem is.
Much love for canabalt
My Player keeps on falling then respawning at the top
You should come to the discord, a few people have had this same experience. Ask chuuyarx
@@superjustin5000 thanks
I don't understand how the loop works because there is nothing changing the didGroundgenerate back to false. So surely after one ground is generated and this Boolean is given the value true, no more ground will be generated as it doesn't pass the condition !didGroundgenerate.
Pretty good observation, but there is a bit of a trick. It's a ground that's responsible for generating only one other ground, then the next ground generates the next and so on. So each ground only needs the boolean flag once.
@@superjustin5000 I see so the ground generates one, and because the new ground is created with didGroundgenerate having a value of false, that will then generate one more ground and so on.
@@aadityadahal4622 You got it!
I keep getting this problem where sometimes the first ground that generates is extremely high - after that everything works fine :/
Hmm each ground generates the next ground, so it could be something in the initial values of the first ground that's in the scene??
@@superjustin5000 woah - thanks for the reply man - really appreciate it - I've been messing with the initial values of the ground and it looks like everything matches what you were doing pretty much exactly
gonna keep messing with it
thanks again
@@superjustin5000 also, was wondering - would you be open to doing some freelance work?
@@alextoma402 Depends on the work, feel free to email or contact me, most of my info is in the descriptions or my website : www.superjustin.com
Hey could you help me out I keep having a problem with the player whenever it touches the ground it goes up in the air for some reason and it keeps repeating and im not touching the jump button. It would mean a lot if you would help me out!!!! I could offer you more details if you ask me.
Hmm, something could be up with how its applying velocity, because velocity always gets adjusted by gravity, but should only do it when not grounded.
@@superjustin5000 I must be an error king or something cause the ground keeps spawning at WAY faster rate than should be and it spawning in the wrong places it overlapping and just plain wrong idk what I did I must be dense or something cause I cant figure it out. :(
Haha, not sure if you noticed, back in Part 2, I was having that same issue, because of the placements of the nested game objects. Could be similar.
@@superjustin5000 Soooo how did you fix it though?
@@anthonylewis3804 just position the parent object to something reasonable like 0,0,0 then reposition the child objects accordingly.
Can u make tutorial for android games
Do you mean NOT using Unity, or exporting a Unity game to Android?
@@superjustin5000 im new to developing how can i create mobile games?
You'd want to look up how to setup your unity project to build for Android or iOS. I'm sure there are plenty of tutorials for that out there. I don't usually do mobile but I'll help out if it's gameplay code specific. You're welcome on our discord anytime. There are plenty of others there who are also willing to help or learn.
@@superjustin5000 oh can you help me from where should i start developing.
Do you mean learn how to program?
hey, i really like your videos, please post more 2d game development tutorials with unity, and if you have any courses on Udemy or on any platform, just say that I will be the first to buy !!!!!
It's comments like this that keep me going. Cheers 🍻 . New series is coming soon I promise. If you have any suggestions for future videos I'm all ears.
@@superjustin5000 Well, if to suggest something, I think it's cool to watch about the game development itself, about how the game market works and etc ... It's also nice to have short videos teaching cool things, example: How to make a camera shake at unity. This kind of quick tutorial teaching these things is pretty cool.
(Sorry if there is a lot of error in writing, I'm from Brazil and I don't speak English yet, so I'm using the Google translator).
why do you type so aggressively like calm down
NO!