Peds stop animation each time my character comes in contact with them


#1

hi there i spawned peds with animations , however each time my character gets in contact with them , they stop the animation and walk away . i tried SetRelationshipGroup but no luck . anyone has an idea how to make the peds indifferent when my character comes in contact and keep doing the animation. thanks in advance


#2

You can try to freeze that ped


#3

i dont like to freeze them because they become like obstacles and you cant walk by them . i have them spawned as a crowd so i wanna be able to walk through them without them braking the animation . im pretty sure its the Setrelaionshipgroup native i just gotta make it work somehow .


#4

If it is possible for your animation you can also use scenario with TaskStartScenarioInPlace and when you move that ped with walking into it or with vehicle it will start the scenario again. And also using TaskPlayAnim you can try to use diffrent flags so it may work diffrent and you will get your result? If it not gonna work you can alos try something like this:

if IsEntityPlayingAnim(ped, "your_animation_here", "base", 3 ) then
TaskPlayAnim(your anim here)

target that ped and put it in a loop


#5

i already using taskplayanim . and even if i was able to make them do the animation again . its just annoying as i dont want them to cancel the animation each time i come in contact with them . its supposed to be in a dance floor .


#6

thats it i made it happen . thanks a lot now even tho they i run through them they keep playing the animation . thanks a lot for trying to help me man .


#7

now one last issue that i would love to fix . is that now eventho they dont stoping the animation they move far away from their original position . is there a way to make them go back to the original position .


#8

To start the animation from beginning? Im not sure (It should start from beginning after you interrupt their animation by moving a ped) but you can try to put flag ANIM_FLAG_REPEAT = 1, in TaskPlayAnim look here at flags:
https://runtime.fivem.net/doc/natives/#_0xEA47FE3719165B94


#9

i fixed that last time . the issue now is that they move from their place eventho they keep doing the animation . and they move really far . after i get inside the dance floor im left with an empty circle XD


#10

Well, another thing i can suggest to do is teleport the ped if is too far like this:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5000) --loop every 5 seconds should be enough

            local plyCoords = GetEntityCoords(ped, false)
            local distance = Vdist(plyCoords.x, plyCoords.y, plyCoords.z, YourXCoordsHere, YoursYCoordsHere, YoursZCoordsHere) --coords of starting position

            if distance <= 2.0 then  --your distance here, how far they can be moved. If more than 2.0 then:
		    SetEntityCoords(ped, YourXCoordsHere, YoursYCoordsHere, YoursZCoordsHere) --teleport the ped to their starting position
		    Citizen.Wait(1000)
            end
        
end
end)

#11

hmmm these are all work arrounds . i did that but it just looks weird XD because i made a crowd so when i walk by them if teleport them back to their spawn coords it just looks weird XD not to mention how much it will affect performance . im pretty sure the solution is to set the player and peds in one group SetRelationshipGroup . this way they will act as if you are one of them . with that being said im very thankfull for trying to help me out .


#12

If you dont want to make them teleport, you can also use TaskGoStraightToCoord to make them walk to selected coords.
Anyway if you think that SetRelationshipBetweenGroups would work try this:

AddRelationshipGroup("PEDS")
AddRelationshipGroup("PLAYER")
SetRelationshipBetweenGroups(255, GetHashKey("PEDS"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(255, GetHashKey("PLAYER"), GetHashKey("PEDS"))
	--255 = Pedestrians so they should think you are one of them?



--and then add that group to each ped
SetPedRelationshipGroupHash(ped, GetHashKey("PEDS"))

--also add player group to you
SetPedRelationshipGroupHash(GetPlayerPed(-1), GetHashKey("PLAYER"))

Anyway let me know if you made this work :slight_smile:


#13

hey thanks i ll give it a try once i get home . i think i tried something like that . but maybe i missed smth . again thanks a lot for all the help .