[HELP]how to set ped looking at position

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

Is this what you’re looking for?

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

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

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

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

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.

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

6 Likes

Hey Havoc!

General Lua question: I’ve been neglecting to use variables in my “Get’s” because they never seem to update until I put them in a loop of some sort. Is my suspicions correct, or is there a way to keep p1 and p2 (for example) to continuously getentitycoords?