OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Rellikki on 18 Jun 2009, 20:14:22
-
Let's imagine that I have an object, a road for example, which will every time have a different spawning position and a direction. I was wondering if it's possible to spawn another object, which would always be next to the road on a specific side? This would be of course piece of cake with a simple, basic setPos command, if the road was always facing the same direction, but that wouldn't always be right, because of the random direction of the road. I hope you know what I mean.
So as I asked, is it possible to spawn the another object always on a specific side of the road, regardless of the road's angle?
Edit: Here's two pictures of what I had in mind for better understanding. 4 different examples in each of the pictures. The orange arrow resembles the road and its random direction and the green dot resembles the other object which I want to be on the specific side.
Notice how in the first picture the green dot is always on the same side from the road's angle. That's how I want it to be.
(http://rellikki.armaholic.eu/paska/prsgd.jpg)
However, this happens with just a simple setPos command, which I don't want to happen:
(http://rellikki.armaholic.eu/paska/prsbd.jpg)
-
Trust me Im no genius on this stuff but I would play with a "dowatch" command and coordinnate that with a "deletevehicle" command.
Im not sure how you are placing a stretch of road but if you have an object placed ahead on the road then you could have a soldier unit look at the object immediately, then have a trig delete him with a time of "2".
Then I would use a setpos command for an item to his right after 1 second.
This would have the soldier appear on the road, and look down the road at initialization. Then the object you need to appear would show up after 1 second, (to his right) then the soldier gets deleted another second later.
Truthfully I have no idea if this would work, and I have no idea how the roadway is random in direction but maybe those commands will help?
-
I'm not really sure what you mean by that. ??? What's the soldier for?
Im not sure how you are placing a stretch of road
I'm using an editor update to place roads. ;) The random direction of it is made with a script, but that's another story...
Then I would use a setpos command for an item to his right after 1 second.
Well, the problem here is that I don't know how to return a specific side of an object from its angle...
-
Easy solution:
Place.sqs
_obj1 = _this select 0
_obj2 = _this select 1
_ang = _this select 2
_dis = _this select 3
_h = _this select 4
_p=getpos _obj1
_d=getdir _obj1
_a=_d+_ang
_r=[(_p select 0)+_dis*sin _a,(_p select 1)+_dis*cos _a,(_p select 2)+_h]
? local _obj2 : _obj2 setpos _r
exit
Now execute this file with the following parameters:
[first_object,second_object,relative_angle,relative_distance,relative_height] exec "Place.sqs"
first_object: Is the object that is used as center, your roadway
second_object: Is the object that should be placed relative to the first, after spawning of course
relative_angle: For the right side use 90, for left use -90 or 270, or any other desired value
relative_distance: The distance object2 should have to object1
relative_height: The relative height, mostly 0
[road1,car7,90,2,0] exec "Place.sqs"
will place car7 to the right side of road1 in a distance of 2m and at the same height as road1...
If the calculation of the height of object1 brings up an unexpected value, play a bit with the input parameter until object2 shows up at the desired height.
:)
-
Sorry for the late reply.
I just tried that out and it seems to work all fine, so thanks. :)