Right now in script update I get result from c++ then set which seems wrong tbh.
function M.update(self, dt)
local pos = go.get_position()
local new_pos, new_vel, new_move_dir, grounded, new_params = terrain.npc_update(self.id, pos,self.velocity,self.move_dir,self.size, dt, self.ai_state)
self.velocity = new_vel
self.move_dir = new_move_dir
self.ai_state = new_params
go.set_position(new_pos)
terrain is my extension. npc_update function have 2 states( idle , walk) and just randomly move npc around terrain with my own physics which is just AABB swept.