..:D&G:.. Posted March 23, 2016 Share Posted March 23, 2016 Is there any easy way to have an action function that does something when the player looks straight at an object and presses 'E' for example, like in games like Rust or Reign Of Kings? Don't really know how to explain this, but here is an example: Thanks. Link to comment
Dimos7 Posted March 23, 2016 Share Posted March 23, 2016 So want a player pick up a object when press a key and look it? Link to comment
undefined Posted March 23, 2016 Share Posted March 23, 2016 As I understand as: SetPedLookAt Link to comment
..:D&G:.. Posted March 23, 2016 Author Share Posted March 23, 2016 As I understand as: SetPedLookAt Well I want to get the position of where the ped is looking at. Lets say I have a wood box on the ground, and if the player is close to it and is looking directly at the box, a message like "You are looking at the box" should appear. Link to comment
Dimos7 Posted March 23, 2016 Share Posted March 23, 2016 function pedLooks(theElement) local x, y, z = getElementPosition(localPlayer) local bx, by, bz = getElementPosition(theElement) local distance = getDistanceBetweenPoints3D(x, y, z, bx, by, bz) if setPedLookAt(localPlayer, theElement) and distance <= 5 then outputChatBox("You looking at "..theElement) end end Link to comment
xScatta Posted March 24, 2016 Share Posted March 24, 2016 hit, hitX, hitY, hitZ, hitElement = processLineOfSight ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPlayers = true, bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, element ignoredElement = nil, bool includeWorldModelInformation = false, bool bIncludeCarTyres ] ) set ignoredElement to localPlayer and where its positions do startX, startY, startZ, endX, endY, endZ = getCameraMatrix() and then check if 'hit' is true and hitElement is the element which are u looking on. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now