Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Will21 · Jan 18, 2015 at 10:18 PM · mobilejumpjumpingplaystation

My player falls really slowly and cant jump

I recently got the version of unity for playstation mobile to try and make one of my other games on it I copied and pasted a script but my player wouldnt jump even though the animation was playing and he fell really slowly. My script (sorry it is so long): #pragma strict

 //VARIABLES
 var health : int = 5;
 var Speed : float = 12;
 var Health : float = 100;
 var JumpHeight : float = 15;
 var Skin : GUISkin;
 var AbilityLabelTime : float = 3;
 var Dave : Animator;
 var CanShoot : boolean = true;
 var ShootTakeTime : float = 2;
 
 //Animator Variables
 Dave.SetBool("Jumping", false);
 Dave.SetBool("CollectedSB", false);
 Dave.SetBool("CollectedG", false);
 Dave.SetBool("CollectedMB", false);
 Dave.SetBool("CollectedGevar", false);
 Dave.SetBool("RLEquiped", false);
 
 //Items and ability variables
 var ShowLabelSuperboots : boolean = false;
 var ShowLabelLaserblaster : boolean = false;
 var ShowLabelMegaBoots : boolean = false;
 var ShowLabelGevar : boolean = false;
 var ShowLabelRocketLauncher : boolean = false;
 
 //Collection variables
 var CollectedGun : boolean = false;
 var CollectedSuperboots : boolean = false;
 var CollectedMegaboots : boolean = false;
 var CollectedGevar : boolean = false;
 var CollectedRocketLauncher : boolean = false;
 var RLEquiped : boolean = false;
 var StopTime : float = 3;
 var canJump : boolean = true;
 
 
 //Jump height variables
 var JumpLow : float = 15;
 var JumpMedium : float = 28.5;
 var JumpHigh : float = 38.5;
 
 //Bullet variables
 public var bulletRight : GameObject;
 public var bulletLeft : GameObject;
 public var RocketRight : GameObject;
 public var RocketLeft : GameObject;
 
 function Start () {
 
 }
 
 function Update () 
 {
 
     if (health <= 0) {
         Dead ();
     }
 
     
 
 
 //Jump
 if(Input.GetKey("w") && canJump){
     this.rigidbody2D.velocity.y += JumpHeight;
     Dave.SetBool("Jumping", true);
     canJump = false;
 }
 //Move left
 if (Input.GetKey (KeyCode.A)) 
     {
         transform.localScale.x = 1;
         transform.Translate(Vector3(-Speed,0,0) * Time.deltaTime);
     }
     
 //Move right
 if (Input.GetKey (KeyCode.D)) 
     {
         transform.localScale.x = 1;
         transform.Translate(Vector3(Speed,0,0) * Time.deltaTime);
     }
      
 //Shoot right     
 if (CollectedGun == true && RLEquiped == false){ 
      if(Input.GetKey(KeyCode.RightArrow)) { 
          Instantiate(bulletRight, transform.position, Quaternion.identity);
     }
 }
     
 //Shoot left    
          if (CollectedGun == true && RLEquiped == false){ 
       if (Input.GetKey(KeyCode.LeftArrow)) {
           Instantiate(bulletLeft, transform.position, Quaternion.identity);
         }
     }
     
 //Turning rockets on/off
     if (CollectedRocketLauncher == true && RLEquiped == false && Input.GetKeyDown(KeyCode.R)){
               RLEquiped = true;
               Dave.SetBool("RLEquiped", true);
               gameObject.Find("Rocket").SendMessage("On");
               gameObject.Find("Bullet").SendMessage("Off");
  }
  
 else if (CollectedRocketLauncher == true && RLEquiped == true && Input.GetKeyDown(KeyCode.R)){
               RLEquiped = false;
               Dave.SetBool("RLEquiped", false);
               gameObject.Find("Rocket").SendMessage("Off");
               gameObject.Find("Bullet").SendMessage("On");
  }
     
 //Shoot rocket right    
       if (CollectedRocketLauncher == true && RLEquiped == true && CanShoot == true){
           if (Input.GetKey(KeyCode.RightArrow)){
               Instantiate(RocketRight, transform.position, Quaternion.identity);
               CanShoot = false;
               WaitForShoot ();
           }
       }
       
 //Shoot rocket left
       if (CollectedRocketLauncher == true && RLEquiped == true && CanShoot == true){
         if (Input.GetKey(KeyCode.LeftArrow)){
             Instantiate(RocketLeft, transform.position, Quaternion.identity);
             CanShoot = false;
               WaitForShoot ();
         }
       }
 
 
 
 // JUMPING HEIGHTS
 //Low Jump      
     if (Input.GetKey(KeyCode.Z)){      
               JumpHeight = JumpLow;
                   gameObject.Find("High").SendMessage("Off");
                   gameObject.Find("Medium").SendMessage("Off");
                 gameObject.Find("Low").SendMessage("On");
       }
 
 //Medium Jump    
       if (CollectedSuperboots == true){
               if (Input.GetKey(KeyCode.X)){
               JumpHeight = JumpMedium;
                   gameObject.Find("High").SendMessage("Off");
                   gameObject.Find("Medium").SendMessage("On");
                   gameObject.Find("Low").SendMessage("Off");
           }
       }      
 
 //High Jump     
       if (CollectedMegaboots == true){
           if (Input.GetKey(KeyCode.C)){
               JumpHeight = JumpHigh;
                   gameObject.Find("High").SendMessage("On");
                   gameObject.Find("Medium").SendMessage("Off");
                 gameObject.Find("Low").SendMessage("Off");
           }
       }
 
 }
 
 function OnTriggerEnter2D (other : Collider2D) {
 
  //POWER UPS / ITEMS 
 //Super speed power up
      if (other.gameObject.tag == "SuperSpeed") {    
           ShowLabelSuperboots = true;
          Speed = Speed + 8;
          CollectedSuperboots = true;
          Dave.SetBool("CollectedSB", true);
          WaitAndFalseSuperSpeed ();
          Destroy(other.gameObject);
      }
      
 //Laserblaster power up     
      if (other.gameObject.tag == "Laserblaster") {
          CollectedGun = true;
          Dave.SetBool("CollectedG", true);
          gameObject.Find("Rocket").SendMessage("Off");
           gameObject.Find("Bullet").SendMessage("On");
          ShowLabelLaserblaster = true;
          WaitAndFalseLaserblaster ();
          Destroy(other.gameObject);        
      }
      
 //Megaspeed power up     
      if (other.gameObject.tag == "MegaSpeed") {
          ShowLabelMegaBoots = true;
         Speed = Speed + 10;
         Dave.SetBool("CollectedMB", true);
         CollectedMegaboots = true;
         WaitAndFalseMegaBoots ();
         Destroy(other.gameObject);                 
      }
      
 //Gevar suit power up     
      if (other.gameObject.tag == "Gevar") {
          ShowLabelGevar = true;
          Dave.SetBool("CollectedGevar", true);
          CollectedGevar = true;
          WaitAndFalseGevar ();
          Destroy(other.gameObject);
      }
 
 //Rocket launcher power up     
       if(other.gameObject.tag == "RocketLauncher") {
           ShowLabelRocketLauncher = true;
           CollectedRocketLauncher = true;
           WaitAndFalseRL ();
           Destroy(other.gameObject);
       }
 
 
                
      if (other.gameObject.tag == "Lava" && CollectedGevar == false) {
          Health -= 10000000000000;
      }
  }
 
 function WaitForShoot () {
     yield WaitForSeconds(ShootTakeTime); CanShoot = true;
 }
   
  function OnGUI()  {
      GUI.skin = Skin;
      
      //LABLES AND GUI
      
      
      //Label Super Boots
      if (ShowLabelSuperboots){
           GUI.Label(Rect(100,100,Screen.width,Screen.height),"Super Boots Acquired - These let you move and jump faster, press X to activate, press Z to jump normally again"); 
       }
       
       //Label Laserblaster
       if (ShowLabelLaserblaster){
           GUI.Label(Rect(100,100,Screen.width,Screen.height),"Laser Blaster Acquired - This lets you shoot, left arrow to shoot left, right arrow to shoot right");
       }
       
       //Label Mega Boots
       if (ShowLabelMegaBoots){
           GUI.Label(Rect(100,100,Screen.width,Screen.height),"Mega Boots Acquired - These let you move and jump even faster, press C to use it");
       }
       
       //Label Gevar Suit
       if (ShowLabelGevar){
           GUI.Label(Rect(100,100,Screen.width,Screen.height),"Gevar Suit Acquired - Protects you from lava");
       }
       
       //Label Rocket Launcher
       if (ShowLabelRocketLauncher) {
           GUI.Label(Rect(100,100,Screen.width,Screen.height),"Rocket Launcher Acquired - Press R to switch to rockets press again to switch back");
       }
  }
 
  //Function Super Speed
  function WaitAndFalseSuperSpeed () {
      yield WaitForSeconds(AbilityLabelTime); ShowLabelSuperboots = false;
  } 
  
  //Function Laserblaster
  function WaitAndFalseLaserblaster () {
      yield WaitForSeconds(AbilityLabelTime); ShowLabelLaserblaster = false;
  }
  
  //Function Megaboots
  function WaitAndFalseMegaBoots () {
      yield WaitForSeconds(AbilityLabelTime); ShowLabelMegaBoots = false;
  }
  
  //Function Gevar
  function WaitAndFalseGevar () {
      yield WaitForSeconds(AbilityLabelTime); ShowLabelGevar = false;
  }
  
  //Function Rocket Launcher
  function WaitAndFalseRL () {
      yield WaitForSeconds(AbilityLabelTime); ShowLabelRocketLauncher = false;
  }
  
  //GROUND DETECTOR
  function OnCollisionEnter2D (other : Collision2D) {
      if(other.transform.tag == "Ground"){
         canJump = true;
         Dave.SetBool("Jumping", false);
      }
           if(other.gameObject.tag == "Enemy") {
          health -= 1;
      }
  }
  
  function Dead () 
 {
     Destroy(gameObject);
 }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SaraCecilia · Jan 19, 2015 at 02:31 PM 0
Share

What exactly in your script are you changing to increase your character's speed when falling plus enable it to jump?

avatar image chariot · Jan 19, 2015 at 02:34 PM 0
Share

Try function OnCollisionStay2D

avatar image Will21 · Jan 19, 2015 at 07:16 PM 0
Share

I am just applying force to the rigid body to jump and checking if my player is on the ground

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Jumping in only the direction of the last key pressed 0 Answers

I'm making a 2D mobile platformer and I just figured out how to make the mobile buttons work. But I can't get the jump limit to work. Does anyone know how to create maybe a ground detection with this script? 1 Answer

Hey Guys I have a problem with a single jump script. 1 Answer

Adding a jump feature help? 2 Answers

Sphere can jump, but doesn't stop. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges