Ace_Gambit Posted February 17, 2008 Share Posted February 17, 2008 Some how I can't make the camera work like I want it. Whatever values I use for setCameraPosition, setCameraTarget and setCameraLookAt none of those give the right effect. In fact I haven't managed to move the camera to a fixed position other than somewhere at 0,0,0. No matter what values I use for setCameraPosition it always ends up at 0,0,0. Look at this code snippet for example. When simple fixed camera placement failed I tried to make a hawkview function. meta.xml <meta> <info author="" description="" name="" version="1.0" type="gamemode" /> <script src="test.lua" type="server" /> <script src="test_cli.lua" type="client" /> <map src="test.map" /> </meta> test.map <map mod="deathmatch" version="1.0" time="06:00"> <spawn posX="0" posY="0" posZ="4.0" rot="90" randx="0" randy="0" randz="0" /> <pickup id="2" posX="0" posY="0" posZ="4.0" type="38" respawn="500" amount="6000" /> <object name="platform" id="3" posX="0" posY="0" posZ="2.0" rotX="0.0000" rotY="0.0000" rotZ="0.0000" model="17559" /> </map> test.lua function spawn() if (spawnPlayer(source, 0, 0, 4.0)) then fadeCamera(source, true, 5.0) setCameraMode(source, "fixed") createBlipAttachedTo(source, 0, 2, 0, 255, 0) end end addEventHandler("onPlayerJoin", getRootElement(), spawn) test_cli.lua function hawkview() local x, y, z = getElementPosition(getLocalPlayer()) setCameraPosition(getLocalPlayer(), x, y, z + 50) setCameraTarget(getLocalPlayer()) end addCommandHandler("hawkview", hawkview) But when I test the mode and go to hawkview the camera simply goes back to chase mode . Link to comment
norby89 Posted February 17, 2008 Share Posted February 17, 2008 if you remove 'setCameraTarget(getLocalPlayer())' it won't do that but the camera will stay in place Link to comment
Mr.Hankey Posted February 17, 2008 Share Posted February 17, 2008 i think you have to make all camera functions either client or server side try this for the client: function hawkview() local x, y, z = getElementPosition(getLocalPlayer()) toggleCameraFixedMode (true) setCameraPosition(getLocalPlayer(), x, y, z + 50) setCameraTarget(getLocalPlayer()) end addCommandHandler("hawkview", hawkview) and for the serverside just leav the setcameramode function out: function spawn() if (spawnPlayer(source, 0, 0, 4.0)) then fadeCamera(source, true, 5.0) createBlipAttachedTo(source, 0, 2, 0, 255, 0) end end addEventHandler("onPlayerJoin", getRootElement(), spawn) Edit: Hm... i think norby is right and afaik you have to use setCameraLookAt instead of setCameraTarget. Link to comment
Ace_Gambit Posted February 17, 2008 Author Share Posted February 17, 2008 I already tried both your suggestions. But it seems like whenever I enable fixed camera mode I can't move the thing with setCameraPosition anymore. The camera automatically snaps to 0,0,0 every time I change to fixed mode. And it stays there no matter what values I use for setCameraPosition. -edit- The camera is moving now...let's try something different... -edit- Never mind. I hereby admit that I am a ******* idiot. I should have used setCameraPosition ( float x, float y, float z ) for the client-side instead of setCameraPosition ( player thePlayer, float x, float y, float z ) . Problem solved. 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