For anyone confused about the variables, basically a float is a number value, it allows decimals. A int doesn't allow decimals into their value. And the difference between private and public is that private only gives the script the information that the variable has and public allows information that the variable has outside the script, making it being configurable outside the script too.
We came to this one minute tutorial to NOT hear all the explanations (Jk, I'm just teasing- it's always a good idea to understand the variables lol. Thank you)
THANK U SO MUCH BRO this helped so much i have been trying to find a decident jump script for days and i find this vid u helped so much keep up the good work
just add collision, whenever the player is collsion to the ground its ready to jump but whenever the player is not touching the ground its not ready to jump
@@gianlucapapa1508 find other 2dvids bro, 'isjumping' = tru, they put that in the ifstatement. would be cool to keep on jumping tho... Keep on trucking and trying. I only just started and those first steps are soo hard, but allmost there to understand c#... ;-)
heres the script so i can save u $8.50 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerJump : MonoBehaviour { private Rigidbody2D rb; public float jump; // Start is called before the first frame update void Start() { rb = GetComponent(); } // Update is called once per frame void Update() { if (Input.GetButtonDown("Jump")) { rb.AddForce(new Vector2(rb. velocity.x, jump)); } } }
@@unitylearning8736 that's not a better way of doing it, just different. In your example you are overriding the player's velocity, which may not always be wanted. Alternatively you could use AddForce but use ForceMode.Impulse and run it once so it works the same but doesn't override the velocity.
@@Hietakissa Not really overriding the velocity, we are setting velocity to equate to a locked Vector instead of instantiating a new Rigidbody velocity every frame. Say you want to create a variable that controls jump height, you will keep needing to add a new Rigidbody velocity.. Using this method, you can just modify the Vector2. Simple, easy, and much more efficient.
@@unitylearning8736 Yeah I guess I didn't fully read your comment. My point was that if the player were falling and jumped the downwards velocity would have no effect on the jump which may not always be desired, but that could easily be fixed just by setting the y velocity to rb.velocity.y + jumpForce instead. You could also use AddForce, so you still wouldn't be creating a new Vector3 every time you jump. Realistically this won't have any effect on performance but you are right it's better to just set the values of the existing Vector instead creating a new one and generating that 96 or so bits of garbage.
@@ignacio3312 I can create a UA-cam video so that you will learn out of it. Also can create ground check function because I don't believe it is showcased here..
@@slimecraft7620 i might have gotten that wrong do you know where the error line is? Or if you’re lazy like me use chatgpt to check it just throw the code and it will probaly fix it also i have took a long break from unity
For anyone confused about the variables, basically a float is a number value, it allows decimals. A int doesn't allow decimals into their value. And the difference between private and public is that private only gives the script the information that the variable has and public allows information that the variable has outside the script, making it being configurable outside the script too.
We came to this one minute tutorial to NOT hear all the explanations
(Jk, I'm just teasing- it's always a good idea to understand the variables lol. Thank you)
ДА НУ НАХУЙ, Я НЕ ЗНАЛ
THANK U SO MUCH BRO this helped so much i have been trying to find a decident jump script for days and i find this vid u helped so much keep up the good work
This is a life breaker I just got pure errors one after the other
Remember to check your spelling
THANK YOU. Your video is short, but very informative, thanks😊
What about the ground check? Currently you’ can just jump forever essentially flight.
just add collision,
whenever the player is collsion to the ground its ready to jump but whenever the player is not touching the ground its not ready to jump
@@kryuza3191 how can I add it? it's my first time doing it
@@gianlucapapa1508 ua-cam.com/video/ctpExP8GaiQ/v-deo.html&ab_channel=bblakeyyy
@@gianlucapapa1508 hes not gonna answer it since its 4 months old
@@gianlucapapa1508 find other 2dvids bro, 'isjumping' = tru, they put that in the ifstatement. would be cool to keep on jumping tho... Keep on trucking and trying. I only just started and those first steps are soo hard, but allmost there to understand c#... ;-)
Very concise and effective, thank you very much :)
Why do you prefer default force over impulse?
how do i bind the jump key to space? it is not binded to any key just "Jump" which is not a key
Ya idk how to do that
Old input system:
bool isJumping = Input.GetKeyDown(KeyCode.Space);
use this in if statement like
if(isJumping)
Same
"Jump" already has a keybind which is within Unity's built-in Input Manager system, so you shouldn't have to physically bind it through code
i dont want flappy bird
So how do i jump aka how do i do the jump key?
No fixedupdate for jump collision via layers?
When I click on the script in unity the float doesn’t appear but I put in the float what’s wrong?
Be sure that it is public or SerializedField private
Thank you so much ❤
you should add a time.deltatime moltiplication
in this case it would be forcemode.impulse
What is the use of delta time I am new to all this so idk also this method is more simpler
Bro what mine just flyies into the stratosphere
too much jump
Lower the jump value
How can I make it so it won’t fly if you hold it
thank you
Thanks
How to do a dash in a topdown game by using the new input system?
It says that I need a jump input can you help me out😅
Have a full player movement script available on my Patreon: www.patreon.com/BlakeyGames
keep going
can you have tutorial on how to give the caracter animation with that script
Use animation controllers (in the controller use transition arrows, parameters, and conditions)
knowing how to define the jump key would be nice..
Thats Space
pretty sure that's what the Input.GetButtonDown is
you can define it on project settings > Input manager > axes
COOL!
It said cannot convert ‘float’ to ‘string’. Pls help
same for me. I dont know why.
what do you mean about the jump float
He means make the character jump more like a person and less like a balloon
@@annoyingdog9646 no like when he says multiply by the jumjp float
Lifesaver
How do you set the jump key to a mouse click
for a left click its mousebutton 1 and right click mousebutton 2
if (Input.GetKey(KeyCode.LeftMouseButton)
i really never tried to make a game it'll be bad😐
interact
can you please give me the source code?
heres the script so i can save u $8.50 using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerJump : MonoBehaviour
{
private Rigidbody2D rb;
public float jump;
// Start is called before the first frame update
void Start()
{
rb = GetComponent();
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Jump"))
{
rb.AddForce(new Vector2(rb. velocity.x, jump));
}
}
}
can I have the code?
@@unitylearning8736 that's not a better way of doing it, just different. In your example you are overriding the player's velocity, which may not always be wanted.
Alternatively you could use AddForce but use ForceMode.Impulse and run it once so it works the same but doesn't override the velocity.
@@Hietakissa
Not really overriding the velocity, we are setting velocity to equate to a locked Vector instead of instantiating a new Rigidbody velocity every frame.
Say you want to create a variable that controls jump height, you will keep needing to add a new Rigidbody velocity.. Using this method, you can just modify the Vector2. Simple, easy, and much more efficient.
@@unitylearning8736 Yeah I guess I didn't fully read your comment. My point was that if the player were falling and jumped the downwards velocity would have no effect on the jump which may not always be desired, but that could easily be fixed just by setting the y velocity to rb.velocity.y + jumpForce instead.
You could also use AddForce, so you still wouldn't be creating a new Vector3 every time you jump.
Realistically this won't have any effect on performance but you are right it's better to just set the values of the existing Vector instead creating a new one and generating that 96 or so bits of garbage.
@@unitylearning8736 can you change the original code to match your changes?
@@ignacio3312 I can create a UA-cam video so that you will learn out of it. Also can create ground check function because I don't believe it is showcased here..
just as I guessed you're BRI'I'SH
Sherlock has arrived
What do I do with “Assets\playerJump.cs(20,58): error CS1002: ; expected”?
That means I think on line 20 there is no semi colon at the end
@@skycloud97 i tried that and it still doesn't work
@@slimecraft7620 i might have gotten that wrong do you know where the error line is? Or if you’re lazy like me use chatgpt to check it just throw the code and it will probaly fix it also i have took a long break from unity