I am making fly function which will make my character fly but its not working as it should be i dont know why its not working. It was done similarly on android i recreated it on ios here is what i have done.
void (*Old_PlayerController_Update)(void *myPlayer);
void PlayerController_Update(void *myPlayer)
{
if (myPlayer != NULL) {
// Function pointers for Rigidbody methods
void (*set_velocity)(void *, Vector3 value) = (void (*)(void *, Vector3))getRealOffset(0x2785420);
void (*MovePosition)(void *, Vector3 position) = (void (*)(void *, Vector3))getRealOffset(0x2785E10);
Vector3 (*get_posRigidbody)(void *) = (Vector3 (*)(void *))getRealOffset(0x2785C18);
if (show_fly){
void *myRigidbody = *(void **)((uint64_t)myPlayer + 0x428); // Get Rigidbody pointer
if (myRigidbody != NULL) {
Vector3 MyPos = get_posRigidbody(myRigidbody); // Get current position
set_velocity(myRigidbody, Vector3(0.0f, 0.0f, 0.0f));
// Fly up
if (setFly) {
MovePosition(myRigidbody, Vector3(MyPos.x, MyPos.y + valueFly, MyPos.z));
setFly = false; // Reset after moving
}
// Fly down
if (setFly2) {
MovePosition(myRigidbody, Vector3(MyPos.x, MyPos.y - valueFly, MyPos.z));
setFly2 = false; // Reset after moving
}
}
}
}
return Old_PlayerController_Update(myPlayer);
}
and i hook uodate like this:
HOOK(0x101E7C8, PlayerController_Update, Old_PlayerController_Update);
here functions from dump.cs:
functions or offsets in dll arelike this:
// RVA: 0x2785E10
public Void MovePosition(Vector3 position) { }
// RVA: 0x2785420
public Void set_velocity(Vector3 value) { }
// RVA: 0x2785C18
public Vector3 get_position() { }
Here is preview what it does when i activate this function try to fly:
https://file.io/OZrl5THtXDf7