I struggle a bit with the following prob:
If the user clicks on an image, an animation starts that moves him closer. If he drags the mouse, he starts to rotate.
Now, if he would like to rotate but the input starts on an image, the animation will start, since the click is always first.
So, at the moment, I delay the animation a little bit like so:
function on_input(self, action_id, action)
if action_id == TOUCH then
local pos = vmath.vector3(action.x, action.y, 0)
local cam_pos = go.get_position("camera")
if action.pressed then
self.pressed_position = pos
self.pressed = true
end
if self.pressed then
local distance = vmath.length(pos - self.pressed_position)
-- do not perform a raycast when the player rotates:
-- if distance <= 20, it's a click and raycasting is allowed
if distance <= 20 then
-- only cast a ray when the camera is not raised to look at a painting
if cam_pos.y == self.camera_init_pos_y then
click_counter = click_counter + 1
if click_counter > 12 then
-- code for ray casting, if it hits an image, the animation starts
end
end
end
end
-- code to reset the counter and other variables on release
end
-- code for keyboard input
end
This effectively means a click and hold and the user needs to press longer and harder. This might be a bit irritating.
I could avoid this problem with a FPS rotation where the user rotates when he moves the mouse.
Personally, I don’t like this very much and, personal preferences aside, I don’t think it works too well for my project, way too hectic.
Can someone think of an alternative? I don’t think there is one - but you never now.