Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by lightpower26 · Jun 08, 2016 at 05:28 PM · charactercontroller

Why won't my character jump? [JS]

I found a script on the Unity Scripting Reference that was very useful for my FPS system. It allowed me to make my character move forwards, backwards, left, and right using the Horizontal and Vertical axes. I then added in a lot of things like jumping, looking around, and loading a new map.

I've pretty much abandoned that project and started a Third Person system. It works pretty well, until you jump. Nothing happens sometimes, but there are rare occasions where you'll jiggle around when you "jump." I investigated the problem and found that the controller won't say the character is grounded. Here's a little video that shows my problem. (On-Screen Keyboard shows that I'm sure I'm hitting the spacebar)

Here's my JavaScript:

 //Public Variables
 public var walkSpeed : float; //Set to 16
 public var jumpPower : float; //Set to 10
 public var rotSpeed : float; //Set to 5
 public var playerCamera : GameObject; //Set to the Camera
 public var failedCanvas : GameObject; //Set to a UI. Not relevant
 public var normalCanvas : GameObject; //Set to a UI. Not relevant
 public var upperTorso : GameObject; //Set to the upper part of the Character's Torso
 //Private Variables
 private var gravity : float = 400.0; //Effects how fast the player falls
 private var moveDirection : Vector3 = Vector3.zero;
 private var origWalkSpeed : float = 0;
 function Start(){
     //Cursor.visible = false;
     origWalkSpeed = walkSpeed;
 }
 
 function FixedUpdate(){
     var controller = GetComponent.<CharacterController>();
     var animController = GetComponent.<Animator>();
     moveDirection = transform.TransformDirection(Vector3(-Input.GetAxisRaw("Horizontal"), 0, -Input.GetAxisRaw("Vertical"))) * walkSpeed;
     if(Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0){
         animController.SetBool("Walking", true);
     } else {
         animController.SetBool("Walking", false);
     }
     if(Input.GetButton("Jump") && controller.isGrounded){
         print("Jumping");
         moveDirection.y = jumpPower;
         animController.ResetTrigger("Jump");
     }
     if(Input.GetButton("Run") && (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0)){
         animController.SetBool("Running", true);
         walkSpeed = origWalkSpeed*1.5;
     } else {
         animController.SetBool("Running", false);
         walkSpeed = origWalkSpeed;
     }
     if(!controller.isGrounded){moveDirection.y -= gravity * Time.deltaTime;}
 }

I don't see why it should work any different than my FPS system. It worked fine (Still does in the FPS system) and my character has the same setup. When I added print(controller.isGrounded); all I got was a console of falses. Here's a picture of my character setup

Why isn't it grounded? I'm not falling through the floor... or floating on the floor.

Comment
Add comment
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to move my rigid body in the direction my model is facing. 0 Answers

Gravity To CharacterController 0 Answers

Question on Unity5 CharacterController performance/efficiency 0 Answers

Making a 2D platformer, where am I going wrong? 0 Answers

CharacterController gets stuck between two or more box colliders 0 Answers


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