Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 csgeorge · Jan 20, 2016 at 09:41 PM · c#physicsrigidbodydrag

Can I Prevent Rigidbody Drag from Affecting the Z-Axis?

I'm currently using Drag in my player gameobject's Rigidbody to limit how far the player is pushed after being struck with a moving projectile. However, this is also affecting the player's jump function, causing it to sort of glide in the air as the drag makes it descend slowly. Is there a way I can prevent the drag from affecting the z-axis so this doesn't happen? Or perhaps another way to limit the push from projectile collisions so I don't need to use drag at all?

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 Fattie · Jan 20, 2016 at 10:15 PM 0
Share

Try playing with the Physic$$anonymous$$aterial of both your player, and the objects hitting the player

2 Replies

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

Answer by Owen-Reynolds · Jan 21, 2016 at 03:33 AM

Drag is just multiplying velocity by almost 1. You can set Physics drag to 0 and apply drag yourself in FixedUpdate. I do things like this when I need a particular "feel":

 Vector3 vel = GetComponent<RigidBody>().velocity;
 vel.x*=0.98f; vel.y*=0.98f;
  GetComponent<RigidBody>().velocity = vel;

Then you can do little tricks, like increasing it after you've flown for a second or more:

 float drag=0.98f; if(Time.time+1.5f>lastBumpTime) drag=0.95f;
 // apply drag:
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
avatar image
0

Answer by csgeorge · Jan 21, 2016 at 05:20 PM

Thanks for your suggestions, but I found the most effective solution- for my case at least- is to just use Drag and change the physics.gravity of the desired axis to essentially cancel it out.

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 Owen-Reynolds · Jan 21, 2016 at 05:32 PM 0
Share

If you look at changing gravity threads here, they describe a possible problem with that -- everything else also falls faster. So you're back to using code, but this time to increase your own gravity (I think2D has a personal gravity scale, but not 3D.)

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

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

Related Questions

Rigidbody character controller can't walk on stairs 0 Answers

Multiple Cars not working 1 Answer

Touch controlled ice puck 0 Answers

Rigidbody.SweepTest Hit Trigger Colliders 0 Answers

What is the best way to prevent a physics object from going through thin colliders? 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