Jump to content
RAGE Multiplayer Community

[C#] RAGE.Game.Misc.GetGroundZFor3dCoord always returns 0.0f??


Recommended Posts

Posted (edited)

Honestly at this point, I'm beyond ideas; Loading the area collision prior to calling "RAGE.Game.Misc.GetGroundZFor3dCoord", if anyone has any idea's that'd be great.

public static void StartPlayerSwitchToPosition(this Player player, Vector3 pos)
{
    SWITCH_TIME_WAITED = 0;

    RAGE.Game.Invoker.Invoke(0xAAB3200ED59016BC, (int)RAGE.Elements.Player.LocalPlayer.Handle, (int)0, (int)1); // Start Ped/Entity switch

    while (SWITCH_TIME_WAITED < SWITCH_WAIT_TIME)
    {
        SWITCH_TIME_WAITED++;
        RAGE.Game.Invoker.Wait(0);
    }

    RAGE.Game.Streaming.SetFocusArea((float)pos.X, (float)pos.Y, (float)pos.Z, (float)pos.X, (float)pos.Y, (float)pos.Z + 3.8f);

    if (SWITCH_TIME_WAITED >= SWITCH_WAIT_TIME)
    {
        // 797.97(~6)f being the highest point.
        float Z = 797.97f;
        RAGE.Elements.Player.LocalPlayer.Position = new Vector3((float)pos.X, (float)pos.Y, Z);

        RAGE.Game.Streaming.RequestCollisionAtCoord((float)pos.X, (float)pos.Y, (float)pos.Z);
        RAGE.Game.Streaming.RequestAdditionalCollisionAtCoord((float)pos.X, (float)pos.Y, (float)pos.Z);

        bool collision = RAGE.Game.Invoker.Invoke<bool>(RAGE.Game.Natives.HasCollisionLoadedAroundEntity, player.Handle);
                    
        while (!collision)
        {
            collision = RAGE.Game.Invoker.Invoke<bool>(RAGE.Game.Natives.HasCollisionLoadedAroundEntity, player.Handle);
            RAGE.Game.Invoker.Wait(500);
        }

        RAGE.Elements.Player.LocalPlayer.Position = new Vector3((float)pos.X, (float)pos.Y, 797.97f);
        player.FreezePosition(true);

        bool groundZ = RAGE.Game.Misc.GetGroundZFor3dCoord(pos.X, pos.Y, 797.97f, ref Z, false);

        while (!groundZ)
        {
            groundZ = RAGE.Game.Misc.GetGroundZFor3dCoord(pos.X, pos.Y, 797.97f, ref Z, false);
            RAGE.Game.Invoker.Wait(120);
        }

        RAGE.Elements.Player.LocalPlayer.Position = new Vector3((float)pos.X, (float)pos.Y, Z + 3.0f);
        player.FreezePosition(false);

        RAGE.Game.Invoker.Invoke(0xD8295AF639FD9CB8, (int)player.Handle); // End Ped/Entity switch

        SWITCH_TIME_WAITED = 0;
        player.FreezePosition(false);
    }
}

 

Edited by TheOnlyDroid
Link to post
Share on other sites
  • TheOnlyDroid changed the title to [C#] RAGE.Game.Misc.GetGroundZFor3dCoord always returns 0.0f??

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...