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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by tekke · Apr 17, 2013 at 01:04 AM · physicsgravitymomentum

Setting a jump force on a rigidbody

Hello people, I'm very new in unity so any help will be really appreciated.

I'm making a game about a fish jumping out of the water and doing tricks (like dolphin Olympics).

My player is a game object with a rigidbody, and the water is a plane . when the player is on the water the rigidbody is set to IsKninematic and I move and rotate the player with transform.Translate and transform.rotate , when i get out of the water i use this

 void Update () 
     {
         rigidbody.isKinematic = m_bIsKinematic;
         
         
         //Amount to move
         float amtToMove = playerVelocity *        Time.deltaTime;
         
         // player Movement
         transform.Translate (Vector3.right * amtToMove);
         
 
         
         //rotation
         if (Input.GetKey(KeyCode.Z))
             transform.Rotate(0,0,-rotateSpeed);
         
             if (Input.GetKey(KeyCode.X))
                 transform.Rotate(0,0,rotateSpeed);  
             
         
     }

 void OnTriggerExit(Collider Otherobject) 
     {
              if (Otherobject.tag == "Sea")
             {
             bMove = false;
             collider.attachedRigidbody.useGravity = true;
             
                     //a bool to enable or disable IsKinematic
                     m_bIsKinematic = false ;


             playerVelocity = 0;
             
             }
     }

So when the player gets out it turn off the IsKinematic and the UseGravity is set to Enable and turn to 0 the player velocity .

SO here is the problem . I want to keep the momentum and velocity of my player to perform the tricks but as i set the player velocity to 0 it stop movement immediately. If i left the player velocity running it jumps out and the gravity pull me down but i can move in the jump like I'm still swimming (not like it should be).

Is there a function or a method or to keep my momentum and velocity but controlated by the physics? I just want to move the fish like a truly kumping dolphin. Any help , workaround , comment will be really apreciated. Thanks for your help.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Negagames · Apr 17, 2013 at 01:36 AM

Well it looks like you just need to reverse the effects of the OnTriggerExit function by resetting the settings and velocity once you enter the water trigger, to check for entering the water trigger, simply use OnTriggerEnter

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

12 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

Related Questions

Best way to achieve Sonic style physics? 0 Answers

Gravity on a rotating platform 1 Answer

how to make an object fall slowly ? 2 Answers

How can i rotate player when player jump ? 2 Answers

Roof of the builiding (physics) 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