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 mmd2sh · Jun 10, 2016 at 09:06 PM · physicsrigidbodycuberoll

How to Roll a Rigidbody Cube one step?

Hi. I'm trying rolling a cube with Horizontal inputs. i used "AddTorqe" , but after a while its flying in the air. i don't want that. i want to roll a cube like its heavy (not too heavy) and step by step. and when its in the middle of rolling to the right , its turn back when i press left key. and when i release the keys in middle of rolling, physics push it to the correct direction. alt text i'm using this code. but no luck:

 using UnityEngine;
 using System.Collections;
 
 public class rotate : MonoBehaviour {
 
     public float torque = 100;
     public Rigidbody rb;
 
     void Start() {
         rb = GetComponent<Rigidbody>();
     }
     void FixedUpdate() {
 
         float turn = Input.GetAxis("Horizontal");
         rb.AddTorque(transform.up * torque * turn);
     }
 }

maybe code is good, but not the other setting like (torque , gravity, Mass , Drag , Angular Drag...). i don't know.

Any help will be appreciated.

box.jpg (26.8 kB)
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

2 Replies

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

Answer by JatsArts · Jun 12, 2016 at 01:20 PM

A quick and dirty solution is to add a physics material to the cube and increase the physics materials friction property.

Unity Doc: Physics Material

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 mmd2sh · Jun 13, 2016 at 08:58 AM 0
Share

Thanks . that helps. but still dosn't feel like its heavy. its rolling fast and when its do rolling a while, some times its get airborne. adding material friction is improve physics but increasing any of frictions dosn't affect anything.

avatar image Eno-Khaon mmd2sh · Jun 13, 2016 at 09:34 AM 1
Share

Perhaps couple the friction with AddForceAtPosition()? Your image example hints at how it could be utilized -- If you apply the force higher up on the cube, it would effectively be like pushing near the top, rather than pivoting perfectly around the center of the cube.

avatar image
0

Answer by thomasfriday · Jul 10, 2021 at 03:30 PM

Here's a short Youtube video that covers exactly how to roll a cube on its edges: https://youtu.be/06rs3U2bpy8


rolling cube

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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I make a cube rigidbody pushable by the default 3rd person character controller without tilting and going left and right? 0 Answers

Cube roll over hills/objects 2 Answers

Make a rolling ball always on ground without falling when reaching the edges of the map 1 Answer

Rolling Cube with Rigidbody? 5 Answers

Freezing movement on Z axis. 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