• 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 lian · Dec 10, 2012 at 01:24 PM · mecanim

Jump height in the script Mecanim Animation Tutorial

Hello,

I'm sorry I'm a beginner. I try to understand the BotControlScript "Mecanim Animation Tutorial". I tried searching but I did not find how to change the height of the jump in this script?

I know it's something very easy but I would really appreciate if someone could help me ..?

thanks !!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Cassy · Jan 18, 2013 at 06:26 PM

do you got an answer? I'm also looking for that

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 DaveA · Jan 18, 2013 at 06:27 PM 1
Share

No, no answer, except that you 'answered' this question so now it looks like it has been answered. Please use Comment ins$$anonymous$$d of Answer

avatar image lianzam · Jan 19, 2013 at 12:04 PM 0
Share

No sorry, I failed to find a solution ... If you find an answer, I am always taking !! :)

avatar image
0

Answer by Marcurios · Jan 23, 2013 at 06:50 AM

there is no jumpheight variable in the botcontrolscript. the jump animation which is in the tutorial is just that, an animation, there are some tricks to shrink the collider and temporarily set gravity to 0 to make sure the character doesn't fall to the ground when the collider is shrunk.

if you want to be able to put in a jump height you have to built it in yourself by adding a jump function..

i made a playercontroller in Javascript and borrowed some stuff from the botcontrolscript to play the animations from the Animator component. In there i placed a normal Jump function which is executed while the jump animation is triggered by a boolean that is set to true.. If you look at it it might give you an idea on how to accomplish this, provided you know scripting a bit..

 private var moveDirection = Vector3.zero;
 private var grounded : boolean;
 private var targetSpeed : float;
 private var horizontaal: float;
 private var vertikaal: float;
 private var rotatie: float;
 private var anim: Animator;
 
 var animSpeed = 1.0;                                                            // a public setting for overall animator animation speed
 var jumpSpeed = 5.0;                                                            // jumpspeed, also regulates height
 var gravity = 10.0;                                                             // gravity regulates jumpheight and fallback speed
 var walkSpeed = 1.0;                                                            // walking speed
 var runSpeed = 3.0;                                                             // running speed
 var rotateSpeed = 30;                                                           // rotation speed
     
 function Start() {
     anim = GetComponent(Animator);
 }
            
 function FixedUpdate() { 
     horizontaal = Input.GetAxis("Horizontal");                        // setup horizontaal variable as our horizontal input axis
     vertikaal = Input.GetAxis("Vertical");                            // setup vertikaal variable as our vertical input axis
     rotatie = Input.GetAxis("Mouse X");                             // setup rotatie variable as our rotation input axis
     anim.SetFloat("Speed", vertikaal);                                // set our animator's float parameter 'Speed' equal to the vertical input axis                
     anim.SetFloat("Direction", horizontaal);                         // set our animator's float parameter 'Direction' equal to the horizontal input axis 
     anim.speed = animSpeed;                                            // set the speed of our animator to the public variable 'animSpeed'
     targetSpeed = walkSpeed;                                        // set targetspeed to normal walking speed
     currentBaseState = anim.GetCurrentAnimatorStateInfo(0);            // set our currentState variable to the current state of the Base Layer (0) of animation
              
     if (grounded) {
         // We are grounded, so recalculate movedirection directly from axes
         //Determine the player's forward speed based upon the input.
         moveDirection = new Vector3(horizontaal , 0, vertikaal); 
         //make the direction relative to the player.      
         moveDirection = transform.TransformDirection(moveDirection); 
     }
     
     // STANDARD JUMPING    
     if(Input.GetButtonDown("Jump") && grounded && anim.GetBool("Jumping")==false) {
         anim.SetBool("Jumping", true);
         moveDirection.y = jumpSpeed;
     }
                                                         
     // Apply gravity
     moveDirection.y -= gravity * Time.deltaTime; 
              
     // Move the controller
     var controller : CharacterController = GetComponent(CharacterController);
     var flags = controller.Move(moveDirection * targetSpeed * Time.deltaTime);
     transform.Rotate(0, rotateSpeed * rotatie, 0);
     
     grounded = (flags & CollisionFlags.CollidedBelow) != 0; 
     
     if (!Input.GetButtonDown("Jump") && grounded) {
         if(!anim.IsInTransition(0)) {
             anim.SetBool("Jumping", false);
         }
     }                
 }
 
 @script RequireComponent(CharacterController)
 @script RequireComponent(Animator)
 @script RequireComponent(Rigidbody)

I'm still working on it, cause i just started to build a controller so it is going to be much more complicated once finished, but this might be just your luck, cause you say you are a beginner...

you need to have a animation controller linked to the Animator component with a base layer and some linked animations in there, and a boolean parameter called Jumping to trigger the jump animation ofcourse..

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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Send animation playhead to frame 0 Answers

Mecanim add weight to certain animations 0 Answers

Sample Anim Clip at a given time via script 1 Answer

3rd person gta like weapon problem?? 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