Great tutorial!! @18:00 you mention trying to account for max fall speed to DrawJumpArc curve. I added a float terminalVelocityTime = Mathf.Abs(MoveStats.MaxFallSpeed/MoveStats.Gravity), just before you start iterating timeSteps. Then in the descending else section first remove the last line. Your horizontal velocity will be the same throughout so you can calculate a total horizontal displacement of new Vector2(speed, 0) * descendTime (just adding this to displacement is fine) then: If your descendTime is less than that terminalVelocityTime you add 0.5f * new Vector2(0, MoveStats.Gravity) * Mathf.Pow(descendTime, 2) to displacement Else you'll add 0.5f * new Vector2(0, MoveStats.Gravity) * Mathf.Pow(terminalVelocityTime, 2) for the gravity accelerated component and then add new Vector2(0, -MoveStats.MaxFallSpeed) * (descendTime - terminalVelocityTime) for the remaining fall at terminal velocity.
Thanks for sharing that, it certainly would be helpful for beginners who wants to build a platformer. Although I've noted few things in your tutorial which will make it certainly harder to support and add more features to the controller. Since you're changing velocity of rigidbody directly without using AddForce, you are basically killing possibility to interact with other objects such as Surface effector for example, since it applies a force to a rigidbody in a specific direction, it also will be hard to make a moving platform work flawlessly with that, since you would have to figure out how to add velocity of platform to the player and conserve momentum during jumps. Overall good job, keep it up
A "simple" solution to the moving platforms is to make the player a Child of the platform when they hit it, and dechild the player when they jump - this wont save momentum though.
definitely going to be looking over my jump after watching this, all the adjustability seems really useful. i have to ask though, do you have thoughts on implementing movement via AddForce instead of straight velocity changes? seems to me like implementing knockbacks or such would be a lot simpler if movement is done with AddForce? really grateful for all the videos so far, they've helped tremendously in setting up various systems.
I've copied your code to a T but my character flips dramatically to the other side of the screen and doesn't move. Not too sure what I did wrong. It doesn't work.
Great Platformer Tutorial! Although, it took a while before I was able to type all the lines of code. I had a few issues when implementing this, first I noticed you didn't talk about the camera and what type of camera to be used, I'm using cinemachine but I'm getting weird results when moving the player, the camera is a bit wobbly and when I press Left Arrow Key or A key, the camera moves to the right instead of the left not following the player, but when I press the Right Arrow Key, it works at it should. I'm not sure you factored when the player moves left in the PlayerMovement script. I also noticed the player keeps jumping when I press spacebar multiple times, the effect of gravity does not really work. I messed with values of MaxFallSpeed, TimeTillJump Apex and some others but it was to no avail.
I also noticed if I press the jump button and immediately hold the right arrow key or D key, the player hangs in the air and is not affected by gravity but if I press the spacebar key when stuck in the air, the player then comes down to the ground.
Gravity works, but the player doesn't move when the keys are pressed. New project, empty scene. I copied everything you did, including your input actions and inspector settings. Unity 2022.3.8f1
I absolutely love your tutorials they have been SO helpful in setting up my game cannot thank you enough for these
Great tutorial!!
@18:00 you mention trying to account for max fall speed to DrawJumpArc curve. I added a float terminalVelocityTime = Mathf.Abs(MoveStats.MaxFallSpeed/MoveStats.Gravity), just before you start iterating timeSteps.
Then in the descending else section first remove the last line. Your horizontal velocity will be the same throughout so you can calculate a total horizontal displacement of new Vector2(speed, 0) * descendTime (just adding this to displacement is fine) then:
If your descendTime is less than that terminalVelocityTime you add 0.5f * new Vector2(0, MoveStats.Gravity) * Mathf.Pow(descendTime, 2) to displacement
Else you'll add 0.5f * new Vector2(0, MoveStats.Gravity) * Mathf.Pow(terminalVelocityTime, 2) for the gravity accelerated component and then add new Vector2(0, -MoveStats.MaxFallSpeed) * (descendTime - terminalVelocityTime) for the remaining fall at terminal velocity.
Dude, you have no idea how much you helped me. Thank you very much! We need more of these videos! :)
Awesome Tutorial, as always.
really great tutorial. thank you!
Thanks for sharing that, it certainly would be helpful for beginners who wants to build a platformer. Although I've noted few things in your tutorial which will make it certainly harder to support and add more features to the controller. Since you're changing velocity of rigidbody directly without using AddForce, you are basically killing possibility to interact with other objects such as Surface effector for example, since it applies a force to a rigidbody in a specific direction, it also will be hard to make a moving platform work flawlessly with that, since you would have to figure out how to add velocity of platform to the player and conserve momentum during jumps. Overall good job, keep it up
A "simple" solution to the moving platforms is to make the player a Child of the platform when they hit it, and dechild the player when they jump - this wont save momentum though.
Nice tutorial!
tus videos me ayudan a seguir adelante, hay muchas cosas que debo aprender de unity, Me encanta personalizar la jugabilidad del personaje.
18:12 OnDrawGizmos isn't called in a Build, so turning it off or leaving it on won't make a difference.
Great walkthrough!
Oh. That is super cool and nice!
definitely going to be looking over my jump after watching this, all the adjustability seems really useful. i have to ask though, do you have thoughts on implementing movement via AddForce instead of straight velocity changes? seems to me like implementing knockbacks or such would be a lot simpler if movement is done with AddForce? really grateful for all the videos so far, they've helped tremendously in setting up various systems.
thanks you for your awesome tutorial, but how do you handle inclined plane like stairs ?
Buddy explains the new input system of unity
Please can you zoom in a little bit the script that I can see it clairly and thank you so much for these great tutorials .
This reminds me of the plarformer toolkit by GMTK
Hey thanks. Is there a reason why you didn't switch the rigid bodys to kinematic if you don't need the actual dynamics like you said in the beginning?
I've copied your code to a T but my character flips dramatically to the other side of the screen and doesn't move. Not too sure what I did wrong. It doesn't work.
Great Platformer Tutorial! Although, it took a while before I was able to type all the lines of code.
I had a few issues when implementing this, first I noticed you didn't talk about the camera and what type of camera to be used, I'm using cinemachine but I'm getting weird results when moving the player, the camera is a bit wobbly and when I press Left Arrow Key or A key, the camera moves to the right instead of the left not following the player, but when I press the Right Arrow Key, it works at it should. I'm not sure you factored when the player moves left in the PlayerMovement script.
I also noticed the player keeps jumping when I press spacebar multiple times, the effect of gravity does not really work. I messed with values of MaxFallSpeed, TimeTillJump Apex and some others but it was to no avail.
I also noticed if I press the jump button and immediately hold the right arrow key or D key, the player hangs in the air and is not affected by gravity but if I press the spacebar key when stuck in the air, the player then comes down to the ground.
Fantastic!
Gravity works, but the player doesn't move when the keys are pressed. New project, empty scene. I copied everything you did, including your input actions and inspector settings. Unity 2022.3.8f1
this did not work for me. Not sure what i did wrong.
How to do state machine?
i guess.. i will can not add an other platformer movement mechanics after all by myself😅
can u upload the code?
How can i try this?
epic
First