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 Cyber_Defect · Apr 18, 2013 at 04:27 AM · quaternionaxislookateulerangleslookrotation

transform.right = (point on axis) after using LookAt?

Ok, so I have been fiddling with rotations for quite a while now, and I am getting absolutely NOWHERE when it comes to using LookAt() or LookRotation().

Both of them corrupt the transform.up rotation to always intersect the y-axis. This is cool in theory, however I would rather have the transform.right always intersect the x-axis for my purposes...

Anyone have any suggestions as to how I can accomplish this?

I will include a few screenshots...

alt text

axialcombat.jpg (17.2 kB)
Comment
Add comment · Show 4
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 Cyber_Defect · Apr 18, 2013 at 04:45 AM 0
Share

I saw in a tutorial you could set the forward of an object to equal the forward of the camera to make them look at the projection plane of the camera ins$$anonymous$$d of the camera's actual location...

So why can't I set my objects localeulerAngles.right to Vector3.right and be done with it?

avatar image Cyber_Defect · Apr 18, 2013 at 06:08 AM 0
Share

point of order, localEulerAngles does not have a "right"... it SHOULD. And it should be able to be SET.

avatar image Loius · Apr 18, 2013 at 07:39 AM 0
Share

It's often easiest to just child the rotating object to an empty, spin it a bit, and then use the empty's LookAt.

avatar image Cyber_Defect · Apr 25, 2013 at 09:59 PM 0
Share

Understand that we are talking about boneWeights here Louis. The block above is a basic 1x10x10 wall with 2 bones along the east and west edge. the bones are then told to LookAt() the origin. Unfortunately, the z axis is never rotated, and it leads to some weird deformation.

2 Replies

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

Answer by Cyber_Defect · Apr 27, 2013 at 08:52 PM

I used Vector3.Cross...

Vector3.Cross((Vector3.zero - bones[0].position).normalized, (Vector3.zero - bones[1].position).normalized);

That gives you the appropriate up axis. Then you use:

Quaternion.LookRotation((Vector3.zero - bones[i].position).normalized, (up vector earlier defined)).

I don't want to spell it out, but that's your bones' lookRotation ;)

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
avatar image
0

Answer by robertbu · Apr 18, 2013 at 04:46 AM

I'm not sure this will work for your situation, but I'll toss the idea out anyway. You can split up your look roation into two look rotations on two separate game objects. Think tank with one rotation for the turrent, and a second rotation for the elevation of the gun barrel. You achieve the separate rotation by manipulaing the hit point. For example, for the turret, you bring the hit point down to the level of the turret before doing the the Transform.LookAt(). And for the elevation you would place the point in front of the barrel but at the correct Y height relative to the barrel. In your case, you would use an empty game object. I'm thinking that by splitting the rotation you can isolate/force the rotation around the X axis.

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 Cyber_Defect · Apr 18, 2013 at 05:12 AM 0
Share

I was working on that same concept earlier today, because logically it sounds solid...

However I couldn't think of an eloquent way of doing it. $$anonymous$$aybe I will slap out some code and see what I can do with it.

avatar image Cyber_Defect · Apr 18, 2013 at 06:06 AM 0
Share

Ok, so trying this method will not work. The z axis never gets rotated through because Y always comes first. I tried manually setting the X axis first, but it still jumps to the Y axis before hitting the Z.

It was a decent effort though :(

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

12 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

Related Questions

LookAt on only 1 axis for 2D games? 1 Answer

Rotating on a plane 2 Answers

Quaternion Equivalent of restricting an axes rotation to zero 3 Answers

Turret rotation on one axis problems 2 Answers

Move to the direction of movement, in a mechanic similar to Mario Galaxy... 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