Hey Guys!
I have searched the forums, sorry if this question is already answered else where.
Quaternions are great, I think I have a basic grasp on how to work with those, however let’s say I have a Vector3, and I want to rotate that Vector 30 degrees? So that I can create a bullet at that position.
This is how I am doing it so far, I am wanting to know, is there an easier way to rotate this Vector?
// tempVector is a vector pointing from the player to the mouse cursor
Vector3 createPosition = transform.position + (tempVector.normalized * 0.7f); // transform is the player's position, I want to create the bullet towards the mouse cursor 0.7 units away from the player.
Quaternion tempQ = Quaternion.LookRotation(tempVector); // I now want to find the rotation of this vector
tempQ = Quaternion.Euler(0, 30 , 0) * tempQ; // I now what to rotate the rotation by 30 degrees along the y axis
float angleRadians = tempQ2.eulerAngles.y * Mathf.Deg2Rad; // I now find the radians of this angle
createPosition = new Vector3(transform.position.x + (Mathf.Sin(angleRadians) * 0.7f),1,transform.position.z + (Mathf.Cos(angleRadians) * 0.7f)); //using trigonometry I now calculate the new position which is 30 degrees to the right of my original position
I am using C# and for some odd reason I have had a little difficulty understanding ‘SmoothFollowCamera.js’, as I haven’t found a way to put this code into C# when I do I get complaints about currentRotation being a Quaternion and multiplying it with another type such as Vector3 and a float…
At line 141 of SmoothFollowCamera.js:
// Convert the angle into a rotation, by which we then reposition the camera
currentRotation = Quaternion.Euler (0, currentAngle, 0);
// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = targetCenter;
transform.position += currentRotation * Vector3.back * distance;
Would anyone be willing to help?
Thank you guys! I appreciate it!
David