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) *
distanceBreaking it down into parts:
- (getpos unit select 0)
Gets the X co-ord of the unit you want to place your object around
- sin (getdir unit + bearing) * distance
Here's the business end of it... Using a bit of trig, it gets the sin of the direction the unit is facing, adds any bearing you want, and moves the object out to the distance you specify. So:
unit - The unit you are placing the object relative to
bearing - The offset in relative bearing from the unit where you want the object placed.
Eg. 0 = directly in front of the unit
180 = directly behind the unit
90 = to the unit's right.
Try to imagine a circle of degrees around the unit, with 0 at the top and 180 at the bottom...
distance - the distance from the unit you want the object to be placed.
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