[HELP]how to set ped looking at position


#1

Hey anyway to set our ped facing at the position the we gave…

using entityheading…

i mean i want to set my ped heading to another player


#2

Is this what you’re looking for?

function SetEntityHeading(entity, heading)
	return _in(0x8E2530AA8ADA980E, entity, heading)
end

#3

I already know this nnative… but i want something like this

SetEntityHeading(ped1, ped2) then ped 1 gonna heading to ped2


#4

There isn’t a native for that, you would have to write your own function… It’d look something like

function setEntityHeadingFromEntity ( ent1, ent2 )
    local heading = GetEntityHeading(ent1)
    SetEntityHeading( ent2, heading )
end

#5

Correct me if I’m wrong but that wouldn’t face ent2 towards ent1, it would just make them look the same way. You would have to retrieve the right heading based of ent1’s position.


#6

Yes, if you wanted to make an entity face another, you could so something along the lines of

-- Face entity1 to entity2 
function makeEntityFaceEntity( entity1, entity2 )
    local p1 = GetEntityCoords(entity1, true)
    local p2 = GetEntityCoords(entity2, true)

    local dx = p2.x - p1.x
    local dy = p2.y - p1.y

    local heading = GetHeadingFromVector_2d(dx, dy)
    SetEntityHeading( entity1, heading )
end

Note: Not tested