Hi! I am writing a character customization script, and my camera glitches way too often. I mean it should be looking straight towards the ped I am customizing, but sometimes it looks completely in a different direction, sometimes it’s looking towards the ground, and etc. I dont know how can I create a camera and set it towards the player, so I made my player’s camera first person and set the player right in front of the ped I am customizing, but bad rotations happen. Can someone please help me?
My script:
on("showCharacterCustomizer", (id, charName, playerID) =>
{
FreezePedCameraRotation(PlayerPedId());
DoScreenFadeIn(4000);
DisplayRadar(false);
SetFollowPedCamViewMode(4);
var model = GetHashKey("mp_f_freemode_01");
SetEntityVisible(PlayerPedId(), false);
RequestModel(model);
RequestCollisionAtCoord(pedX, pedY, pedZ);
RequestCollisionAtCoord(pX, pY, pZ);
var tick = setTick(() =>
{
if (HasModelLoaded(model))
{
ped = CreatePed(
2,
GetHashKey("mp_f_freemode_01"),
pedX, pedY, pedZ,
-160,
false,
true
);
SetPedHeadBlendData(
ped,
0,
0,
0,
0,
0,
0,
0,
0,
0,
false
);
FreezeEntityPosition(ped, true);
FreezeEntityPosition(PlayerPedId(), true);
SetEntityCoords(PlayerPedId(), pX, pY, pZ);
//Set the player facing the ped, but sometimes it's looking in a different
//direction.
SetEntityHeading(PlayerPedId(), 40);
SetNuiFocus(true, true);
SendNuiMessage(JSON.stringify({
type: "character_creator", visible: true, accountID: id,
charName: charName, playerID: playerID
}));
clearTick(tick);
}
})
});
My error in the script was I had RenderScriptCams on false. 