Jump to content

Element shaking problem


vovo4ka

Recommended Posts

I want to make own camera handler and every PreRender event I'm using setCameraMatrix function for set camera direction.

When I want to attach camera to moving element I have strange effect - target object starts shaking. See video:

when the camera is fixed - I'm using my own function for set camera position/direction:

function Render()
 local camtx, camty, camtz = getElementPosition(locPlr)
 setCameraMatrix (camtx,camty+5,camtz+5,camtx,camty,camtz)
 end

heli and car starts shaking but other element and landscape are seen stable

When switchin to standard camera mode (or setCameraTarget once) all ok.

But I need to set offset of camera position and target and keep camera near target object.

I'm trying to apply some arithmetic calc positions for smoothing. But this is has no effect.

Increasing server fps limit - leads to increase frequency of shaking.

Link to comment

other suggest, as explosions is making shakes u can use clientside explosion w/o damage,sound, and hided after screen

--clientside!
shakeintensity=-1.0
time=100000
 
function shakescreen()
  camTargX,camTargY,camTargZ,camPosX,camPosY,CamPosZ=getCameraMatrix()
createExplosion(camPosX-(camTargX-camPosX),camPosY-(camTargY-camPosY),camPosZ-(camTargZ-CamPosZ),11,true,shakeintensity,false) --creating explosion without damage,sound, and in back from screen, with shaking effect
end
 
setTimer(shakescreen,time,1000)--create it every second for long effect

but heres also downsides:it might run fps down since much explosions is created, and it migh not work when cameras matrix target is very away from camera position

i believe trigonometrical functions would be much more efficient, but sorry i cant help with them

Link to comment
may moving this code client side and doing it as part of the onClientRender event.

Render functions always client-side

It'll be the game's physics fighting your inputs. If you place a vehicle above the ground, it'll keep trying to fall towards the ground every frame. setVehicleFrozen

Maybe but setVehicleFrozen - doesn't help :cry: And I don't understand how Frozen can help in this case :D Call it like this?:

function Render()
 setvehicleFrozen(..., true)
 setCameramatrix(...)
 setvehicleFrozen(..., false)  
 end

I think it's a crazy idea :D

If the vehicle is drived by ped - there are same problem :(

karlis, I know how to make some effects :D But in this case shaking of oblect - is a problem

Link to comment
It'll be the game's physics fighting your inputs. If you place a vehicle above the ground, it'll keep trying to fall towards the ground every frame. setVehicleFrozen may help - as may moving this code client side and doing it as part of the onClientRender event.

It happens to every kind of vehicle (driving cars, flying helis, piloting boat, etc. haven't tested on moving objects, which are moved by moveObject). But onClientPreRender may solve the issue.

setVehicleFrozen changes vehicle's position on every frame (setElementPosition in onClientRender) but I doubt it would solve the issue. Besides vehicle speed would have to be changed back to speed before setVehicleFrozen and rotation too.

Link to comment

I've been using onClientPreRender for a cockpit camera and there is no problem to me, but onClientRender brings the "shaking" effect. However I have a getElementMatrix() instead of of getElementPosition(), and this is the only major difference between your and mine script logics. Does it matter? No idea, so I can't see a reason why onClientPreRender doesn't work to you in a way it does to me, still this is the solution.

Link to comment
I've been using onClientPreRender for a cockpit camera and there is no problem to me, but onClientRender brings the "shaking" effect. However I have a getElementMatrix() instead of of getElementPosition(), and this is the only major difference between your and mine script logics. Does it matter? No idea, so I can't see a reason why onClientPreRender doesn't work to you in a way it does to me, still this is the solution.

I did it yesterday and all works perfectly. Thx! :wink:

Link to comment

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