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 /
  • Help Room /
avatar image
0
Question by Animus428 · Nov 09, 2016 at 03:45 PM · physicsrotatetorque

Why doesn't a cube move when resting on a rotating cylinder?

I have a dozen or so cylinders that each rotate using the transform.rotate to simulate rolling, and then a cube drops on top of them but the cube doesn't move in the direction of the rolling cylinders.

The cylinders are kinematic, so they stay in place and gravity isn't applied. Both the cube and rollers have rigid bodies.

I've come to understand moving via transform tends to negate physics, so I tried to apply torque to the rollers in order to get them moving but following the code in the API nothing spins.

Anybody know what may be going on? I have a cheater script that detects if the cube is on a platform and applies force to simulate a set of rollers, but i'm looking for a more realistic solution. If only one corver of the cube is touching, I want just the corner to move and not the entire cube as the cheater script causes to happen.

I tried the code here link texthttps://unity3d.com/learn/tutorials/topics/physics/adding-physics-torque but if i got it working I only need the cylinder to roll in place.

Comment
Add comment · Show 5
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 doublemax · Nov 09, 2016 at 05:37 PM 0
Share

Both objects need colliders and a physics material assigned to the collider. Then you should get the behavior you want.

avatar image Animus428 doublemax · Nov 09, 2016 at 06:50 PM 0
Share

I believe they both have colliders but not sure about a physics material. I'll check that when I get home.

avatar image Animus428 doublemax · Nov 09, 2016 at 09:28 PM 0
Share

One of the objects didn't have the material assigned to the collider, but doing that didn't make a difference on things when I use Transform.rotate in order to rotate the cylinders. I updated below with the code using addTorque.

avatar image doublemax Animus428 · Nov 09, 2016 at 10:00 PM 0
Share

Don't make the cylinders kinematic. Ins$$anonymous$$d use constraints in the Rigidbody component and lock their position and all axis except the one they're rotating around.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Animus428 · Nov 09, 2016 at 05:12 PM

Sorry, to clarfiy - Even if I got the addtorque to work, what I need is for the cynlinders to roll in place (i.e. rotate on the X axis) and not move. Their rotation needs to cause the cube that lands on them to move according to their rotation though; just like a conveyor belt.

 using UnityEngine;
 using System.Collections;
 
 public class RollerScript : MonoBehaviour {
 
     public float speed;
 
     // Use this for initialization
     void Start () {
         speed = 50.0f;
     
     }
 
     void wake(){
 
     }
     
     // Update is called once per frame
     void Update () {
 
         //transform.Rotate(Vector3.up, speed * Time.deltaTime);
         float h = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
         float v = Input.GetAxis("Vertical") * speed * Time.deltaTime;
 
         GetComponent<Rigidbody>().AddTorque(transform.up * h);
         GetComponent<Rigidbody>().AddTorque(transform.right * v);
     
     }
 }
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

109 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 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

Rotating an object with VR controller 1 Answer

Cant find how to use InertiaTensor 0 Answers

Rigidbody AddTorque unexpected behavior on one axis 0 Answers

X-Axis rotation quirk 0 Answers

Preventing torque on a child from affecting the parent when attached by a joint 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