Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 stephen_george98 · Apr 27, 2016 at 08:25 PM · unity 5rotationobjectquaternioneulerangles

My Obstacle Rotations Are Not Correct

Hello,

I have these giant meatballs that I want to rotate as they come down my plane; think of a meatball rolling down a mountain, rolling straight at you.

I have this script I wrote that I believe should be working correctly and doing what I want, but it is not.. Here it is:

 using UnityEngine;
 using System.Collections;
 
 public class MeatballMover : MonoBehaviour {
 
     private Rigidbody rb;      //Reference to Rigidbody Component
 
     public float speed;        //Speed, updated through script
     public float acceleration; //Every second, the speed will increase by this much
 
     public float spinSpeed; // speed at how fast I want the meatball to rotate
 
     //Executes once, when object is spawned / scene loaded
     void Start() {
         //Get reference to rigidbody, and set the speed
         rb = GetComponent<Rigidbody> ();
         rb.velocity = -transform.right * speed;
 
 }
     //Executes every frame
     void Update() {
 
         // Rotate the meatball to make it look like it is rolling down
         transform.Rotate(Vector3.left, spinSpeed * Time.deltaTime);
 
         //Add acceleration to speed, make sure it's not above topSpeed)
         speed += Time.deltaTime * acceleration;
         //Set object velocity
         rb.velocity = -transform.forward * speed;
 
 
     }
 }

alt text alt text

Instead of rotating in place, down my plane, they rotate around each other; almost like a black hole is in the middle and they go around it; or someone stuck an Axle in the middle and they are going around it. Can someone explain what is happening? Thank you

screen-shot-2016-04-27-at-21919-pm.png (142.6 kB)
screen-shot-2016-04-27-at-21928-pm.png (138.3 kB)
Comment
Add comment · 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 Leuthil · Apr 27, 2016 at 08:50 PM 1
Share

If you are using rigidbodies you shouldn't have to "fake" them rolling... you can simply apply a torque force which will make them rotate and the friction of rotating from the torque will move them like you would expect in real life.

http://docs.unity3d.com/ScriptReference/Rigidbody.AddTorque.html

Look into the two different Force$$anonymous$$ode's as you may want Force$$anonymous$$ode.Impulse ins$$anonymous$$d of the default.

avatar image stephen_george98 Leuthil · Apr 27, 2016 at 10:33 PM 0
Share

I also tried using Torque, but to no avail :/.

I also played around with the pivot points and that did not solve the problem. :/ But I think I cracked the main problem... In my Update function, I do not think what I wrote on line 24 is getting along with my code on lines 27 and 29. I know this because I did some trials on the same Prefab but I did not attach the $$anonymous$$eatball$$anonymous$$over Script. I am sure it is the logic of my rigidbody in my update function. Do you have any idea on how to combine my update function so as to make everything "get along".? I know that is a complete new question in itself, so I may have to post it again. Thank you! :)

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to get Angle float of specific axis.(Turret clamping related). 2 Answers

When applying a 90 degree rotation to Euler Angles, it is over/undershooting sometimes.. 2 Answers

Smooth rotation in 90° increments 0 Answers

[OAFAT]Why does transform.rotation.x = 45 not work 3 Answers

Snap the rotation 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