Maurize Posted May 22, 2012 Posted May 22, 2012 So I'm trying to let the camera rotate at a specific object( means x, y and z coordinate ) with setCameraMatrix and onClientRender. Anybody a hint how to let camera rotate at this coordinates? I mean, I only have to update this: setCameraMatrix( this, this, this, this not( x ), this not( y ), this not( z ) ) Thanks!(:
X-SHADOW Posted May 22, 2012 Posted May 22, 2012 Just Look At the Tips in wiki there is Required Arguments and Optional Arguments [url=https://wiki.multitheftauto.com/wiki/SetCameraMatrix]https://wiki.multitheftauto.com/wiki/SetCameraMatrix[/url] My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Maurize Posted May 22, 2012 Author Posted May 22, 2012 I know. But I mean to rotate it arround the object. So the "roll" argument won't be the right thing, I think. I must calculate the x and y position...
Castillo Posted May 22, 2012 Posted May 22, 2012 local x, y, z = 0, 0, 10 -- Camera position local rotation = 0 -- Camera rotation local height = math.rad ( 1 ) -- height local distance = 19 -- default distance from the player function renderCameraRotation ( ) rotation = ( rotation + 0.5 ) if ( rotation >= 360 ) then rotation = 0 end local angle = math.rad ( rotation ) local camX = ( x + 3 * distance * math.cos ( angle ) * math.cos ( height ) ) local camY = ( y + 3 * distance * math.sin ( angle ) * math.cos ( height ) ) local camZ = ( z + 0.4 * distance + 2 * distance * math.sin ( height ) ) local hit, hitX, hitY, hitZ = processLineOfSight ( x, y, z, camX, camY, camZ, false, false, false ) if ( hit ) then camX, camY, camZ = ( x + 0.9 * ( hitX - x ) ), ( y + 0.9 * ( hitY - y ) ), ( z + 0.9 * ( hitZ - z ) ) end setCameraMatrix ( camX, camY, camZ, x, y, z ) end addEventHandler ( "onClientPreRender", root, renderCameraRotation ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Maurize Posted May 22, 2012 Author Posted May 22, 2012 exactly what I've searched for. Works really good!(: Thanks & now im studying this function to script it for myself in future!(:
Castillo Posted May 22, 2012 Posted May 22, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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