Freeze coord Z during animation

Hi,

I’m trying to add animation at my different shop like the animation on the Online. I’m currently work on my barber shop and the sitting animation. But when my player arrive on the seat, he takes the hitbox at seat and seat 1 meter upper than the normal position.
Do you know how to freeze only the Z coord ?

Example on video :

My code :

AddEventHandler("barbier:animChain", function(v)
    Citizen.CreateThread(function()
            Wait(100)
            local dict ='misshair_shop@barbers'
            local myPed = PlayerPedId()
            RequestAnimDict(dict)

            while not HasAnimDictLoaded(dict) do
                Citizen.Wait(0)
            end

            local animation = ''
            local flags = 0 -- only play the animation on the upper body
		if Menu.hidden then
                      animation = 'player_exitchair'
                      TaskPlayAnim(myPed, dict, animation, 8.0, -8, -1, flags, 0, -1, -1, -1)
                      Citizen.Wait(100)
                      SetEntityCollision(GetPlayerPed(-1),true,true)
                      FreezeEntityPosition(GetPlayerPed(-1),false)
		end
    end)
end)

Have you tried setting the player position after the animation has been play 1 meter down?

like as soon as the animation to get out of the chair is started set the new coords of the player -1.0 on the z so maybe it will teleport him back into the chair instantly?

idk just a thought…

I had already try but it don’t work. It will be automatically move up,for the first animation (during sitting time) I have to disable the collision of my ped and freeze it to keep the right position but it’s not possible with the exit because my ped move :S

Try disabling the collision with the chair.

I think I need this hash to make that? Do you have the list of all object?

You could also try SET_ENTITY_COLLISION(Entity entity, BOOL toggle, BOOL keepPhysics);, which I assume will stop collision with everything.

I already use it but if you use it without freezeposition, your player will fall through the ground.

But I can’t freeze my player because with my animation, my player move :S

Well, if you freeze them, it should still play the animation, you just won’t be able to walk around, or fall through the world in this case.

The problem is with the exit animation, if you watch the video on my first post. So, I can’t freeze my player

Wouldn’t this fix your problem then?

if IsControlJustPressed(1, 32) then
ClearPedTasks(GetPlayerPed(-1))
FreezeEntityPosition(GetPlayerPed(-1), false)
end
      Modelname           Hash
v_serv_bs_barbchair  = 1543408104
v_serv_bs_barbchair2 = -465246693
v_serv_bs_barbchair3 = 434950506
v_serv_bs_barbchair5 = -177141645

These are the Chairprops. But you would need the objectpointer to disable the collision.

You could use this: Click Here to get the objectpointer and then this: Click Here to disable the collision.

Thanks you, I will check that this night

I tried with Flatracer’s method but impossible to go closest object, my scrip always return “nil” value :S

How to do to put animations to the characters in fivem I do not know what I have to use or how to do I have many things in the server but I have to put animations could help me? That I have to use or how I put the animations or files I need thanks if you can help me