• 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 MCoburn · Jul 07, 2015 at 12:36 AM · physicsrigidbodycontrollerwater

"Swimming" Physics with Rigidbodies

I've always been stumped when it comes to this question. The best reference I can say is that I want to replicate a swimming physics setup like in Super Mario 64 (1996, Nintendo 64 title for those devs that go "uh?").

In Mario 64's implementation, there's two things I can see - one, the gravity changes to a more "slower" pull down rather than the on-land gravity, and when you press A to swim it applies some upwards momentum, as well as the direction you're traveling - so you end up going forwards on the Z axis Mario's facing (so to speak) and also a little up on the Y axis.

Unlike previous attempts where I killed gravity all together and I'm not doing that again because it caused my character's setup to do barrel rolls, I'm unsure how I would implement it.

I was wondering if anyone had any ideas on how to do underwater physics. I could use Character Controller and manually do gravity, but I perfer to use Rigidbody where possible (as it allows for more dynamic forces, etc). Do I tweak the gravity?

I do apologise for having no code, but I'm just collecting some implementation ideas before I put the pencil to the IDE.

Cheers!

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
Best Answer

Answer by FirePlantGames · Jul 07, 2015 at 12:53 AM

Well. Irrelevant note, but I'm pretty sure every dev knows what you're talking about when you mention SM64. But on topic; I think the best concept is to death the gravity and but keep friction. I don't have code to show for this, but since you didn't provide any, I am not obligated to either :P But that concept is probably your best bet, as this is essentially what SM64 water physics does.

Comment
Add comment · Show 6 · 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 MCoburn · Jul 07, 2015 at 12:57 AM 0
Share

So, i would lower the gravity "pull" (I think the default is like -9.81 in Unity3D physics) to say half that? Seems like a reasonable experiement.

avatar image FirePlantGames · Jul 07, 2015 at 01:40 AM 0
Share

Yep. But also add enough force "upwards" (On a global scale) to keep the consistent falling from pulling to fast and not like your underwater at all.

avatar image darkhog · Jul 07, 2015 at 01:40 AM 1
Share

That, or just increase rigidbody's drag.

avatar image FirePlantGames · Jul 08, 2015 at 02:32 AM 0
Share

Sure you cooould do that if you want to be logical and easy about it.

avatar image kingcoyote · Jul 08, 2015 at 07:22 PM 0
Share

I would highly recommend not changing the gravity from -9.81. Ins$$anonymous$$d, change the rigidbody's gravity scale from 1 to something like 0.25. If you change the global gravity setting, than anything that is above water will also act like it's under water.

$$anonymous$$aybe set the entire water surface as a trigger. When entering the water, set gravity to 0.25. When exiting the water, set gravity back to 1.

Show more comments
avatar image
0

Answer by MCoburn · Jul 08, 2015 at 03:28 AM

Alright, so what I did was increase the drag on the character, to cause it to slow down. So the winner is memorymod with a bonus point to darkhog.

Now... time to implement this with the controller scripts...

Thanks for the help, I appreciate it.

Comment
Add comment · Show 1 · 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 FirePlantGames · Jul 08, 2015 at 07:13 PM 0
Share
  • no problem!

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Character Controller children of a car: Inertia effect, delay effect, what??? 1 Answer

Character controller jittering up and down 2 Answers

RigidBody controller - Where to start? 0 Answers

Looking for some advice for a Horse with Rigidbody 0 Answers

How to use character controller to push down hinge joint properly 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