My apologies, it seems during the encoding process, the audio and video got slowly out of sync the further you are in the video. Doesn't seem to be too bad though. Also JUST updated the project files link to include this one.
@@Deathzuki. I have the same problem i need the player to jump when touched the screen but it cant because the jump is on spacebar. I thought deleting the line in the player script where it says if input key spacebar but i dont know it doesnt work. i cant find a solution for this
@superjustin5000 do we need another script for that or must be there made changes in the player script for making the player jump on touchscreen ( or hold the touchscreen for bigger jump)???
Thanks a lot for the tutorials, Im learning many things I didnt know and it helps a lot. I actually had a question. How do you add coins ( like you did with the obstacles ) so that they randomly spawn on the ground. Not like the obstacles that you have to avoid them but actually collect the coins that are randomly spawning so they dont decrease your move speed. Maybe with a counter of collected coins. The idea was you play again and again dying but collecting coins that are randomly spawned and also by making a shop ( like for skins or buffs) you can waste your money/coins you collected from the previous attempts. That would give the game a little more potential and it would give the game more sense to spend more time playing it and Im sure this would help a lot for people who are also looking for something like this. Maybe you could explain it to me or make another tutorial, but anyways I would be very grateful for everything.
Sure thing. It shouldn't be too much heavy lifting, and a lot of what you need can be copied from what you have. Like you said, the obstacles randomly generate, so creating something similar would represent the coin. You can check the type in the OnTriggerEnter function, and distinguish between obstacle vs coin. The UI text is already there for distance, so something similar for coins. The only thing left is to track the count of how many you've collected.
@@superjustin5000 Seems makeable. The thing is I'm new to unity so I needed some help and your opinion. Alright, thanks for sharing and the time you wasted to answer me, I will try this but not sure if I can do it xD Anyways I'll give it a try, thanks a lot.
Great series - very helpful explanations! I especially love the parallax and the technique/math for introducing new buildings/obstacles. I do have a question about a bug I've noticed. In play testing there's a bug related to ray detection. Frequently, when landing after a jump on top of a "collapsing" building - the code doesn't trigger the "isGrounded" correctly - and the player falls through the middle of the building. Similarly (I think) when the player starts going a decent speed/velocity they occasionally pass through an obstacle without it trigging a hit. These seem more fundamental to the ray cast implementation for hit detection and the ray not being "long" enough to detect a hit in some cases? I haven't attempted a solution yet. I'm thinking it would involve testing with more interpolation of where we predict the player might be next frame, to see if we'd pass over an obstacle or into a building, etc. That is - create the length of the ray based on that "next" position? I'm wondering if keeping the ray cast solution is worth it, or abandoning that in favor of (as you suggested on another comment) using rigidbodies with kinematic/continuous hit detection. If you see this comment I'd be curious about your thoughts on continuing with the raycast checks, especially knowing the speed of the player is important and the time between frames, given a potentially slow mobile device, might be pretty jumpy? I'm thinking "will I run into more bugs related to missed ray cast checks" that will need addressing later, and would using another method of collision detection be more future-proof?
Hey thanks! Funny enough I was just running into a similar issue in my other project, so thanks for bringing it up. The raycast should work similarly to a continuous collider collision check so you can try that too, but I think it's because the position and velocity are incremented before the actual raycast check is happening, so the raycast is a frame off / ahead. Try to first save the previous position into a variable before advancing it by velocity and use the previous position when calculating the raycast origin. OR.. just do the raycast checking earlier and do the updates of position and velocity later, or at the end of the update or something. If that's not entirely the reason this issue is presenting itself, it's at least partly responsible.
@@superjustin5000 Hi, I just solved the problem mentioned above. There were two problems. The first one is that you mentioned from above reply (plus a little bit of floating point error), and the second one was from GroundFall.cs. There's part that if the ground is falling, player position and groundheight of the decremented with fall speed, even when isGround is not true. So after I added if statement about isGround, the problem's been solved. Hope this comment helps those who have the same problem! Thanks for the video!
This all good for the beginning. However the platform generator depends on a single object which must be instantiated within the bounds of a screen in order for it to be generated again and again. Not sure if the math will work once you randomize the length of platforms!? For example, Canabalt has many running platform objects, some of them stretching 2 or even 3 sizes of screen. I do love how you handled acceleration, and reference to the jump height in relation to platforms etc.., but this solution has a constant predictive rhythm for the entire duration of gameplay time. Why didn't you decide to pull the objects from the array?
Nice tutorials. I have a question please. This appears to work well on PC. But not so well on Android. You can seemingly hit ground and stop and fall through it for some reason. Is it somehow a timing issue on the FPS and the code? Pc Vs Mobile device perhaps? Thanks for any thoughts.
That's what it seems like, however the the collision check is happening in fixedUpdate so the delta time should be consistent. I guess if the underlying unity physics simulation is running slow it could be a factor. One thing worth checking is that, all objects that have rigidbodies (which might only be the player), make sure the type is kinematic, and that the collision detection is set to 'continuous' and not 'discrete'. Let me know if you solve it.
I did this for android and i have the issue that on phones is no spacebar but the jump is only called when pressed spacebar. How do you make the player jump on touchscreen? Please answer it would be veryyyy helpful.
Sorry to get back to you so late, but it's always a good idea to check out the unity documentation, here's one relating to getting touch input : docs.unity3d.com/ScriptReference/Input.GetTouch.html
Hi there. Love this series. I know its kinda ended long time ago, but I have a question. Probably its just me missing something, but I have a critical gameplay bug in my version of the game from this tutorial. I can jump in the air non-stop using a ground threshold mechanic. If I press space just in right moment I can catch that treshold, even if there is no ground under player. Thats cause ground height updates only by touching platforms. I wonder do you have that bug too, or is it me missing some part of some video? Thanks :)
Honestly my version probably has it as well. It has been a while since I looked at the code, but your explanation sounds very convincing and likely that there is a bug there. You can download my project from the ko-fi link and test it out yourself. Otherwise you can do something where, as soon as the player leaves the platform (their position is past the right edge) then set their ground height to some very low value like -100 or something. Thanks!
My apologies, it seems during the encoding process, the audio and video got slowly out of sync the further you are in the video. Doesn't seem to be too bad though. Also JUST updated the project files link to include this one.
Great series. How do you make the same jump system but with touch control that you click on the screen or you hold the screen for jumping?
@@Deathzuki. I have the same problem i need the player to jump when touched the screen but it cant because the jump is on spacebar. I thought deleting the line in the player script where it says if input key spacebar but i dont know it doesnt work. i cant find a solution for this
@superjustin5000 do we need another script for that or must be there made changes in the player script for making the player jump on touchscreen ( or hold the touchscreen for bigger jump)???
@@art3misj260 just change the GetKey for a GetButtonDown("Fire1")
@@mikimiyagui9269 i did that but then the player jumps only on click, like if you hold the screen he wont jump further
i completed the entire series. its pretty sweet so far. thank you for being helpful, clear easy to understand. good lookin out yo.
Nice work, happy to hear that, and hope you're able to make something awesome! Thanks.
Thanks a lot for the tutorials, Im learning many things I didnt know and it helps a lot. I actually had a question. How do you add coins ( like you did with the obstacles ) so that they randomly spawn on the ground. Not like the obstacles that you have to avoid them but actually collect the coins that are randomly spawning so they dont decrease your move speed. Maybe with a counter of collected coins. The idea was you play again and again dying but collecting coins that are randomly spawned and also by making a shop ( like for skins or buffs) you can waste your money/coins you collected from the previous attempts. That would give the game a little more potential and it would give the game more sense to spend more time playing it and Im sure this would help a lot for people who are also looking for something like this. Maybe you could explain it to me or make another tutorial, but anyways I would be very grateful for everything.
Sure thing. It shouldn't be too much heavy lifting, and a lot of what you need can be copied from what you have. Like you said, the obstacles randomly generate, so creating something similar would represent the coin. You can check the type in the OnTriggerEnter function, and distinguish between obstacle vs coin. The UI text is already there for distance, so something similar for coins. The only thing left is to track the count of how many you've collected.
@@superjustin5000 Seems makeable. The thing is I'm new to unity so I needed some help and your opinion. Alright, thanks for sharing and the time you wasted to answer me, I will try this but not sure if I can do it xD Anyways I'll give it a try, thanks a lot.
Great series - very helpful explanations! I especially love the parallax and the technique/math for introducing new buildings/obstacles.
I do have a question about a bug I've noticed. In play testing there's a bug related to ray detection. Frequently, when landing after a jump on top of a "collapsing" building - the code doesn't trigger the "isGrounded" correctly - and the player falls through the middle of the building. Similarly (I think) when the player starts going a decent speed/velocity they occasionally pass through an obstacle without it trigging a hit. These seem more fundamental to the ray cast implementation for hit detection and the ray not being "long" enough to detect a hit in some cases?
I haven't attempted a solution yet. I'm thinking it would involve testing with more interpolation of where we predict the player might be next frame, to see if we'd pass over an obstacle or into a building, etc. That is - create the length of the ray based on that "next" position? I'm wondering if keeping the ray cast solution is worth it, or abandoning that in favor of (as you suggested on another comment) using rigidbodies with kinematic/continuous hit detection.
If you see this comment I'd be curious about your thoughts on continuing with the raycast checks, especially knowing the speed of the player is important and the time between frames, given a potentially slow mobile device, might be pretty jumpy? I'm thinking "will I run into more bugs related to missed ray cast checks" that will need addressing later, and would using another method of collision detection be more future-proof?
Hey thanks!
Funny enough I was just running into a similar issue in my other project, so thanks for bringing it up. The raycast should work similarly to a continuous collider collision check so you can try that too, but I think it's because the position and velocity are incremented before the actual raycast check is happening, so the raycast is a frame off / ahead.
Try to first save the previous position into a variable before advancing it by velocity and use the previous position when calculating the raycast origin.
OR.. just do the raycast checking earlier and do the updates of position and velocity later, or at the end of the update or something.
If that's not entirely the reason this issue is presenting itself, it's at least partly responsible.
@@superjustin5000 Hi, I just solved the problem mentioned above. There were two problems. The first one is that you mentioned from above reply (plus a little bit of floating point error), and the second one was from GroundFall.cs. There's part that if the ground is falling, player position and groundheight of the decremented with fall speed, even when isGround is not true. So after I added if statement about isGround, the problem's been solved. Hope this comment helps those who have the same problem!
Thanks for the video!
This all good for the beginning. However the platform generator depends on a single object which must be instantiated within the bounds of a screen in order for it to be generated again and again. Not sure if the math will work once you randomize the length of platforms!? For example, Canabalt has many running platform objects, some of them stretching 2 or even 3 sizes of screen.
I do love how you handled acceleration, and reference to the jump height in relation to platforms etc.., but this solution has a constant predictive rhythm for the entire duration of gameplay time.
Why didn't you decide to pull the objects from the array?
Wow such a beautiful tutorial series I would definitely try to make a game based on your base thanks
Do it! Send updates. Thanks for the kind words. 🍻
Thank you very much man!
Thanks for the request! Cheers 🍻
Very good, thanks for the video series
The only thing is, the buildings are get destroyed before they are out from the screen, should be easy to fix though
Sometimes, the player still suddenly falls when the ground is falling
Thank you so much such ... Cant express in words 😁
I think you just did 🤔
@@superjustin5000 but you got my feelings right? That's what I mean...
Nice video keep it up!
Nice tutorials. I have a question please. This appears to work well on PC. But not so well on Android. You can seemingly hit ground and stop and fall through it for some reason. Is it somehow a timing issue on the FPS and the code? Pc Vs Mobile device perhaps? Thanks for any thoughts.
That's what it seems like, however the the collision check is happening in fixedUpdate so the delta time should be consistent. I guess if the underlying unity physics simulation is running slow it could be a factor. One thing worth checking is that, all objects that have rigidbodies (which might only be the player), make sure the type is kinematic, and that the collision detection is set to 'continuous' and not 'discrete'. Let me know if you solve it.
@@superjustin5000 Thanks for the reply. I will check that out and let you know. Cheers.
How can we generate different types of buildings? Do we need to create array of game objects and randomize it?
Yes that's for sure a good way to do it
I did this for android and i have the issue that on phones is no spacebar but the jump is only called when pressed spacebar. How do you make the player jump on touchscreen? Please answer it would be veryyyy helpful.
Sorry to get back to you so late, but it's always a good idea to check out the unity documentation, here's one relating to getting touch input : docs.unity3d.com/ScriptReference/Input.GetTouch.html
I have some issues in player distance display ing
I'll definitely need to know more information. Or you can send me your project.
Put some animations pls we are here to learn 👍
This could be a future video 🤔
Plus one for this
Hi there. Love this series. I know its kinda ended long time ago, but I have a question. Probably its just me missing something, but I have a critical gameplay bug in my version of the game from this tutorial. I can jump in the air non-stop using a ground threshold mechanic. If I press space just in right moment I can catch that treshold, even if there is no ground under player. Thats cause ground height updates only by touching platforms. I wonder do you have that bug too, or is it me missing some part of some video? Thanks :)
Honestly my version probably has it as well. It has been a while since I looked at the code, but your explanation sounds very convincing and likely that there is a bug there. You can download my project from the ko-fi link and test it out yourself. Otherwise you can do something where, as soon as the player leaves the platform (their position is past the right edge) then set their ground height to some very low value like -100 or something.
Thanks!