Hello, I faced a problem regarding on_input function.
In my Project i have external crosshair object (it’s movement linked with mouse movement but it isn’t mouse).
My go Player handles player movement and this object movement.
function update(self, dt)
--MOUSE
if self.past_one==true then
self.ch_pos = go.get_position('crosshair')
self.ch_pos = self.ch_pos + self.mouse_change * dt * 50
go.set_position(self.ch_pos, "crosshair")
else
self.past_one=true
end
self.mouse_change.x=0
self.mouse_change.y=0
print("ch_pos.x: " .. go.get_world_position('crosshair').x)
print("ch_pos.y: " .. go.get_world_position('crosshair').y)
end
function on_input(self, action_id, action)
--MOUSE
self.mouse_change.x=action.x-self.mouse.x
self.mouse_change.y=action.y-self.mouse.y
self.mouse.x=action.x
self.mouse.y=action.y
print("mouse_change.x: " .. self.mouse_change.x)
print("mouse_change.y: " .. self.mouse_change.y)
--PLAYER
if action.pressed then
if action_id == hash("up") then
self.up = 1
elseif action_id == hash("down") then
self.down = 1
elseif action_id == hash("left") then
self.left = 1
elseif action_id == hash("right") then
self.right = 1
end
elseif action.released then
if action_id == hash("up") then
self.up = 0
elseif action_id == hash("down") then
self.down = 0
elseif action_id == hash("left") then
self.left = 0
elseif action_id == hash("right") then
self.right = 0
end
end
end
So, problem is in that when I am using keyboard it doesn’t track mouse movement, is there any solution for this?