Jump to content

how to go about scripting a moving camera?


Recommended Posts

local obj1 = createObject(1337,0,0,5)
setElementAlpha(obj1,0)
local obj2 = createObject(1337,-5,5,4.5)
setElementAlpha(obj2,0)
fadeCamera(true)
moveObject(obj1,30000,5,0,5)
moveObject(obj2,30000,10,5,4.5)
 
addEventHandler("onClientPreRender",getRootElement(),
function()
local cx,cy,cz = getElementPosition(obj1)
local tx,ty,tz = getElementPosition(obj2)
setCameraMatrix(cx,cy,cz,tx,ty,tz)
end
)

Link to comment

it doesn't work :( I still don't firmly understand, I know that setCameraMatrix sets the camera and it's suppose to set it to the object and move the object but the code doesn't move the camera back it just sits there...heres my code

function setCameraOnPlayerJoin()
local obj1 =  createObject(1337,
805.09777832031, -2780.2409667969, 9.3761787414551)
setElementAlpha(obj1,0)
local obj2 = createObject(1337, 821.29284667969, -2780.1831054688, 9.3761787414551)
setElementAlpha(obj2,0)
moveObject(obj1,30000,821.29284667969, -2780.1831054688, 9.3761787414551)
moveObject(obj2,30000,821.45483398438, -2786.248046875, 11.3835067749023)
fadeCamera(source, true, 5)
local cx,cy,cz = getElementPosition(obj1)
local tx,ty,tz = getElementPosition(obj2)
setCameraMatrix(source, cx,cy,cz,tx,ty,tz)
end
 
addEventHandler("onPlayerLogin",getRootElement(), setCameraOnPlayerJoin)

Link to comment
okay now it is working however I want it to follow a path so i created a midpoint where one object would pick up where the other one left off..how would I do this?
...

  • A lot of maths

...

Link to comment
If you needed advanced camera for machinima you can use stage resource. You can take result like real movie camera 8)

how can I use that in-game? I need it because in my server you can create a character but when you click create character the camera moves to a new room and you can create your skin there however i need to move left but the moveObject only can move in one direction and i need to move back and then left...how can I accomplish this?

Link to comment

You can use timers to move objects in different directions at different times.

But what vovo4ka wanted to say is you can use stage resource which lets you feel like movie "director" (and I think that would be better name for such resource).

Link to comment

but how can i bring that into my game mode???? I created what i want with the stage resource and got a .std file when I include that in my meta it doesnt do anything! I need the camera to move when a gui button is clicked and some peds doing activities in the back but when I start this it does nothing this resource is for recording movies with a video camera or playback recorder

Link to comment
local obj1 = createObject(1337,0,0,5)
setElementAlpha(obj1,0)
local obj2 = createObject(1337,-5,5,4.5)
setElementAlpha(obj2,0)
fadeCamera(true)
 
function move1()
moveObject(obj1,30000,5,0,5)
moveObject(obj2,30000,10,5,4.5)
setTimer(move2,30000,1)
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),move1)
 
function move2()
moveObject(obj1,30000,0,0,5)
moveObject(obj2,30000,-5,5,4.5)
setTimer(move1,30000,1)
end
 
addEventHandler("onClientPreRender",getRootElement(),
function()
local cx,cy,cz = getElementPosition(obj1)
local tx,ty,tz = getElementPosition(obj2)
setCameraMatrix(cx,cy,cz,tx,ty,tz)
end
)

this would make the camera loop between those 2 states i used before.

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