Jump to content

setCameraBehindPlayer


Glo

Recommended Posts

Posted

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.

Posted

if you are using it correctly - it's working. and who told you it requires timer?? O_O

this topic doesnt make sense

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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

Posted

give some code to reproduce "not always working" - i was using this function many times in complicated scripts - and it was ALWAYS working..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

Posted

example = script.

give me well scripted code that is causing this.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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.

Posted

you can script that very easly, ill add example later

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

Sorry this reply but, if you set the player's camera target as itself, it doesn't delete old camera matrices configurations?

Posted

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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.

Posted

less lines, but SO MUCH CPU. It's better to use my 16 lines, than yours 4.

http://en.wikipedia.org/wiki/Program_optimization

:)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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

mtascreen20101019113308.jpg

Posted

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 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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

Posted

just do it client-side (if you need from server - trigger event) - the martix and timer will be set clientside. solved.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

there isn't, saying thanks is enough :P

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...