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 MikeMan411 · Oct 24, 2011 at 08:33 PM · axismouselookorientationrotatearound

Harry Potter's Wand problem, MouseLook script

Hey Yall, I'm a few months into the Unity3d scripting but I could definitely use some help with some of the movement scripts.

What I'm trying to do: I'm trying to rotate Harry Potter's wand in his hand. When he's in a dark room the end of the wand lights up. I want his wand to rotate at the end that harry's hand touches so that he can move the light around in the dark.

What I'm using:
I've attached a MouseLook script to the wand.

Problem:
The wand rotates around the end of the lighted end instead of rotating around where Harry's hand is. Therefore, instead of the lighted tip pointing at the mouse's position, the handle moves around, opposite to the given mouse coordinates.

Although I have tried moving the wand in different locations, the point that it rotates around stays the same.

Questions:
How do I change the orientation of the mouse look script to rotate around the handle's axis? or: What is the best way to make Harry's wand operate correctly.

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
0

Answer by roamcel · Oct 25, 2011 at 07:58 AM

the transform's rotation is always in terms of world axes so if you have a specific local rotation that you need to apply, you need to:

  • declare a quaternion and store the original object rotation there

  • rotate the object by the intended means and direction

  • multiply the rotated quaternion by the original rotation

This way, you'll actually 'restore' the original axes rotation, in the transformed object.

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 MikeMan411 · Oct 27, 2011 at 06:23 AM

Why would you use a quaternion as opposed to a Vector3 matrix?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Maintain direction regardless of orientation (2) 1 Answer

Transform.RotateAround(Vector3 axis, float angle) - what happens with only two arguments? 3 Answers

What are some strategies for supporting BOTH landscape and portrait mode on mobile? 1 Answer

Mouse looking combined with head bob animation. And key input to play animation 2 Answers

Character changing its orientation randomly while calling the animation through scripting 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