Jump to content

How to attach a camera to an element?


Recommended Posts

  • Moderators

hmm, (I never used it before on vehicles and did not notice that)

setElementAlpha ( vehicle,0)

-- onClientRender.  
local vehicle = getPedOccupiedVehicle (localPlayer) -- not needed, when you already have a vehicle 
if vehicle then 
 local Sx,Sy,Sz = getElementPosition (vehicle) 
 local _,_, pR         = getElementRotation (localPlayer) 
 pR =  ((pR+90) * 3.141592653 * 2)/360; --edit "90" to change the rotation. 
 local lookAtX, lookAtY, lookAtZ = Sx + math.cos(pR)*5, Sy + math.sin(pR)*5, Sz 
 setCameraMatrix (Sx,Sy,Sz+4, lookAtX, lookAtY, lookAtZ+4)-- +4 high camera 
end 
  

-- updated and tested

Link to comment

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