Home   Help Search Login Register  

Author Topic: Slow motion, pause and than rotate round missile  (Read 1935 times)

0 Members and 1 Guest are viewing this topic.

Gooner861

  • Guest
Re:Slow motion, pause and than rotate round missile
« Reply #15 on: 31 Aug 2004, 11:53:16 »
Just been playing this great mission Farcile Ground by Sui and that has something what i want, a tank gets hit by a mine the cutscene slows rite down and spins round the front of the tank.

Very cool

Gooner

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Slow motion, pause and than rotate round missile
« Reply #16 on: 31 Aug 2004, 13:34:28 »
Teh code I used to do that:

Code: [Select]
abrams setspeedmode "normal"
_c4 camsetpos [(getpos (object 91142) select 0), (getpos (object 91142) select 1) + 4,0.5]
_c4 camcommit 0
abrams lockwp true
@ getdammage abrams > 0
0 fademusic 0
setacctime 0.03
_i = 0.03
#matrixloop
_c4 camsetpos [(getpos abrams select 0) + (sin ((_i*1000)+ 120) * 10), (getpos abrams select 1) + (cos ((_i*1000)+ 120) * 10), (0.5 + (_i*5))]
_c4 camcommit 0.1
_i = _i + 0.02
setacctime (0.03 + (_i/2))
~0.05
? _i < 0.24: goto "matrixloop"
setacctime 0.25
~0.25
setacctime 0.375
~0.25
setacctime 0.5
~0.25
setacctime 0.625
~0.25
setacctime 0.75
~0.25
setacctime 1
titlecut ["","BLACK OUT",1]

The main part you'll want to look at is this:

_i = 0.03
#matrixloop
_c4 camsetpos [(getpos abrams select 0) + (sin ((_i*1000)+ 120) * 10), (getpos abrams select 1) + (cos ((_i*1000)+ 120) * 10), (0.5 + (_i*5))]
_c4 camcommit 0.1
_i = _i + 0.02
setacctime (0.03 + (_i/2))
~0.05
? _i < 0.24: goto "matrixloop"

That's the bit that rotates the camera around the abrams. It uses a trig function to move the camera 20 degrees (you can change that by changing the underlined bit) every loop.

The numbers may seem strange, but multiply them by 1000 and you'll see you get a range from 30 to 240. That's bearings from the tank... the camera moves in an arc from 30 degrees to 240 degrees, based on the setpos.
It looks nasty, but it's not too bad if you break it down.

I'm happy to explain further if you'd like ;)
« Last Edit: 31 Aug 2004, 13:37:28 by Sui »

Gooner861

  • Guest
Re:Slow motion, pause and than rotate round missile
« Reply #17 on: 31 Aug 2004, 15:48:50 »
Thanks a heap Sui.  ;D Well it does look rather difficlut at the moment but i'm willing to learn. The thing is though in my intro im concentrating more on an RPG firing at a convoy of trucks.

But i want to slow mo rite down wen it is fired and than follow the missile, like ur lose outro u have made. That was cool.

I've been looking at how u did it:

Quote
player switchcamera "internal"
_cam camsettarget atguy
_cam camcommit 5
~3
_cam camsetfov 0.1
_cam camcommit 3
~2
atguy dofire ftruck
~2
atguy dofire ftruck
_cam camsetpos [(getpos atguy select 0) - 5, (getpos atguy select 1) - 2, 1]
_cam camsettarget atguy
_cam camsetfov 0.7
_cam camcommit 0
atguy dofire ftruck
~1
atguy dofire ftruck
(leader group atguy) say "rus10"
(leader group atguy) setcombatmode "yellow"
setacctime 0.25
_now = (time + 7)
#OLatguyloop
~0.01
atguy dofire ftruck
? (atguy ammo "AT4Launcher" == 1) and (alive atguy) and (time < _now): goto "OLatguyloop"
_at4 = (nearestobject [atguy,"AT4"])
setacctime 0.05
~0.2
_cam camsetpos [(getpos _at4 select 0) + sin (getdir _at4 + 5) * 20, (getpos _at4 select 1) + cos (getdir _at4 + 5) * 20, 1]
_cam camsettarget _at4
_cam camcommit 0
setacctime 0.05
_now = (time + 2)
@ (_at4 distance ftruck < 50) or (time > _now)
setacctime 1
_cam camsetpos [(getpos ftruck select 0) + sin (getdir ftruck - 80) * 50, (getpos ftruck select 1) + cos (getdir ftruck - 80) * 50, 8]
_cam camsetfov 0.7
_cam camsettarget ftruck
_cam camcommit 0
~0.1
setacctime 0.05
#OLatloop
setacctime (acctime * 1.25)
~ (1/(acctime*22.5))
? (acctime < 1): goto "OLatloop"
setacctime 1
~3
_cam camsetpos [getpos (object 85439) select 0, getpos (object 85439) select 1, 20]
_cam camsettarget ftruck
_cam camcommit 0
_cam camsetpos [getpos (object 40149) select 0, getpos (object 40149) select 1, 20]
_cam camcommit 30
~2

Now on this thread sum guys have helped me get a type of bullet cam on the RPG which was very good as well. But i also wanna know how u kind of followed the RPG missile as it flew past the camera.

Plus, sorry keep on at you, just thinking now wud it be possible to use your rotation thing for a truck. Cos i wud like to have the RPG pause about 5 metres away from the truck, rotate round the truck and than play in normal time for a great explosion etc.

Cheers

Gooner

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Slow motion, pause and than rotate round missile
« Reply #18 on: 01 Sep 2004, 11:11:13 »
This is the bit of code I used to grab the rocket as it was going past:

Code: [Select]
_at4 = (nearestobject [atguy,"AT4"])
You have to use that as soon as the rocket is fired, as nearest object only works to 50m and the rocket is moving very fast.

Once you have given it a name (here it's called '_at4'), you can camtarget it just like anything else ;)

Feel free to use any code you'd like... just throw my name in the credits/readme somewhere ;D

Just bear in mind that you may have to do a lot of trial and error with the timings to get the movement right... I know I did...

Gooner861

  • Guest
Re:Slow motion, pause and than rotate round missile
« Reply #19 on: 01 Sep 2004, 11:53:08 »
Cheers for that, will get onto it. Just one more thing : I was looking at this bit of the script,

Quote
_cam camsetpos [(getpos _at4 select 0) + sin (getdir _at4 + 5) * 20, (getpos _at4 select 1) + cos (getdir _at4 + 5) * 20, 1]
_cam camsettarget _at4
_cam camcommit 0
setacctime 0.05
_now = (time + 2)
@ (_at4 distance ftruck < 50) or (time > _now)
setacctime 1

And was interested in this bit:
Quote
@ (_at4 distance ftruck < 50) or (time > _now)
setacctime 1

Does that just look to see that when the missile is about 50m away frm the target ftruck it will move setacctime to 1. So cud that code be used to set up the spin around the abrams:


So the script cud look like this:

player switchcamera "internal"
_cam camsettarget atguy
_cam camcommit 5
~3
_cam camsetfov 0.1
_cam camcommit 3
~2
atguy dofire tank
~2
atguy dofire tank
_cam camsetpos [(getpos atguy select 0) - 5, (getpos atguy select 1) - 2, 1]
_cam camsettarget atguy
_cam camsetfov 0.7
_cam camcommit 0
atguy dofire tank
~1
atguy dofire tank
(leader group atguy) say "rus10"
(leader group atguy) setcombatmode "yellow"
setacctime 0.25
_now = (time + 7)
#OLatguyloop
~0.01
atguy dofire tank
? (atguy ammo "AT4Launcher" == 1) and (alive atguy) and (time < _now): goto "OLatguyloop"
_at4 = (nearestobject [atguy,"AT4"])
setacctime 0.05
~0.2
_cam camsetpos [(getpos _at4 select 0) + sin (getdir _at4 + 5) * 20, (getpos _at4 select 1) + cos (getdir _at4 + 5) * 20, 1]
_cam camsettarget _at4
_cam camcommit 0
setacctime 0.05
_now = (time + 2)
@ (_at4 distance tank < 50) or (time > _now)

Then add the spin around the tank

i = 0.03
#matrixloop
_c4 camsetpos [(getpos tank select 0) + (sin ((_i*1000)+ 120) * 10), (getpos tank select 1) + (cos ((_i*1000)+ 120) * 10), (0.5 + (_i*5))]
_c4 camcommit 0.1
_i = _i + 0.02
setacctime (0.03 + (_i/2))
~0.05
? _i < 0.24: goto "matrixloop"


Now obviously bits wud have to be changed but cud that be done?

Cheers

Gooner

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Slow motion, pause and than rotate round missile
« Reply #20 on: 01 Sep 2004, 12:36:31 »
Yeap... you've got the idea :)

If you remeber that loose outro, the camera cuts to a side view of the truck just before the rocket hits. That's how I did it.

You could do exactly the same thing with your tank scenario. I'd up the distance slightly though... remember that rocket is travelling really fast ;D

Do some experimentation and see what looks good and what doesn't... I'm happy to answer any more questions you might have.

Gooner861

  • Guest
Re:Slow motion, pause and than rotate round missile
« Reply #21 on: 01 Sep 2004, 16:31:28 »
Quote
You could do exactly the same thing with your tank scenario

I dnt wanna copy your work, im only interested in the techniques used, been very helpful though. Your mission gave me alot of ideas  ;D .

Anyway this is another query that i've been trying to figure out.

Ok so you have all the cutscenes in scene.sqs, i opened up the mission in the editor but couldn't find any triggers that activated the cutscenes .

Like for example at the minefield part where the tank gets hit, i went to that exact place but cudnt find anything that cud of activated the cutscene. Im i just being blind or was there another technique.

Thanks for your help, been very interesting  ;D

Gooner

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Slow motion, pause and than rotate round missile
« Reply #22 on: 02 Sep 2004, 10:59:49 »
I use another wierd scripting technique in that mission to try to cut down on cpu time...

Instead of using a whole bunch of triggers to activate things, I have a single looping script (trigs.sqs I think I called in in that mission), which acts as the triggers instead.

From memory, the tank cutscene is activated by checking when the convoy is approaching Larche... when it gets close enough the 'trigger' calls the scene.sqs, and plays the cutscene...

Gooner861

  • Guest
Re:Slow motion, pause and than rotate round missile
« Reply #23 on: 02 Sep 2004, 18:59:00 »
Ahhhh i see ok thanks for the feedback  :) .
I'll leave this thread open incase i encounter any problems with my camera script, but i won't be doing that for a while now. Im concentrating now on my mission, its shaping up pretty nice at the moment. (But not as good as yours, sadly  :'( )

Anyway thanks,

Gooner