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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
2
Question by I9ball · Sep 13, 2012 at 01:21 AM · relativevectorsaddtorque

Parent transform forward as reference then need to ADD Torque to that

I am having trouble wrapping my head around a solution for this.

I am attempting to add torque to a sphere using the direction of its parent (camera) as the starting point. My trouble has been trying to add the torque vector to the vector forward of the cameras transform. I know this is easier than I'm making it.

My code is a mess from too many edits... If anyone has a code snippet in C#, I would be eternally grateful!

Thanks ahead of time! Answers is awesome!

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 I9ball · Sep 15, 2012 at 01:54 AM 0
Share

LOL, no I'm not a physicist, nor am I a rocket scientist, but I am familiar with the ter$$anonymous$$ology, etc. Thank you for clarifying, one never knows who's on the other side.

Lemme fill in some details to shed some light on my specific application.

I created a "roller controller where torque is the sole driving force of movement. ( I must say its fun as heck to play with lol) I currently have 3 ways to control the sphere:

Right mouse to orbit camera around sphere... At any time...

  1. WASD ( adds appropriate torque relative to view

  2. Left mouse button down and held while the right button is also held gives simple torque in direction of view (camera)

  3. Click and drag left mouse button - creates a user defined direction to spin the sphere. The mouse down sets point1 and point2 is sampled every frame on update. So the torque vector is created from the updated mouse position relative to stationary point1.

The strength of the torque applied is dictated by the distance ffrom point1

I.e. torque is applied in the direction mouse has been dragged and magnitude is how far they have dragged from where they clicked.

The third one works beautifully ( and I almost had a party when I got it working right) but as long as the camera hasn't been rotated! To be useful, it needs to be relative to the view direction like the first two methods.

So with the explanation, does the camera need to be parented, or can it be independent, AND how will that help with view control? Also it is nice to just grab the parent and move it around.....

BTW thank you for taking the time to help! I truly appreciate it!

avatar image I9ball · Sep 15, 2012 at 01:55 AM 0
Share

Here's a link to my original post

http://answers.unity3d.com/questions/294451/making-a-torque-based-sphere-controller-by-simple.html

avatar image I9ball · Sep 15, 2012 at 10:16 PM 0
Share

Okay, not parented... But what is the reasoning?

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by aldonaletto · Sep 13, 2012 at 05:30 AM

Well, you could try something like this:

   rigidbody.AddTorque(transform.parent.forward * someTorqueValue);

But be aware that rigidbodies are wild! They rarely do what you expect without doing lots of annoying unexpected things. The instruction above, for instance, will make the object rotate around weird axes during some time before finally settling down to the desired rotation, and any parent rotation will start another disappointing weird sequence. Parent movements also aren't immediately followed by the child rigidbody, which will move exasperating slowly in the movement direction - not to mention other movements in unexpected directions that will result from this.
If you simply want to rotate an object around the camera's forward direction, avoid rigidbodies and simply use Rotate - like this:

public float rotSpeed = 360;

void Update(){ transform.Rotate(0, 0, rotSpeed * Time.deltaTime); } This code rotates the object around its forward direction. If the object's initial localRotation is Quaternion.Identity (Rotation field = 0,0,0 in the Inspector), it will rotate always around the parent forward direction, no matter to which direction the parent is turned to.

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 I9ball · Sep 15, 2012 at 01:58 AM 0
Share

Actually, I've experienced beautiful results upwards and above angular velocities of 200+ lol !

Really fun to skid out with a sphere and jump ramps..... I'll post a link when I have a fully working scene.

Thanks for the code the first snippet may just help

avatar image I9ball · Sep 29, 2012 at 02:18 AM 0
Share

Thanks for the insights on this! $$anonymous$$uch appreciated! I imagine I havent yet experienced these types of issues because Ive only been doing noob stuff, lol thanks again!

avatar image
0

Answer by I9ball · Sep 18, 2012 at 09:48 PM

Thanks for the explanation! Sorry about the large bold text in the previous comment, :p.

Got it. So then we would simply use scripting to follow an object with a cam and similar instances?

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 I9ball · Sep 29, 2012 at 02:08 AM 0
Share

sorry took so long for the tick.... internet has been troublesome. thanks for the great responses everyone!

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

SImply yet tricky question about RELATIVE VELOCITIES... 1 Answer

gui position of Screen relative position 2 Answers

Relative Accelerometer Movement 0 Answers

Place object relative to player location 1 Answer

Reletive rotation problems. (C#) 2 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