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 The-BOOM · Feb 04, 2012 at 06:50 AM · physicsrigidbodyrotategravitytranslate

Gravity only rigidbody

I want my player's vehicle to be affected by gravity, yet when it moves, I want it to be by a set speed, and I don't want it to be affected by other physics. Should I just use the rigidbody for y direction movement, and restrict everything else, spinning and moving through translating? Or should I manipulate the speed through relative velocity?

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
1

Answer by Owen-Reynolds · Feb 04, 2012 at 06:31 PM

This is exactly what a characterController is for. Assuming you can't use it because the collider is the wrong shape (a real capsule collider can be flipped forwards, like a submarine shape, but the charController one is locked into straight up.)

You can't usefully move an RB with Translate -- translate "goes around" physics, going through solid objects, such as tunneling through hills.

Locking the move dirs makes it so the good way to move an RB (setting velocity,) won't work. It can't tell between the velocity you set and what collisions give. Constraints just ignore all velocity, and you never move.

The simplest way for an RB to "ignore" being hit is to jack up the Mass. Another way is, suppose you always have your set speed in Vector3 myVel;. Update tweaks that and sets rigidbody.velocity=myVel;. So, any velocity you get from collisions is cancelled next Update.

I haven't tried this, but you could also add that to OnCollisionEnter. That might immdediately reset "pushed" velocity before it moves you for even that frame.

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 The-BOOM · Feb 04, 2012 at 06:58 PM 0
Share

Right now, since I'm prototyping, a capsule collider would be fine, but I want to eventually have the player piloting a large mech, so I want to make sure that if someone fires between the arm and body, it doesn't count as a hit, so I can't use one large capsule in the end.

Could I possibly use characterController for multiple noncapsule colliders?

avatar image Owen-Reynolds · Feb 05, 2012 at 08:12 PM 0
Share

CharControllers only really move properly with that one y-axis capsule they give you. The compound collider trick, which works for rigidbodies great, doesn't work for them. You can add more colliders to them, which work fine for other things hitting them, but the built-in move doesn't see them -- they get pushed right through other colliders.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Physics gravity appears very weak 2 Answers

How to make a object jump constantly at y and move to the next position to z (perfectly) 0 Answers

How to make rigidbodies on each side of a cube fall towards the cube? [multiple gravity / addForce] 0 Answers

How can I match Unity's gravity implementation per object? 1 Answer

My objects keep falling through 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