(Unity tutorial) How to make a boost jump (From Bo3) – for beginners!

Updated on April 13, 2017 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
17 on December 4, 2016

Here is a simple tutorial to help YOU make a BOOST JUMP!

    • First, get a Cube GameObject. This will be our player.

    • Add a Rigidbody.

    • Make a c# script.

    • Drag the script to the Cube GameObject.

    • Now for the code!
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 public class PlayerMovement : MonoBehaviour {
 private Rigidbody rb;
 void Start () {
 rb = GetComponent();
 }
void Update(){
if (Input.GetKey(KeyCode.Space)){
rb.AddForce (Physics.gravity * -50 * rb.mass * Time.Deltatime);
//the jumping script
  if (Input.GetKeyUp(KeyCode.Space)){
  rb.AddForce (Physics.gravity * 100 * rb.mass * Time.Deltatime);        
  //the falling script.
  

Now, if we enter play mode and hold square, we will be able to jump SUPER high!

Thanks for reading!
ps: Replace the jump script’s 50 with 25 to create a less high jump and with the falling one, you do the opposite : change 50 to 100, if you want the jump more realistic.
Do the opposite if you want to REACH TO THE STARS!

  • Liked by
  • ThatOtherDog
Reply
2 on December 4, 2016

sorry, it didn’t let me do the whole piece of code in the code format for some reason 🙁

Hope you don’t mind!

Guru
on December 4, 2016

Fixed your code not being included completely.
Make sure to not put code tags in front of a unordered list or:

  • These things (Bulleted List as the forum calls it)

Because that seems to mess it up.

on December 4, 2016

Wow, thank you SO much!

I honestly thought that that was unfixable, but it isn’t! 😀

Show more replies
  • Liked by
Reply
Cancel
3 on December 4, 2016

Have you considered using a character controller? They’re much easier to deal with than rigidbodies.

Wise
on December 4, 2016

There are huge differences. 

Helpful
on December 4, 2016

True, but he has created a playerscript, rigidbodies are messy for that.

on December 10, 2016

I never knew that

Show more replies
  • Liked by
Reply
Cancel
6 on December 4, 2016

This is unnecessary 😉

using System.Collections;
 using System.Collections.Generic;

Guru
on December 4, 2016

Although I would agree on your first point your second two are not quite right.
(Then again System.Collections and System.Collections.Generic are in the default C# script templates from Unity).
 
rb = GetComponent(); Happened probably because it was outside the code block first and got seen as a tag by the forum.
 
For some a putting “private” in front of there variables helps them when coding, even if you don’t do it. A lot of others do and that doesn’t mean it’s a bad practice.

Wise
on December 4, 2016

Ok 😉

But generics namespace is not default.

Guru
on December 4, 2016

Well yeah it is… It gets added to my scripts without me having changed anything to the templates

Wise
on December 5, 2016

Not for me, at least

on December 10, 2016

That’s a weird editor you have…

Wise
on December 10, 2016

What are you even talking about?

Show more replies
  • Liked by
Reply
Cancel
2 on March 4, 2017

Tell me if it worked! I’m pretty sure it did 😛

Wise
on March 4, 2017

You could have just bumped the thread if you wanted to

on April 13, 2017

How do I do that?

Show more replies
  • Liked by
Reply
Cancel