Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by joe 3 · Oct 14, 2010 at 04:45 AM · camerafps

how can i make my character jump?

what is the script for my character to jump? right now i have it with character conroller but its not jumping.... also if some1 can tell me how to lock the mose so you cant see it that be great.

Comment
Add comment · Show 2
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 mrod9590 · Sep 23, 2014 at 03:55 AM 0
Share

None of these are working for me :/ Can someone post a full player jump script?

avatar image robertbu · Sep 23, 2014 at 03:56 AM 1
Share

Unity Answers does not write or find scripts for you. We answer specific questions to help you write your own code. If you have a specific situation, post your code attempt and all the particulars as a new question.

5 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Brodie Winning · Jan 19, 2011 at 06:48 AM

Try transform.position += transform.up jumpSpeed Time.deltaTime;

That should do it but you need a variable called jumpSpeed and you need gravity on your player or he'll stay in the air.

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

Answer by anilo · Mar 29, 2013 at 08:35 PM

Characters jump up and down along the y-axis.

So, all you ned to do is write a short script in your Update() method so that you can detect the button pressed and then translate that into a movement along the y-axis.

Here's a snippet.

 > function Update () {
 >         if (Input.GetKeyDown ("space")){
 >                 transform.Translate(Vector3.up * 260 * Time.deltaTime, Space.World);
 >         } 
 >} 


Another simple technique is to use an animation controller. Set the transition from walking animation to a jumping animation with a simple bool variable and then your character will play a different animation whenever you toggle the bool value.

Here's a snippet.

 > function Update () {
 >         if (Input.GetKeyDown ("space")){
 >                 myAnimator.SetBool("letsJump", true );
 >         } 
 >} 
Comment
Add comment · Show 2 · 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 senrohit · Jun 30, 2013 at 10:40 AM 0
Share

Dear anilo.. Your code allows jump only at the same place. Suppose if i want my character to jump and cover a certain length, how would it be possible. I only want to use the Jump button.

avatar image Explodinn_Weazle · Jun 26, 2015 at 06:05 AM 0
Share

I used your code but Unity's compilers said this Assets/Scipts/PlayerController.cs(23,36): error CS1061: Type bool' does not contain a definition for SetBool' and no extension method SetBool' of type bool' could be found (are you missing a using directive or an assembly reference?)

avatar image
1

Answer by DigitalCyan · Mar 20, 2016 at 09:33 AM

To lock the mouse just use Cursor.visible = false; in your void Start.

Simple as that :)

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

Answer by pr_0_0_ · May 25, 2020 at 09:23 AM

     #pragma strict
    
     public var jumpHeight : int = 10;
     var inAir : boolean = false;
     
     function Update () {
         if (Input.GetAxis ("Jump") && inAir == false) {
             GetComponent.<Rigidbody>().velocity.y = jumpHeight;
             inAir = true;
         }
     }
     
     function OnCollisionEnter () {
         inAir = false;
     }

The inAir variable will ensure you don't multi-jump.

Comment
Add comment · Show 2 · 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 pr_0_0_ · May 25, 2020 at 09:24 AM 0
Share

Just realised this question was asked 10 years ago. I'm so stupid.

avatar image Skullkidd98 pr_0_0_ · Jul 10, 2020 at 10:14 AM 0
Share

I mean this kinda helps me out because i can get my character to jump but if i hold down the “w” key the character just stays in the air.

avatar image
0

Answer by AliAzin · Oct 14, 2010 at 05:56 AM

Add "FPSWalker" script in standard assets to your character.

Comment
Add comment · Show 2 · 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 joe 3 · Oct 15, 2010 at 01:34 AM 0
Share

i cant island demo did not download i need the scrypt

avatar image AliAzin · Oct 16, 2010 at 10:43 AM 0
Share

it is included in standard package

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

9 People are following this question.

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

Related Questions

I need help with my script 3 Answers

FPS camera script - keeps reverting to 0,0,0 rotation 1 Answer

Camera Height-based crouch script 2 Answers

Camera Bobbing and Stairs 4 Answers

I want to change gun position with my camera joystick 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