I have a file named mira and want to make it rotate in your base. How to make?
Script
function update(self, dt)
print(go.get_rotation().z)
local rot = vmath.quat_rotation_z(go.get_rotation().z+1)
go.set_rotation(rot)
-- Add update code here
-- Remove this function if not needed
end
1 Like
vmath.quat_rotation_z rotates in radians, so you must convert your value from degrees by using:
math.rad(degree) (https://www.defold.com/ref/math/#math.pi)
so, in your example, that would be:
vmath.quat_rotation_z(go.get_rotation().z + math.rad(1) )
1 Like
His rotation now hangs on 0.017451519146562
Right, I was too quick. go.get_rotation returns a quaternion which is not what you want.
go.get(".", "euler.z")
would give you the euler rotation around the z-axis, which you then can use to increase your rotation as you wanted. You can read more about properties here: https://www.defold.com/manuals/properties/
4 Likes
Great! Now how do I change the origin of the sprite to another point?
1 Like
Managed to change the point, it was something really stupid, but thanks to everyone who helped
3 Likes