Jump to content

[HELP] Ped looking at an object


..:D&G:..

Recommended Posts

Posted

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:

pvM0D.png

Thanks.

Posted
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.

Posted
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 

Posted
  
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...