Teleportation of AI Peds / Falling Through The Ground

Hey all,

To give a bit of context, I’m working on a script which allows paramedics to revive AI peds which have been killed/incapacitated. I have no issues with the script besides the one I’m currently struggling with. After the ped is revived (Through the use of ResurrectPed(), which works) and all tasks are cleared (So they don’t remain frozen in mid-air). I then set the entity’s coords. This is where it gets kinda odd…

If I set the ped’s coords directly where they were prior to being ‘revived’, they simply fall through the ground. If I set them a bit higher (2.0 for example), the ped falls those 2 meters, hits the ground like he/she made the landing, then continues falling through the ground. I can never get the ped to simply stand on the ground. This is the current code I have:

respawnLoc = GetEntityCoords(revPed)
ResurrectPed(revPed)
SetEntityHealth(revPed, 200)
SetEntityCoords(revPed, respawnLoc.x, respawnLoc.y, respawnLoc.z + 1.0)
ClearPedTasksImmediately(revPed)

What I’ve tried:

  • Re-arranging all the various functions to see any differences
  • Freezing the ped in place for a moment (This makes the ped stay on the ground, but even setting them directly on the ground, the ped will fall over and eventually hold their stomach and die)
  • Changing the Z value (No effect on falling through ground)
  • Using SetPedCoordsKeepVehicle() instead of SetEntityCoords()

So I guess my question is… How can I ‘teleport’ an AI ped and not have them fall through the ground and/or fall on the ground in agony?

I will try to attach footage if I can get it.

I’m just guessing but what happend if you teleport them multiple times to the “surface”, do they continue falling down ? If so I’m guessing there is a collision issue or maybe something isn’t networked between all the players/ the server and thus causing this issue.

I tried teleporting them a second time and also freezing the ped for a moment and teleporting again. Both times, the ped would either fall through the ground completely or just fall over when teleported, hold their stomach, and die again.

As a side note, I went ahead and tried using SetPedCanRagdoll() (to false) and SetEntityInvincible() (to true), both of which just caused the ped to fall through the ground instead of falling over and dying.

Hey,

im just doing the very same thing and the peds dont fall through the ground.

Couldnt it be that there is some interference? Maybe some animations or whatever?

A little late to the party but what works for me %100 of the time is having them teleported into a vehicle since I cant find a way to get them to set properly on the ground.
So Res them, TaskEnterVehicle them and they just get out of the vehicle brand new