OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Surdus Priest on 10 Jun 2007, 13:06:45
-
basically i need a way of tracking an object, then from another script, shake the camera from where ever the camera currently is. i have my own shaker, i just need an effective tracker for the job. thank you
-
Easiest way would be to pass the object as argument of your shaking script, am I missing something here? What do you mean by "tracking"?
-
supose you are running a cutscene, but your unsure about when sumthing in gonna explode. so you write the cutscene and you create an additional script to shake the camera of the cutscene.
to do this, the additional script would need to 'track' the current location of the camera, then shake the camera
-
You may just use a gobal variable set to any value which triggers the shaking effect. Triggers or a different script may take care of that global variable.
Dont you already have this topic open in the beta board?
-
i do, but it's a basic version, i need a more flexible script. do you know how to make this shake work as i want?
-
bingo.. i need to make the camera name a global variable so i can refer to and get the position of from another script. but i have never used globals before.. can you tell me how? and if posible, can you tell me how to get the position (and follow) of the camera in use. thank you
-
A global varialbe is anything that does not start with _
_varname1 is local
varname2 is global
your shaking camera is attached to an object, so you only need to track the position of that object with a simple getpos command.
-
thank you, i will try this. however, i know the getpos will get you to the object, but can you give me an example of the layout please?
because i have seen things like this:
; use: [cameraname, shakiness] exec "shakecan.sqs"
_cam = _this select 0
_shakiness = _this select 1
_ox = getPos _cam select 0
_oy = getPos _cam select 1
_oz = getPos _cam select 2
endshake = 0
#shake
_rx = (random(_shakiness)) - (_shakiness / 2)
_ry = (random(_shakiness)) - (_shakiness / 2)
_rz = (random(_shakiness)) - (_shakiness / 2)
_cam camSetPos [_rx + _ox, _ry+_oy, _rz+_oz];
_cam camCommit 0
~0.05
_cam camSetPos [_ox, _oy, _oz];
_cam camCommit 0
~0.05
? (endshake==0) : goto "shake"
exit
i can hardly understand this. and where it says; use: [cameraname, shakiness] exec "shakecan.sqs"
i just cant figure it out. the alternative was this, which i found more usefukl, but i still couldnt understand it:
;initiate with [name,x,y,z] exec "shakey_camera.sqs"
_unit = _this select 0
_x = _this select 1
_y = _this select 2
_z = _this select 3
stoptracking = false
_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]
_cam camSetTarget _unit
_cam CamSetFOV 0.7
#loop
~0.05
_cam camSetRelPos [_x + random 0.3,_y + random 0.3,_z + random 0.3]
_cam camCommit 0
? not stoptracking : goto "loop"
_cam cameraeffect ["terminate", "back"]
camdestroy _cam
exit
and againm, i havent a clue what; [name,x,y,z] exec "shakey_camera.sqs"
i know what the execute is, its normally [] exec "xxxxx.sqs" i use it all the time, but its the value name,x,y,z that i dont get
can you explain it at all?
thank you
-
further, if this is as simple is finding the object, then it wont continue the previous camera script. or would the shake take effect during the previous and then continue with the previous after rtghe shake script is finished?
-
Sorry, but now I really have no idea at all what you are really trying to do in your cutscenes.
-
ok, all im trying to do, is have a cutscene run normally. then when a particular explosion goes off. the screen shakes. and the magic thing about what im trying to do, is that the explosion could go off at any time, meaning the shake must be able to appear at any time during the cutscene. thats what im trying to do. can you help me?
-
So, you have the camera moving following your cutscene storyline, and when something explodes the camera should shake, right?
Now forget about the shake, how are you moving the camera through the cutscene?
-
heres a basic example, im using it for testing, moving from object to object:
cam = "camera" camcreate [0,0,0]
cam cameraeffect ["internal", "back"]
cam camsettarget ob1
cam camsetrelpos [-5,10,3]
cam camcommit 0
~5
cam camsettarget ob2
cam camsetrelpos [-5,10,3]
cam camcommit 2
~5
cam camsettarget ob3
cam camsetrelpos [5,-10,3]
cam camcommit 2
~5
cam camsettarget ob1
cam camsetrelpos [5,10,3]
cam camcommit 2
~5
cam camsettarget ob2
cam camsetrelpos [-5,10,3]
cam camcommit 0
-
Check the explosion condition during the delays (~5) and apply setRelPos changes with quick commit, after that, resume the path of the camera (same rel pos as before exposion and commit it in the original time minum the time consumend during your checks minus the time consumed by the shaking effect.
-
so i'd need to resume the previous camera?
-
so how to i check the conditions?
-
actuualy, it would be all i need to know how to make the shaker, track the current position of the camera. so all i need to know, is what this does:
_ox = getPos _cam select 0
_oy = getPos _cam select 1
_oz = getPos _cam select 2
-
just punt a hint format["%1 %2 %3", _ox, _oy, _oz] and youll find out what that does
-
this is what i've done so far, this is the Movement Capsule, its the target for my shaker:
;==Movement Start==
x = ###
y = ###
z = ###
cam camsettarget ###
cam camsetrelpos [x,y,z]
cam camcommit ###
;==Movement End==
Use it as you would use any camera position. what this does is sets the values to an alternative path. This will allow you to use the shaker more effectively.
This is my shaker, i called it the Violence Factor:
; *****************************************************
; ** Violence Factor - Advanced Shake
; *****************************************************
;Execute = [Camera Name] exec "Advanced_Shake.sqs"
;--Do Not Modify--
_cam = _this select 0
_tshake = 0.1
;--Do Not Modify--
;Initial Pause - Required to Synchronize with Explosion
~0.5
;Duration - Time Until Shake Ends
_shake = 2
;Violence Level - Level of Shake Distance
_v = 0.8
;Positions - Standard x,y,z (According to Movement Capsules)
_x = x
_y = y
_z = z
;Loop Name
#shake1
;--Do Not Modify--
_shake = _shake - _tshake
_cam camSetRelPos [_x + random _v,_y + random _v,_z + random _v]
;--Do Not Modify--
;Cool Down - Fading Shake Duration (Use at own Risk)
_v = _v - 0.
;Loop Duration - Modifies the speed of shake (Use at own Risk)
_cam camCommit 0.025
~0.025
;End Loop - Modify "goto" target only (Use is Necessary)
? _shake > 0.1 : goto "shake1"
So far i have created a basic version which can be implemented directly into the camera script, but its not as effective with explosions as my advanced version. this version allows a great amount of flexibility, and it automatically refers to the camera script, it is important however that if you use this shaker, you must use the movement capsule, but you only need to use them when you gonna do the shake (although the capsule may have other oppotunities)
The only problem with this shaker is that it doesnt work when the camera is moving from position to position. How ever it does work with what i call a Follower, a Basic Tracker, this is a Follower:
;==TRACK START==
_tfollow = 0.1
_follow = 2
;Positions
_x = ###
_y = ###
_z = ###
#follow1
_follow = _follow - _tfollow
_cam camsetrelpos [_x,_y,_x]
_cam camcommit 0.01
~0.01
? _follow > 0.1 : goto "follow1"
;==TRACK END==
Because the positions are reset every 0.01 seconds, the shaker will work just fine with this.
My final goal now, is to make a shaker that can work on cameras which are moving positions. Because what my shaker will do if the camera is not still (or not tracking), it will jump to the destinate position, and will not look that good.
-
Surdus Priest
- Like already said (in couple of other threads) use the code tags when posting long pieces of code.
- You have not only violated our double posting rule but you have triple posted.
If you have something to add to your post after a short period of time (we'd prefer that about 3 days should pass), modify your post instead of replying
to yourself.