How to edit gameobject velocity, position, rotation in c++?

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.

You may want to keep the game object data in a C struct. Then you can use SetPosition and SetRotation in C++ update. However, you first need to pass the instance to C++.

Example: defold-daabbcc3d/daabbcc3d/src/extension.cpp at d96330d222b68d36d4f8e0893ebc7fc5541b1128 · selimanac/defold-daabbcc3d · GitHub