5. Hold Button to Jump Higher--Let's Make A 2D SideScroller! (BEGINNER Unity Tutorial)

  Рет қаралды 4,662

Night Run Studio

Night Run Studio

Күн бұрын

Пікірлер: 39
@EzraVFX
@EzraVFX 2 жыл бұрын
I love the way you explain, keep up the great work!
@NightRunStudio
@NightRunStudio 2 жыл бұрын
Thanks! I appreciate the encouraging feedback.
@Z4riki
@Z4riki 3 ай бұрын
fantastic job with the videos so far ive done everything with no errors ,ive made some obstacles for the player to jump from but everytime when i go near the collider i have set, the player just falls to the ground like face down( rolls over ) and i dont know what to do can u please help me ?
@Z4riki
@Z4riki 3 ай бұрын
nevermind i just didnt check the freeze rotation box XD
@NightRunStudio
@NightRunStudio 3 ай бұрын
@@Z4riki Glad you figured it out!
@NightRunStudio
@NightRunStudio 3 ай бұрын
Glad the series has been helpful! Thanks for sharing the comment.
@Illuym
@Illuym Жыл бұрын
quick question, physics stuff is supposed to be in FixedUpdate no? shouldn't the part where we use Physics2D be in FixedUpdate?
@NightRunStudio
@NightRunStudio Жыл бұрын
Some people might dispute me on this, but I like this function in regular update. Fixed Update is used for physics functions like movement because it is regular and thus helps avoid the appearance of lag (always 50frames per second, no matter what), whereas Update can be faster, but also can be slower if your system gets bogged down (leading to laggy-looking movement). So... for movement, you want fixed update as you want your movement to be smooth. For ground checks, however, you want them to just fire as often as possible (smoothness doesn't matter here, as it's not like you will see a graphics lag of the ground check happens to fire a little slower one time). I hope that helps! And, great question by the way.
@sonicskull0072
@sonicskull0072 9 ай бұрын
Ive ran into a problem when fixing my jump, I have fully followed this script but when I press play this error pops up: ArgumentException: Input Button jump is not setup. To change the input settings use: Edit -> Settings -> Input But my character still jumps however the movement is still dodgy like its ignoring the script any help would be appreciated thanks
@NightRunStudio
@NightRunStudio 9 ай бұрын
This means that something went wrong with setting up the jump button. Did you go into the Input Manager and set up a button called jump? Also, make sure that all capitalization matches between your script and the name of the button in the button manager. Hopefully that helps!
@TheTerspet
@TheTerspet Жыл бұрын
hey, i just started getting into unity and found your stuff, question i have right now, i followed along and everythink is working except that when i jump, i can double jump until time runs out wich makes my player jump higher than i want it to ( spamming space basicly) how can i fix this?
@NightRunStudio
@NightRunStudio Жыл бұрын
Hmmn... there's a couple of possibilities here. First, you should only be able to initiate a jump when you are grounded. So if you are double jumping, there may be something wrong with your Ground Check (maybe your circle is too large?) To test this your could make sure your isGrounded bool is set to public, and then try looking at it in the inspector while running your game. Does isGrounded become false after jumping? If not, something is wrong. Another possibility is that there is some mix-up between your GetButton and GetButtonDown lines. It might help to double check these lines of code and make sure they are correct. Hopefully one of those ideas solves the issue for you. Good luck!
@TheTerspet
@TheTerspet Жыл бұрын
@@NightRunStudio managed to find the bug issue, but saying it make me look increadible stupid xD but whatever, maybe it helps someone: the if statement " getbuttonup " was also in the same if statement as the " getbutton " statement, basicly just had to copy getbuttonup statement and paste it 2 lines further down , outside the other if statement just makes it look like im to stupid to follow a tutorial though :(
@NightRunStudio
@NightRunStudio Жыл бұрын
Don’t be too hard on yourself-we’ve all made those kinds of errors! Thanks for sharing your solution-hopefully it helps someone else down the road. Cheers!
@Aces-p
@Aces-p 7 ай бұрын
When i set the ground check circle to 13 i can infinity jump but any less and I can’t jump at all do you know what could be wrong
@NightRunStudio
@NightRunStudio 7 ай бұрын
This sounds like maybe the groundcheck circle is not in the right spot... are you certain that the circle is set to a position directly at the player's feet?
@Aces-p
@Aces-p 7 ай бұрын
@@NightRunStudio i fixed that issue but now any number i put in even 0 i can infinitely jump
@Thatoneguysotherchannel25393
@Thatoneguysotherchannel25393 Жыл бұрын
Hey i was wondering my jump button isnt working I tried doing stuff nothing fixed it does say that its grounded but its not jumping
@NightRunStudio
@NightRunStudio Жыл бұрын
It's hard to know what exactly is happening without more information. My first thought would be to run some debug checks to find out which lines of code are not executing. For example, I would add a: 1) Debug.Log("Jump Pushed"), after the if(isGrounded) line 2) Debug.Log("More Jumping"), after the if(Input.GetButton... line then check if those print in your console. If not.. then it seems like we're having a button problem. If so, the problem is somewhere else.
@Thatoneguysotherchannel25393
@Thatoneguysotherchannel25393 Жыл бұрын
Thank you man i owe you one but i found the issue turns out i added the "isGroundedbool * Time delta time" into a diffrent line of code thanks for the help and i love your tutorials❤
@NightRunStudio
@NightRunStudio Жыл бұрын
@@Thatoneguysotherchannel25393 Glad you figured it out! Good luck with your project.
@project45yt
@project45yt Жыл бұрын
error CS1061: 'float' does not contain a definition for 'ButtonUp' and no accessible extension method 'ButtonUp' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?) What does this mean???
@NightRunStudio
@NightRunStudio Жыл бұрын
Sounds like there is something missing from this line of code. If you want to paste that line I can take a look.
@project45yt
@project45yt Жыл бұрын
@@NightRunStudio using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public Rigidbody2D playerRb; public float speed; public float input; public SpriteRenderer spriteRenderer; public float jumpForce; public LayerMask groundLayer; private bool isGrounded; public Transform feetPosition; public float groundCheckCircle; public float jumpTime = 0.35f; public float jumpTimeCounter; private bool isJumping; // Update is called once per frame void Update() { input = Input.GetAxisRaw("Horizontal"); if(input < 0) { spriteRenderer.flipX = true; } else if (input > 0) { spriteRenderer.flipX = false; } isGrounded = Physics2D.OverlapCircle(feetPosition.position, groundCheckCircle, groundLayer); if (isGrounded == true && Input.GetButtonDown("Jump")) { isJumping = true; jumpTimeCounter = jumpTime; playerRb.velocity = Vector2.up * jumpForce; } if (input.GetButton("Jump") && isJumping == true) { if(jumpTimeCounter > 0) { playerRb.velocity = Vector2.up * jumpForce; jumpTimeCounter -= Time.deltaTime; } else { isJumping = false; } } if (input.ButtonUp("Jump")) { isJumping = false; } } void FixedUpdate() { playerRb.velocity = new Vector2(input * speed, playerRb.velocity.y); } } I see nothing wrong with this :(
@NightRunStudio
@NightRunStudio Жыл бұрын
I think the problem is in your getButton calls. You have written “input” which Unity thinks is a reference to the float your created. What you want is “Input” which refers to Unity’s input system.
@NightRunStudio
@NightRunStudio Жыл бұрын
If you are in safe mode, just restart Unity normally.
@ArkhamSurgeon138
@ArkhamSurgeon138 Жыл бұрын
This Tutorial has been amazing so far and I cannot wait to continue further on, quick question though. For some reason after my character moves for a certain period of time he can no longer jump when I press the space. I'm not sure if I may have misplaced some code, but it does not do it all the time and I can even get my character to jump again. But I can't get him to jump every time, probably sounds super confusing and finally my settings for the Gravity, jumpTime, jumpForce keeps resetting everytime I go to test it. Do I just have to save before hand to keep the settings?
@ArkhamSurgeon138
@ArkhamSurgeon138 Жыл бұрын
Found I was missing a Up in my last GetButton code, but still running into the problem. I can't tell if it's because of my movement that's stopping me from jumping or the isGrounded feature. Trying to inform my situation the best I can, sorry for the long comment Lol
@NightRunStudio
@NightRunStudio Жыл бұрын
@ArkhamSurgeon138 glad you figured it out! Good luck with your project!
@ArkhamSurgeon138
@ArkhamSurgeon138 Жыл бұрын
@@NightRunStudio Um still having the jumping problem, even with the fixed code. Could this have more to do with the code ending the ability to jump while in the air?
@NightRunStudio
@NightRunStudio Жыл бұрын
​ @ArkhamSurgeon138 Sorry about that. I read your last comment on my phone, and it cut off the second half. It's pretty hard to say what's up without looking at your code. That said, my first gut reaction is that your grounding isn't detecting properly. If you watch the grounded bool in your inspector, is it checking the box whenever you land (and unchecking appropriately when you jump)? If we can rule out that problem it will help determine where to go next. Also, feel free to pop into my discord server if you want to share your code. discord.gg/gHerha3h
@ArkhamSurgeon138
@ArkhamSurgeon138 Жыл бұрын
@@NightRunStudio I went to your Discord, I wanted to upload some photos of my character then my script, but it wouldn't let me. Then for some reason I was kicked off the Discord Server. Any reason?
@wagdynavas6337
@wagdynavas6337 2 жыл бұрын
Great job man. I hope to see you channel with more viewers. =)
@NightRunStudio
@NightRunStudio 2 жыл бұрын
Thanks for that! I appreciate the encouragement.
@wagdynavas6337
@wagdynavas6337 2 жыл бұрын
@@NightRunStudio It was nice to watch your last video, It gave me motivation to keep working. I'm a software engineer and I always wanted to build my own game but I always put it aside because I suck as a designer and I don't think I am a good writer too. hehehe. Tks again. Keep up the good work.
A Perfect Jump in Unity - A Complete Guide
17:05
Press Start
Рет қаралды 77 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
The Most Impressive Scratch Projects
11:00
DenshiVideo
Рет қаралды 5 МЛН
Improve your Platformer’s Jump (and Wall Jump) | Unity
8:12
Dawnosaur
Рет қаралды 135 М.
Making a Game About Weak Points
21:27
Emis
Рет қаралды 991 М.
Recreating Super Mario's Jump
9:32
Pontypants
Рет қаралды 70 М.
A Great Way To Setup POWERUPS In Your Unity Game
13:43
Make a game in under 15 minutes! - Unity 2D
14:28
Game Code Library
Рет қаралды 4,5 М.
Much bigger simulation, AIs learn Phalanx
29:13
Pezzza's Work
Рет қаралды 2,9 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН