if the function takes an a parameter vector3(10f,30f,60f), I would to able to rotate the object 10 degrees about the x-axis, 30 degrees about the y-axis and 60 degrees about the z-axis.
How can I do this using the transform of the object?
if the function takes an a parameter vector3(10f,30f,60f), I would to able to rotate the object 10 degrees about the x-axis, 30 degrees about the y-axis and 60 degrees about the z-axis.
How can I do this using the transform of the object?
Something like this should do it:
public void RotateEntityByDegreesVector(Vector3 rotateBy)
{
Entity.Transform.RotationEulerXYZ = new Vector3(
MathUtil.DegreesToRadians(rotateBy.X),
MathUtil.DegreesToRadians(rotateBy.Y),
MathUtil.DegreesToRadians(rotateBy.Z));
}
As well as Tom’s answer, if you want to stick to Quaternions for rotation, you can use something like:
public void RotateTransform(Vector3 vector)
{
Entity.Transform.Rotation *= Quaternion.RotationYawPitchRoll(
vector.X,
vector.Y,
vector.Z);
}
And u can use api like Quaternion.RotateAxis() to rotate your object about any axis.