Home   Help Search Login Register  

Author Topic: tracker for shaking  (Read 3503 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
tracker for shaking
« 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
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #1 on: 10 Jun 2007, 13:25:48 »
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"?

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #2 on: 10 Jun 2007, 13:30:49 »
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
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #3 on: 10 Jun 2007, 13:33:27 »
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?

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #4 on: 10 Jun 2007, 13:39:11 »
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?
Campaigns are hard, I'll stick with scripting for now!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #5 on: 10 Jun 2007, 13:45:00 »
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
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #6 on: 10 Jun 2007, 13:48:04 »
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.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #7 on: 10 Jun 2007, 13:55:34 »
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
Campaigns are hard, I'll stick with scripting for now!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #8 on: 10 Jun 2007, 14:02:08 »
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?
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #9 on: 10 Jun 2007, 15:29:28 »
Sorry, but now I really have no idea at all what you are really trying to do in your cutscenes.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #10 on: 10 Jun 2007, 15:32:12 »
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?
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #11 on: 10 Jun 2007, 16:02:31 »
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?

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #12 on: 10 Jun 2007, 16:31:28 »
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
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #13 on: 10 Jun 2007, 16:41:45 »
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.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #14 on: 10 Jun 2007, 16:45:59 »
so i'd need to resume the previous camera?
Campaigns are hard, I'll stick with scripting for now!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #15 on: 10 Jun 2007, 16:59:42 »
so how to i check the conditions?
Campaigns are hard, I'll stick with scripting for now!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #16 on: 10 Jun 2007, 17:06:45 »
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
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: tracker for shaking
« Reply #17 on: 10 Jun 2007, 17:08:29 »
just punt a hint format["%1 %2 %3", _ox, _oy, _oz] and youll find out what that does

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: tracker for shaking
« Reply #18 on: 10 Jun 2007, 17:51:30 »
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.
Campaigns are hard, I'll stick with scripting for now!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: tracker for shaking
« Reply #19 on: 10 Jun 2007, 19:04:39 »
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.
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.