OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dmakatra on 02 Apr 2003, 16:22:57

Title: frequently asked camcreate Q
Post by: dmakatra on 02 Apr 2003, 16:22:57
Hi! I know this Q has been asked several times but I didnÂ't find anything while using the search function. Sry. :-[ :-*

How do I camcreate something 1 meter behind a guy, two meters in front of a guy, three meters right to a guy and 1 meter infront of a guy etc. Y axis are unimportant. Please help.

Thx in advance.
Title: Re:frequently asked camcreate Q
Post by: macguba on 02 Apr 2003, 16:47:20
when you camcreate something you have to specify the position.   And, as you know, there are lots of ways of specifying a position.

camcreate [getPos loon1 select 0, (getPos loon1 select 1) + 1, 0]

will create the thing 1m from the loon at ground level.     Hey, setRelPos might even work, who knows.   syntax not guaranteed of course.

To get it in front you might need to use getDir and some trigonometry.
Title: Re:frequently asked camcreate Q
Post by: dmakatra on 02 Apr 2003, 17:07:46
OK. I have tried a couple of tests but I canÂ't get it to work. I only get it over me or not at all.
Title: Re:frequently asked camcreate Q
Post by: macguba on 02 Apr 2003, 17:17:09
If you can get it on top of you we are half wa there.    The next bit is just getting the syntax right ..... do what I suggested but make it 10 rather than 1, 1m is a bit close.   What happens then?
Title: Re:frequently asked camcreate Q
Post by: dmakatra on 02 Apr 2003, 17:20:09
If you can get it on top of you we are half wa there.    The next bit is just getting the syntax right ..... do what I suggested but make it 10 rather than 1, 1m is a bit close.   What happens then?

Same thing.
Title: Re:frequently asked camcreate Q
Post by: macguba on 02 Apr 2003, 17:22:16
lol that's a bit annoying.    Copy and paste the command you're using here so I can see it.
Title: Re:frequently asked camcreate Q
Post by: Artak on 02 Apr 2003, 17:25:13
setrelpos is the answer to your question.


_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal","back"]

_cam camsettarget moped
_cam camsetrelpos [-2,10,3]
_cam camcommit 0


Will create the camera 2 meters left 10 meters in front and 3 meters above the moped. Really nice command. I use it a lot.
Title: Re:frequently asked camcreate Q
Post by: dmakatra on 02 Apr 2003, 17:25:35
I just saw that it was the same as the one you set height! I told ya I have tested a bit, and know IÂ'm back at the start ;).

Back to work. Added the zero on the end as in your version. The error text came up.

Error 4 elements provided, 3 expected
Title: Re:frequently asked camcreate Q
Post by: dmakatra on 02 Apr 2003, 17:29:31
setrelpos is the answer to your question.


_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal","back"]

_cam camsettarget moped
_cam camsetrelpos [-2,10,3]
_cam camcommit 0


Will create the camera 2 meters left 10 meters in front and 3 meters above the moped. Really nice command. I use it a lot.

Hmmm. How do you camcreate a building for instance with the setrelpos?
Title: Re:frequently asked camcreate Q
Post by: macguba on 02 Apr 2003, 17:31:08
If its a camera you want, go with Artak.  

Or is it an object, like you want a table to appear out of thin air?
Title: Re:frequently asked camcreate Q
Post by: dmakatra on 02 Apr 2003, 17:43:50
an object. Like a bomb.
Title: Re:frequently asked camcreate Q
Post by: Artak on 02 Apr 2003, 17:52:36
Oh yeah right.. you want to
Quote
camcreate something
not a camera. Didn't read that too well did I   :D

I've never done it but basicly what you'd need to do is combine getdir with your camcreate command.
So
something = "something" camcreate [(getpos someone select 0)+2,getpos someone select 1, getpos someone select 2]
won't work because the guy could be facing any direction and the above would always set the item 2 meters east of him.

I'm puzzled.
Title: Re:frequently asked camcreate Q
Post by: macguba on 02 Apr 2003, 18:06:11
It can certainly be done, its just a question of converting polar coordinates [5m in front of the loon] to cartesian coordinates [x,z].     20 years ago I could have done it in my head.  Now I can't.    We need a 15 year old to do the trig.     OFP has trig functions, so that's no bother.

What bothers me more is that Armsty hasn't got the wretched thing to appear just 5m away in any direction yet.    That's the first problem.
Title: Re:frequently asked camcreate Q
Post by: titan on 02 Apr 2003, 21:54:01
i dont know much about cords. but if you want to create smething so it gets created from an object then try this...

explode = "heat120" camcreate getpos unitname


the wep cld be changed to other types of explosives,  i dont know anything about objects like buildings or tables. trying to find that myself!
Title: Re:frequently asked camcreate Q
Post by: Sui on 03 Apr 2003, 01:49:56
You're after a big of trig...

I surprised you didn't find anything on this with a search, as I seem to remember answering this question a few times now... but anyway.. ;)

Here's a generic example line:

object = "objecttype" createvehicle [(getpos unit select 0) + sin (getdir unit + bearing) * distance, (getpos unit select 1) + cos (getdir unit + bearing) * distance, 0]

Looks like fun, huh ;D
It's actually much simpler than it looks. I'll use the first part (the X co-ord) as an example:

(getpos unit select 0) + sin (getdir unit + bearing) * distance

Breaking it down into parts:
The bit with the Y co-ord is exactly the same, except that sin is replaced with cosin, and the (getpos unit select 0) is (getpos unit select 1), as we're now working with the Y axis ;)

So a couple of practical examples:

1m behind the guy:
object 1 = "objecttype" createvehicle [(getpos unit select 0) + sin (getdir unit + 180) * 1, (getpos unit select 1) + cos (getdir unit + 180) * 1, 0]

3m to the right of the guy:

object 2 = "objecttype" createvehicle [(getpos unit select 0) + sin (getdir unit + 90) * 3, (getpos unit select 1) + cos (getdir unit + 90) * 3, 0]

Just a quick note: use createvehicle rather than camcreate. Since it can now create munitions, createvehicle has superseeded camcreate...

By the way... I'm a bit older than 15, Macca ;D ;D
Title: Re:frequently asked camcreate Q
Post by: Artak on 03 Apr 2003, 07:59:52
*cough*

Sui just typed down what we all were thinking..  :P ::)


 ;D


/me kneels before his master, Sui
Title: Re:frequently asked camcreate Q
Post by: dmakatra on 03 Apr 2003, 08:20:52
* Armsty follows Artak and just to be sure, he sacrifises Macguba to the god * ;D

:cheers: Sui :D! IÂ'm gonna test it when I get back home. Right now I only can spare 5 min :'(. And the answer to the search. Well, laziness actually. I didnÂ't know what to search for except 'camcreate' and then I got a heck lot of hits... Anyway, thx a lot!

IÂ'm gonna sacrifise my pillow just to be sure... Man, momÂ's gonna be pissed... ;D
Title: Re:frequently asked camcreate Q
Post by: macguba on 03 Apr 2003, 10:21:01
What a memory you have ::)

I can't even remember how to do basic trig, and I have a physics degree.   There should be an expiry date on these things.   Oh the shame.    At least I knew the principle.
Title: Re:frequently asked camcreate Q
Post by: Sui on 03 Apr 2003, 10:29:36
Hehe :)

Well, to tell you the truth I cheated a little then...

I was re-taught how to do that during my Degree. Vector addition is needed to account for wind when you're navigating...

Though now-days I have an electronic nav calculator to do it for me ;)