Glo Posted October 17, 2010 Share Posted October 17, 2010 setCameraBehindPlayer(player) - ability to set camera directly behind a player. Can be done using setCameraTarget at the moment, but unfortunately that method does not always work and requires a timer. Link to comment
dzek (varez) Posted October 17, 2010 Share Posted October 17, 2010 if you are using it correctly - it's working. and who told you it requires timer?? O_O this topic doesnt make sense Link to comment
Glo Posted October 17, 2010 Author Share Posted October 17, 2010 Needs to be done like this to set the cam behind player: setCameraTarget(player) setTimer(setCameraTarget, 1000, 1, player) and then still doesn't work all times. That's why a dedicated function would be better Link to comment
dzek (varez) Posted October 17, 2010 Share Posted October 17, 2010 give some code to reproduce "not always working" - i was using this function many times in complicated scripts - and it was ALWAYS working.. Link to comment
Glo Posted October 17, 2010 Author Share Posted October 17, 2010 give some code to reproduce "not always working" - i was using this function many times in complicated scripts - and it was ALWAYS working.. For example, it doesn't work under a certain delay amount (sometimes 100ms, another time 1000ms - varies), and doesn't work without a timer at all. Link to comment
dzek (varez) Posted October 17, 2010 Share Posted October 17, 2010 example = script. give me well scripted code that is causing this. Link to comment
12p Posted October 17, 2010 Share Posted October 17, 2010 Check out this resource I made for that you want: https://community.multitheftauto.com/index.php?p= ... ls&id=1129 Link to comment
MX_Master Posted October 18, 2010 Share Posted October 18, 2010 author want to say that setCameraTarget(player) don't point camera from back to front of player skin. After setCameraTarget(player) camera may be pointed from side to side of player skin. Example = standard game mode "play". After spawn camera will be placed not to back but to left side from spawned player. Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 you can script that very easly, ill add example later Link to comment
MX_Master Posted October 18, 2010 Share Posted October 18, 2010 you can script that very easly, ill add example later waiting... Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 server side, not tested but should work function getPositionRelatedToPed(thePed, val) local xx, yy, zz = getElementPosition(thePed) local rot = getPedRotation(thePed) local lx = xx + math.sin (math.rad(-rot)) * val local ly = yy + math.cos (math.rad(-rot)) * val return lx,ly end function setCameraBehindPlayer(pl) local xx,yy,zz = getElementPosition(pl) local lx, ly = getPositionRelatedToPed(pl, -2) setCameraMatrix(pl, lx, ly, zz+1, xx, yy, zz) setCameraTarget(pl, pl) end Link to comment
12p Posted October 18, 2010 Share Posted October 18, 2010 Sorry this reply but, if you set the player's camera target as itself, it doesn't delete old camera matrices configurations? Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 yes, but first it sets camera behind - then set camera target - so this should cause the camera to be behind player and targetted to player Link to comment
12p Posted October 18, 2010 Share Posted October 18, 2010 But too much lines. Is easier to use (client-side): addEventHandler ( "onClientPreRender", getRootElement(), function ( ) setCameraTarget( getLocalPlayer( ) ) end ) It does the same thing (just has problems trying to using mouse to up or down), in less lines. Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 less lines, but SO MUCH CPU. It's better to use my 16 lines, than yours 4. http://en.wikipedia.org/wiki/Program_optimization Link to comment
12p Posted October 18, 2010 Share Posted October 18, 2010 Yeah... That's true LOL. Thanks for the lines, I will use them on my resource Link to comment
MX_Master Posted October 19, 2010 Share Posted October 19, 2010 server side, not tested but should work function getPositionRelatedToPed(thePed, val) local xx, yy, zz = getElementPosition(thePed) local rot = getPedRotation(thePed) local lx = xx + math.sin (math.rad(-rot)) * val local ly = yy + math.cos (math.rad(-rot)) * val return lx,ly end function setCameraBehindPlayer(pl) local xx,yy,zz = getElementPosition(pl) local lx, ly = getPositionRelatedToPed(pl, -2) setCameraMatrix(pl, lx, ly, zz+1, xx, yy, zz) setCameraTarget(pl, pl) end checked. Same things.. camera position is on the left side of player and target is on the right side of player. Look Link to comment
dzek (varez) Posted October 19, 2010 Share Posted October 19, 2010 try this: function setCameraBehindPlayer(pl) local xx,yy,zz = getElementPosition(pl) local lx, ly = getPositionRelatedToPed(pl, -2) setCameraMatrix(pl, lx, ly, zz+1, xx, yy, zz) setTimer(setCameraTarget, 50, 1, pl, pl) end Link to comment
MX_Master Posted October 19, 2010 Share Posted October 19, 2010 try this: function setCameraBehindPlayer(pl) local xx,yy,zz = getElementPosition(pl) local lx, ly = getPositionRelatedToPed(pl, -2) setCameraMatrix(pl, lx, ly, zz+1, xx, yy, zz) setTimer(setCameraTarget, 50, 1, pl, pl) end for players with big ping may not work properly Link to comment
dzek (varez) Posted October 19, 2010 Share Posted October 19, 2010 just do it client-side (if you need from server - trigger event) - the martix and timer will be set clientside. solved. Link to comment
MX_Master Posted October 19, 2010 Share Posted October 19, 2010 bingo, current Suggestion can be done by MTA server-side and client-side functions varez, +1 and where is here "thanks" button?.. Link to comment
dzek (varez) Posted October 19, 2010 Share Posted October 19, 2010 there isn't, saying thanks is enough Link to comment
Recommended Posts