- Home /
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.
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.
Answer by MikeMan411 · Oct 27, 2011 at 06:23 AM
Why would you use a quaternion as opposed to a Vector3 matrix?
Your answer
Follow this Question
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