[Help] Make Object face the way you are facing

I have this so far:

AddEventHandler('murtaza:sbarrier', function()
	local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
	
	RequestModel('prop_mp_barrier_02b')
	
	while not HasModelLoaded('prop_mp_barrier_02b') do
		Citizen.Wait(1)
	end
	
	local cone = CreateObject('prop_mp_barrier_02b', x, y, z-1, true, true, true)
	PlaceObjectOnGroundProperly(object)
	notification('~g~The small barrier has been placed!')
end)

The barrier faces in a different direction which looks odd. Is there a way to make it face the way you are facing. If possible, an explanation would be great. Thank you in advance!

1 Like
local cone = CreateObject(......)
local heading  = GET_ENTITY_HEADING(PlayerPed(-1))
SET_ENTITY_HEADING(cone, heading)

It might be that you’ll need to add 90 degrees to some objects because R* is inconsistent.
This only rotates around Z. If you want to fully line up the rotation with the player, use GET and SET ENTITY_ROTATION.
(Also if I recall correctly, the heading value is in degrees, not radians)

hey man… we had the same idea lol…

did you solve it? would you mind telling me how?

i’m trying SetEntityRotation, but i miss understand how this works.