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 Gnur · Apr 26, 2015 at 08:35 PM · physics3dcharactergravity

Realistic gravity and physics on a playable character. How?

This has been bothering me for a while now - I have a 3D character, scaled to par with official Unity assets, about twice as tall as a 3D Cube. In order to move this character responsively and for him not to slide like he's using rollerblades, I have "Drag" on his rigidbody set to about 12-13.

But, this makes him actually behave like a feather and any "Drag" value other than 0 makes for severely unrealistic gravity physics, since they don't take into account his mass (which would impact air resistance). You might say "Increase the gravity", but this makes him unable to move at all - until I factor his moving speed by a couple of hundred thousand - in which case the controls are so unresponsive it's unplayable. However, putting Drag at 0 makes it impossible to move the character in any reasonable way using AddForce, as he will accelerate extremely slowly and even still go a lot faster than what he's supposed to once he gets up to speed, then will slide for a while until he eventually stops.

My question is - how are characters supposed to be controlled nicely with realistic physics, without scaling the character to the size of an ant (and thus probably causing its own array of issues)?

Comment
Add comment · Show 1
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 Calum1015 · Apr 27, 2015 at 02:47 AM 0
Share

I think you can change the mass of the player's rigidbody, does that offer a solution?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by kburkhart84 · Apr 27, 2015 at 03:52 AM

Generally, the character is not actually directly controlled by physics. The problem is that for the most part, game characters don't move all physics based like that. Your character would normally be able to accelerate, stop on a dime, turn around, etc... all that is not something a normal physics setup would be able to handle with ease.

Most games that I've seen that are physics based are not moving the character's themselves with physics, rather via normal translation and rotation, unless the character is actually something that should be physically simulated, like a spherical character or similar. You would still have a rigidbody and collider(probably capsule) on the character, but it would be set to kinematic, which allows you to directly control it, and won't let physics affect it, but would let it affect physics. So a box moving down a hill would not push the player with it, rather the player would affect the box, making it stop or go around, depending on the situation. But, static colliders could indeed not let the player go through, while non-static colliders would be affected, example, the player could push boxes around by simply walking into them.

If you insist that the player be physics based, there are some things you can do. Physics properties can be adjusted though scripting, for example the drag and angular drag can change at any given time, as I believe so can the gravity, and other things. So you could have the drag be lower when the character is falling so that it can fall faster, then turn up higher to control movement speed, and whatever tweaks you need to get it right. But just remember that it may be easier to get the player working better with your own movement code instead of the physics engine.

Comment
Add comment · Show 3 · 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 Eno-Khaon · Apr 27, 2015 at 04:25 AM 0
Share

As an added note: While it is true that any living creature must follow the laws of physics, musculature allows living beings to generate forces themselves.

In general, you would probably want a physics-driven character to have very low drag and very low friction, then modify most their motion yourself (for example, when holding no direction, add force against your current velocity to slow down). Bare $$anonymous$$imum, baseline physics would be intended more for simulation of objects than characters.

avatar image Gnur · Apr 27, 2015 at 06:45 AM 0
Share

I see. Yeah, it makes sense that the player generates local forces that the physics engine can't properly account for. Actually turns out Unity changed the Drag through scripting themselves too, in their Viking village sample pack. They set it to 0 when the character was not grounded. That is probably what I'm gonna do then, because any movement scripting with 0 Drag is going to be painful with its current behavior.

But one of my issues with this is that normal physics objects like items and props would need to have these scripted properties too, unless they happen to be slidy objects. Although I can imagine most of them would feel realistic at 0 drag consistently, or so I hope. Thanks for the answers!

avatar image kburkhart84 · Apr 27, 2015 at 05:32 PM 0
Share

Well, most of your objects aren't going to be characters, so they wouldn't need much scripting of physics properties, as they only react to what the character(and maybe a couple other things) do. A crate wouldn't need to change it's drag at all, whether on the ground or not, once you get the values right in the first place. Only things like characters for the most part would need this kind of thing.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

ragdoll head stretching 0 Answers

Can you apply physics to only part of an object? 2 Answers

How can I drag an object with touch on X and Z axis without disrupting the gravity of the rigidbody? 0 Answers

Move ball object based on gravity 0 Answers

Can't get gravity to work on Character Controller 2 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