I would suggest you to go through the different macros (such as DEFINE_) which are available in the Ansys Fluent UDF Manual. You will also be able to understand how to write the code for defining the UDFs, the appropriate structure and various available functions. The DEFINE_CG_MOTION could be a good fit for your application as it is used to specify the motion of a particular dynamic zone (object in your case) in Ansys Fluent by providing the linear and angular velocities at every time step. I have also shared a link of a similar discussion on the Ansys Forum related to implementation of UDF for an overset mesh case. Hope that helps!