• 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 question was closed Jun 20, 2014 at 07:44 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
Question by MarvinGo · Jun 19, 2014 at 02:46 PM · boxcolliderrigidbody.velocity

rigidbody.velocity.x also affecting z-axis?

Hi! I'm currently working on a 3D Platformer and trying out some stuff, making very great progress so far. But there's one problem I have:

I have 2 Box Colliders, one on the Player (just for testing) and one on a block. When I now change the velocity of the player on the x-axis while he's standing on a block, he's also moving slightly on the z-axis (this also affects the enemies with box colliders). I already tried it with the player being in the air, and there it's working properly, so I assume the issue must be the 2 box colliders. Of course there aren't any rotations and the gravity is set to default (only y-axis).

Sorry for this noob question, but it really bothers me.

Comment

People who like this

0 Show 2
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 meat5000 ♦ · Jun 19, 2014 at 03:20 PM 0
Share

Is the player collider overlapping the Box's collider? If so the Penalty Force from the corner of the Box is pushing your Rigidbody in the direction the corner is facing.

I have a couple of questions relating to this in my list. Take a look; they were hacked, not solved. It all came down to Skin Widths and Penalty Force.

(I'm calling it Penalty Force - I remember reading this term was applied to the Force applied to separate colliders within each other. I could be wrong; someone please correct me if I am).

avatar image MarvinGo · Jun 19, 2014 at 06:29 PM 0
Share

I tried a lot of stuff, like rotating the block 180° around Y, with the same direction the player is drifting off. For now I ended up with setting velocity.z to 0 during movement - not the most elegant version and will probably give me conflicts soon.

Applying a character controller to my player just mixed everything up - I actually avoided that until now, since I didn't really seem to need it. Is it a "must-have", since you mentioned Skin Widths?

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by meat5000 · Jun 19, 2014 at 06:40 PM

Character controller not essential :)

Try moving the block left then right just a little bit to see if penalty force is kicking in the the edges and corners. Make the box collider much bigger than the player to see if it's still happening.

I was kinda generalising with Skin width. As well as the CC there's also the Penalty Force setting in Physics manager.

Using Rigidbodies and physics will always introduce some kind of error.

If you want it to stick to an axis, try adding a small relative force, proportional to the distance away from target to gently push the Rigidbody back on track.

Comment

People who like this

0 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 MarvinGo · Jun 19, 2014 at 06:58 PM 0
Share

Yep, the relative force is working perfectly. Thank you very much! :)

avatar image meat5000 ♦ · Jun 19, 2014 at 07:03 PM 0
Share

Most welcome

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

My player goes straight through my colider 3 Answers

Big issue with colliders 1 Answer

Best way to check collisions in a 2D Game? 0 Answers

How did I screw up BoxColliders? 1 Answer

Movement stops working randomly 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