Jump to content

How to attach a camera to an element?


Recommended Posts

Posted

Is there any way? Basically, I am creating a vehicle which will move from one point to another and will be invisible. I want the camera to be attached on that vehicle so if the vehicle moves, the camera moves along with it.

Regards,

Cassandra - V:MP

Posted

Maybe you can get the camera matrix of the vehicle and then set it to yours ..

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

  • Moderators
Posted

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

I don't think so ..

Maybe in another version of MTA ..!

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

  • Moderators
Posted

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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