I’m trying to write a bit of code that will rotate the Game Object when the right arrow key is held. My code is:
function on_input(self, action_id, action)
-- Add input-handling code here
-- Remove this function if not needed
if action_id == hash("right") then
rotation = go.get_rotation() + vmath.quat(0, 0, 1, 0)
print(go.get_rotation())
go.set_rotation(rotation)
end
end
Whenever I build the game and press the right arrow key, it gives me the error:
Line 39 being where I define “rotation”, and line 35 is the on_input function.
Quaternions is something a lot of users are struggling with. I wonder if we could create a couple of samples in the Examples section where quaternions are used?
I’ve got the rotation thing down, but my idea was to rotate a dynamic collision object. Is there any way to do that, considering you can’t control dynamics?