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 commodore · May 31, 2012 at 01:15 AM · rigidbodyvelocityjump

Getting rigidbody to jump by changing the velocity

Hello, I'm trying to get my character to jump by changing the velocity along the y axis. I'm making a simple snowboard/skiing game so the character slides down a hill and the velocity keeps going down as well. I'm able to get him to jump a little when he's going slow down the hill, then as he speeds up he jumps higher and higher. And then when he's going up hill, he seems to want to jump down instead of up. How do I fix this so that he jumps the same amount regardless of how fast he's going or if he's going up or downhill. Thanks

 if (Input.GetButtonDown ("Jump")) 
 {
     rigidbody.velocity.y = 2;
 }
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
2
Best Answer

Answer by whydoidoit · May 31, 2012 at 01:35 AM

So firstly he's already got a Y velocity that you are just overwriting :) Hence the weirdness...

You could add something to his velocity:

  rigidbody.velocity = rigidbody.velocity + Vector3.up * 2;

Or you are probably better adding a force:

  rigidbody.AddForce(0,10,0);

Bear in mind that rigidbodies are simulated in World space - for instance adding to the Y on an inverted character will not move it towards the head, but the feet - not that this is probably your issue right now, just for reference. If you want to simulate force in the character's coordinates it's rigidbody.AddRelativeForce(0,10,0)

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 commodore · Jun 01, 2012 at 03:21 AM 0
Share

YES! That works! And I do want him to jump in up in world space. It's so that when I get to making a half pipe, he'll jump out and not away from the wall.

avatar image Bunny83 · Jun 01, 2012 at 03:23 AM 0
Share

@commodore: You posted an answer, but that isn't an answer to the question above. I've converted your answer into a comment.

avatar image
0

Answer by lqvinh2 · Jun 05, 2018 at 07:14 AM

I take player collider with enemy when using UNET. but not working.

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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Jumping from a conveyor belt with added velocity 0 Answers

rigidbody.AddForce jump, different heights each time 1 Answer

Setting Rigidbody Velocity for Jump Unity 5 0 Answers

ForceMode.Impulse Doesnt always fire. 2 Answers

how to limit horizontal input when jumping 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