speed = transform.rotation * speed; explanation please?
So I was watching this guy on youtube.. He used the code "speed = transform.rotation * speed" to align the rotation of the player object and the camera. You know, so wherever your pointing your camera, that's the player's forward.
Now when I tried this same line of code, I get the error "Operator '*' cannot be used with a left hand side of type 'UnityEngine.Quaternion' and a right hand side of type 'float".
Could someone please explain why this worked on him and not mine? Btw I'm using JavaScript and he's using C#.. If the error is cause by that, could someone please translate that line of code to a JavaScript version.
I know this sounds confusing af, but I'm desperate for answers..
Answer by LLIV · May 21, 2016 at 10:55 PM
are you sure it's just "speed = transform.rotation * speed" and not something like "speed = transform.rotation.z * speed"? that would make a lot more sense.
I just completely redid the code and wrote it differently.. It works now but thanks for the answer anyway.
Your answer
Follow this Question
Related Questions
How do you disallow an angle from going to a certain range while rotating? 0 Answers
How to make a first-person player for my game (like slender or the island demo) 4 Answers
Camera Script remove a part. 0 Answers
Show device camera preview (Android & iOS) 1 Answer
Mathf.Clamp Camera Rotation X Axis 1 Answer