Home   Help Search Login Register  

Author Topic: how to make cam follow an object?  (Read 1293 times)

0 Members and 1 Guest are viewing this topic.

dez

  • Guest
how to make cam follow an object?
« on: 20 Jan 2003, 01:00:47 »
i cant get it, it wont follow an object, the camera just stays where it is, how do you get it to, say,  follow 1 meter away from object while the object  moves?  ???

sentience104

  • Guest
Re:how to make cam follow an object?
« Reply #1 on: 21 Jan 2003, 14:17:18 »
check the tutorial; I think it covers that (and much more)

BUNTRO

  • Guest
Re:how to make cam follow an object?
« Reply #2 on: 25 Jan 2003, 03:41:56 »
Hello....
Here is a simple script that you can use:  All you have to do is put the following in the ini field:

[name of object being followed] exec "followcam.sqs";

***followcam.sqs***

_object = _this select 0

#loopcam
_timer = _timer + 1
_camera = "camera" camCreate [0,0,0]
_camera cameraeffect ["internal","back"]
_camera camsetTarget _object
_camera camsetrelpos [x,y,z]
_camera camCommit 0
~0.001
?(_timer == 600): goto "spass"
goto "camloop"

#spass
_camera cameraeffect ["terminate","back"]
camdestroy _camera


Now I have set this up on a timer so that when _timer =600, then the camera shuts off and it goes back to normal first person view.  This is about 6 seconds if I remember right.  Anyways, you could set this up with triggers to end the script when the object moves over that trigger (i.e. when a solder walks over the trigger).  Now if you look at the line where I put camsetrelpos, you'll notice this: [x,y,z].  Here is where you put the distance you want the camera from the object you want to view.  In the X value, a postive number will put the camera to the left of the person while a negative puts it to the right.  For the Y value, a positive will put the camera in front of the object, while negative puts it behind.  And for the Z value, a positive for above the object and a negative for below the object.  For putting in these values, you have to think of the object being in the center of a graph chart with x, y, and z planes.  The origin is where your object is and the camera is set at whatever coordinates you tell it facing towards your object.  If you have any further Q's, post them here of look up Snyper's cam scripting tutorial in the editors depot for furthur info.  Hope this helps!

BUNTRO   :beat:

Jester

  • Guest
Re:how to make cam follow an object?
« Reply #3 on: 25 Jan 2003, 18:44:42 »
BUNTRO, I take it that the _object in the script is the name that you assign to the unit that you want the cam to follow? I am a nOOb so pardon me for the question.

Offline KTottE

  • Former Staff
  • ****
Re:how to make cam follow an object?
« Reply #4 on: 25 Jan 2003, 19:14:26 »
It's all right there.

[unitName] exec "followcam.sqs"

that's how you start it, in a trigger or init field or whatever.

Then

_object = _this select 0

Gets unitName and puts it in the variable _object.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

TakanoFukada

  • Guest
Re:how to make cam follow an object?
« Reply #5 on: 16 Feb 2003, 01:55:50 »
hey, what if the object is actually a round? Eg. A TOW or LAW... can I still attach the camera to the ammo as soon as it is fired ?

I tried with this :
this addeventhandler ["Fired", {if ((_this select 1) == "TOWLauncher") then {TOW switchcamera "internal"}}]

but i still couldn't get the camera to follow the round... must I insert a line in init.sqs or something to 'label' the round?

can someone please help? would appreciate it..
« Last Edit: 16 Feb 2003, 01:59:45 by TakanoFukada »

Cedaie

  • Guest
Re:how to make cam follow an object?
« Reply #6 on: 16 Feb 2003, 07:32:38 »
hmm, In this situation there is only really one other way I know of, because the way your asking means the bullet would need a variable name, which, I can't see how we could get that.

The only real option is to have the camera as the bullet, then dolly the camera into its target  :-\

Unless you create a flying object the shape of a bullet, in which case it's all possible.

Cheers  :P

TakanoFukada

  • Guest
Re:how to make cam follow an object?
« Reply #7 on: 16 Feb 2003, 07:45:47 »
hv the camera as the bullet? can you kindly advice on how would I go about doing that? cos I just started out this scripting thing recently and I have not reach that level of scripting competency yet.  :o

actually, what i'm would like to do is to lock the camera onto a missile that has IRLOCK... so after the missile is fired without a LOCKED target, the user would be able to steer the missile to a target in real-time...  much like a Stinger missile... but I can't seem to find anything like that ! has this been done before?

some samples or help would be useful here....  ;)

thanks !!!
« Last Edit: 16 Feb 2003, 08:03:11 by TakanoFukada »

Bedlam

  • Guest
Re:how to make cam follow an object?
« Reply #8 on: 04 Mar 2003, 11:38:55 »
ive tested the script looks nice

but return to the player after dont work..

something wrong with the timer function?

this works:

_object = _this select 0
_timer = 0

#camloop
_timer = _timer + 1
_camera = "camera" camCreate [0,0,0]
_camera cameraeffect ["internal","back"]
_camera camsetTarget _object
_camera camsetrelpos [0,0,0]
_camera camCommit 0
~0.0001
?(_timer == 100): goto "spass"
goto "camloop"

#spass
_camera cameraeffect ["terminate","back"]
camdestroy _camera
« Last Edit: 04 Mar 2003, 22:23:32 by Bedlam »

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:how to make cam follow an object?
« Reply #9 on: 04 Mar 2003, 23:48:04 »
I noticed a few niggles about the script. ONe was that the camera doesn't need to be created over and over every thousansth of a second. THe other is that the reserved variable _time can be used for the timer.

Try this out for size:
This would create a camera that follows "unit1" from 1 meter behind and 1 meter above group for 60 seconds
Code: [Select]
[unit1,60,[0,-1,1]] exec "follow.sqs"



Code: [Select]
_object = _this select 0
_duration = _this select 1
_position = _this select 2

_camera = "camera" camCreate [0,0,0]
_camera cameraeffect ["internal","back"]

#camloop
_camera camsetTarget _object
_camera camsetrelpos _position
_camera camCommit 0
~0.001
?(_time > _duration): goto "spass"
goto "camloop"

#spass
_camera cameraeffect ["terminate","back"]
camdestroy _camera
exit

« Last Edit: 16 Apr 2003, 08:21:30 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Poet

  • Guest
Re:how to make cam follow an object?
« Reply #10 on: 15 Apr 2003, 17:45:03 »
 ???

Being the utter  noob I am, Im struggling with this.

So far, I have a nice cutscene, using a simple .sqs file, everything working fine, and a helo ( unit name bob2 ) taking off.

I then want to track the helo for a few seconds, then get the camera to switch to another target.

I dont see how I can launch a script from within a script, and I tried to copy the code above, but dont know where to put my unit name in?

Any help would be greatly appreciated.
Thanks.

Offline KTottE

  • Former Staff
  • ****
Re:how to make cam follow an object?
« Reply #11 on: 16 Apr 2003, 08:10:19 »
toady, wouldn't you have to execute it with:

[name, time[position]] exec "script.sqs"

[name,time[position] looks wrong to me.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:how to make cam follow an object?
« Reply #12 on: 16 Apr 2003, 08:22:35 »
toady, wouldn't you have to execute it with:

[name, time[position]] exec "script.sqs"

[name,time[position] looks wrong to me.


LOL the yabb code strips one of the closing brackets at the end. Look at your post.

Here it is:
Code: [Select]
[unit1,60,[0,-1,1]] exec "follow.sqs"
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline KTottE

  • Former Staff
  • ****
Re:how to make cam follow an object?
« Reply #13 on: 16 Apr 2003, 10:26:02 »
Bah, stupid shit ;D

Ok, then I follow you.

edit

Okay, so I'm using this wonderful script, simple and direct, and I'm trying to do a sequence where I cut between several "chase" angles, and it's a bit difficult to time the cuts.
What I do is through the main cutscene script I call this script with the proper syntax, but then when I want to switch to the other angle (just a jumpcut, not trying anything fancy such as swinging the camera around just yet) it goes bonkers.
I have a wait (~) that is the same lenght as the displaytime of the script.
So if I want to run it for 5 seconds I have the wait as 5 in the main script, so it doesn't continue ahead of time.
Anyway, what happens when it's supposed to switch is that it doesn't run the second one.
But when I put a longer wait, say 6 seconds, it works, except it shows the players point of view for that extra second.
Gonna try with very short extra length (5.001) and see if it works better, but otherwise, I'm gonna need yer help ;D

edit

Tested it again, and now it works with the exact time, but it flinches. I.E the view hops around as if you had a glitch in your screen or something. I think this is because the script doesn't take into account the angle of the vehicle. I'm doing it with a chopper, and I think it goes flinchy when it lowers/raises it's nose.
Worth looking into.
« Last Edit: 16 Apr 2003, 12:33:11 by KTottE »
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"