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 ytwithlove · Apr 10, 2013 at 10:45 PM · charactercontrollerplayer movementcharacter controller

Player not responding to Jump Input

(I'm really new at Unity! Please be forgiving!) I'm working on a tutorial series where I have the Character Controller scripted to do some basic movement with the arrow keys and WASD with the spacebar set to make the player jump. Everything works except the jump. Not really sure how to fix this. Any ideas? Here's my code:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMovement : MonoBehaviour 
 {
     CharacterController _controller;
     
     [SerializeField]
     float _moveSpeed = 5.0f;
     
     [SerializeField]
     float _jumpSpeed = 20.0f;
     
     [SerializeField]
     float _gravity = 1.0f;
     
     float _yVelocity = 0.0f;
 
     // Use this for initialization
     void Start () 
     {
         _controller = GetComponent<CharacterController>();
     }
     
     // Update is called once per frame
     void Update () 
     {
         Vector3 direction = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
         Vector3 velocity = direction * _moveSpeed;
         
         if (_controller.isGrounded)
         {
             if (Input.GetButtonDown("jump"))
             {
                 _yVelocity = _jumpSpeed;
             }
         }
         else
             {
                 _yVelocity -= _gravity;
             }
         
         velocity.y = _yVelocity;
         
         _controller.Move(direction * Time.deltaTime);
     }
 }        
 

 
Comment
Add comment · Show 4
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 tss · Apr 11, 2013 at 12:42 AM 0
Share

I don't know if this will work. its just a guess but try capitalizing your string jump. ID$$anonymous$$ if I am right or wrong.

avatar image Graham-Dunnett ♦♦ · Apr 11, 2013 at 11:46 AM 0
Share

What things have you tried to make this work? When you say the jump doesn't work, what happens.

avatar image ytwithlove · Apr 14, 2013 at 02:24 AM 0
Share

@tss: Tried that. Sadly it didn't work.

avatar image ytwithlove · Apr 14, 2013 at 02:28 AM 0
Share

@Graham Dunnett: I've tried a few things. I tried to change the placement of the model in the scene. $$anonymous$$oving it farther down to the ground only resulted in the character controller moving up to the top of the ground with a key press from the arrow keys or WASD with the spacebar still not working. I tried to change the move and jump speed values in the code and in the inspector with no success. Not really sure what else to change.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Vonni · Apr 11, 2013 at 03:11 PM

This is something you need to get used to

A good technique is to add

 // Add inside Input.Getbutton brackets
 Debug.Log("My jump velocity when I jump is: " + _jumpSpeed);

Doing checks like this along the code will help you find where something is going wrong.

Also check if your _jumpSpeed variable in the inspector is 0 or something. Values in the inspector(unity editor) thrump any values inside the code.

Comment
Add comment · Show 5 · Share
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 ytwithlove · Apr 14, 2013 at 03:00 AM 1
Share

Thanks for the help Vonni! I tried to debug and I got the value I put in for the jump speed but the character controller still isn't responding. I'm actually getting a new error now. It says this:

UnityException: Input Button jump is not setup. To change the input settings use: Edit -> Project Settings -> Input Player$$anonymous$$ovement.Update () (at Assets/TheGame/Scripts/Player$$anonymous$$ovement.cs:34)

I followed the tutorial for what it wanted code wise but I'm not sure what to change. Tried to change the input name in the Project Settings but it didn't work. Any ideas?

avatar image Vonni · Apr 15, 2013 at 12:38 AM 0
Share
 if (Input.GetButtonDown("jump"))

Change to:

 if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
avatar image ytwithlove · Apr 15, 2013 at 02:16 AM 0
Share

Unfortunately there was no change. Should I just delete the character controller and try again with a new game object? I have a feeling it won't do any good since I'm going to use the same code and get right back to where I started.

avatar image Vonni · Apr 15, 2013 at 10:11 AM 0
Share

Then I don't know, start from scratch again or something

avatar image ytwithlove · Apr 15, 2013 at 02:49 PM 0
Share

Yeah I had a feeling I would have to start again. Here's hoping it works the second time around. Thanks for your help though! I really appreciate it! :)

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

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Character Controller doesn't always follow it's parent position? 0 Answers

Strange Character Controller Behavior Caused by Simulated Gravity and Ground Check 0 Answers

,How to fix Crouch and Sprint Code (C#) 0 Answers

Character Creeping Backwards 0 Answers

Character Controller "walking on air" off cliffs/slopes 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