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 not a dinosaur · Jan 17, 2013 at 02:48 PM · physicsfriction

Freezing rotation breaks friction for BoxColliders

I have a pretty simple 3d scene with a box collider representing the player on top of a large, flat, and planar box collider. When I apply force on the player's rigidbody purely on the positive x-axis, I also get positive motion on the z-axis. When I apply force purely on the positive z-axis, I also get motion on the positive x-axis. Finally, when I apply force purely on the negative z-axis, I also get motion on the negative x-axis.

I'm a beginner to unity, so it's possible I'm overlooking something stupid. I would expect that when I apply force on one axis, I wouldn't see motion on another. This effect is absent without gravity, so I guess it's due to friction. Is this an unavoidable side effect of the physics engine?

I'm applying the force simply as follows:

 void FixedUpdate() {
     myRigidBody.AddForce(Vector3.right * Input.GetAxis("Horizontal") * WALK_FORCE);
     myRigidBody.AddForce(Vector3.forward * Input.GetAxis("Vertical") * WALK_FORCE);
 }

Update: Disabling useConeFriction on the player's rigidbody as well as increasing the physics iteration count in the project settings greatly reduces this effect, although it's still present

Update 2: I believe this is a bug with the way rotation is frozen in the physics engine. I have uploaded a demonstration of this issue here. Use WASD to move the two objects in the scene. If you watch the box object in the Scene Hierarchy, you will see that as you move it back and forth along one axis, it will also move on the other. If you watch the sphere object, you will see it does not have this effect.

bug report orthogonal movement.zip (140.6 kB)
Comment
Add comment · Show 3
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 not a dinosaur · Jan 19, 2013 at 12:01 AM 0
Share

This appears to be due to the fact I've frozen my Rigidbody's axes of rotation. Is it not possible to have a nonrotating BoxCollider move properly over a planar collider?

avatar image sdgd · Jan 19, 2013 at 12:53 AM 0
Share

if you want to have the character in physics yes it is

but you can make your character ignore all physics

and rigidbody set to ignore gravity forgot some more things but this is basic principle

try

float X = Input.Getaxis("Horizontal")

float y = 0;

float z = 0;

transform.Translate (X,Y,Z);

avatar image sdgd · Jan 19, 2013 at 12:56 AM 0
Share

in addition you can try 2 very good $$anonymous$$chers:

most recommended: https://www.youtube.com/watch?v=zraYNRX54A4 don't worry he $$anonymous$$ches all stuff from beginning

https://www.youtube.com/watch?v=0Tl1Cc0IRnI&list=UUPXOQq7PWh5OdCwEO60Y8jQ∈dex=34

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by iwaldrop · Jan 19, 2013 at 12:57 AM

You can do what you're talking about, but you aren't going to want to apply a force. You're going to want to directly translate the transform -- aka controlling your rigidbody via kinematics. Check the box marked 'is kinematic' on your rigidbody and try the following.

 transform.position = transform.Translate(Vector3.right  * Input.GetAxis("Horizontal") * WALK_FORCE);

And go ahead and give it a shot without that box checked. I forget if the box will still want to be fricative or not, but if it doesn't then at least you can still bump it around using physics.

Also, you might experiment with changing Vector3.right/forward to transform.right/forward. They mean totally different things and will produce very different results depending on the orientation of your rigidbody. I hope that helps you. Enjoy!

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 not a dinosaur · Jan 19, 2013 at 01:05 AM 0
Share

Thanks for your response. In my project, no objects can rotate. The player may have to push boxes around a room, for example. Even if I control the player as a kinematic rigidbody, when he interacts with these boxes I will again see the same effect.

To me, this sounds like a bug in the way rotation is frozen. It seems like the cube is actually rotating a bit, incurring forces due to that rotation, and then it's rotation is reset at the end of the physics frame. For example, with a sphere I do not observe this effect...

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

11 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

Related Questions

How to make moving objects stack, without sliding over each other? 0 Answers

Calculating required force for pushing a body to a desired position at once 0 Answers

What is the appropriate value of Friction Direction 2? 1 Answer

How can I change friction of a Physic material in script? 1 Answer

Angular Friction 0 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