Okay, so 1.85 had given us a new toy to play with...
setVelocityFrom what i can tell, you can use it on vehicles, and some vehicles have some restrictions. Tanks, for example, can not be launched into the air. It does not seem to affect people at all.
I guess you will all see this when the new ComRef is released, but I think this is how it works...
vehicle setVelocity [x-component,y-component,z-component];Where vehicle is whatever you want to affect and the x-axis is west-east, the y-axis is north-south, and the z-axis is up-down.
Basically, it represents velocity in vector form. If you are not familiar with vectors, here will be a rather crappy explanation in terms of OFP... (It is intentionally not mathematically precise, but we are not doing rocket science.)
##########Crappy Vector Explanation:
(skip if you know how to deal with vectors)
Imagine a set of three-dimensional axes (three lines perpindicular to each other all intersecting a point). One line points east (positive x), one points north (positive y), and one points up (positive z).
Imagine your jeep in OFP is standing still where all those lines meet, facing in any direction, it does not matter. Let us say you want to launch it straight up with a speed of 50 (Anyone know what the proper units are?). You type
jeep setVelocity [0,0,50]; and the jeep springs straight up towards the heavens.
Now let us say you want to throw it to the west at a speed of 20. Notice that the positive direction for the x-axis is east, so the y-component must be negative. Type
jeep setVelocity [-20,0,0]; and watch your jeep look like it was hit by a truck and zoom westward.
Okay, now say you want to really catapult your jeep to the North, but you want it to arc. You want to shoot it at a speed of 100 (powerful catapult you have there) at an angle of 30 degrees from the ground. (If you have taken physics, you are problably groaning right now.) It helps if you draw yourself a diagram. Draw a right triangle with a 30 degree angle. Set it up so the right angle is to the bottom left of the diagram. Here, up is up and right is north. The hypotenuse is of length 100, so use your super trigonometry skills to figure out what the other sides are... Notice that you do not alter the velocity of the jeep in the west-east direction, so that value remains zero. So you type
jeep setVelocity [0,(100*(cos 30)),(100*(sin 30))]; and buckle up, you are in for a ride.
I will let you try to figure out the rest yourself...
##########Okay, so this is a very useful command. A couple ideas that come to mind:
- Hydraulic catapult for launching planes.
- Boosters for cars (like in Knight Rider).
- Throwing sh*t around.
- Insanely realistic mortar scripts.
One problem is that direction values are in terms of angle, where 0 or 360 degrees is north, so you will have to convert to vector notation. Let us say you want a "nitro" script that boosts a car in whatever direction it is driving. You want to keep it realistic so you want to conserve the jeep's original velocity in the jump, meaning if the car is sliding backwards at a speed of 20 and the boost makes you go 30 forward, you only go 10 forward. Here would be the working command for the script (SJ stands for superjeep, your cool boosting jeep)...
SJ setVelocity[(40*(sin getDir SJ))+(velocity SJ select 0),(40*(cos getDir SJ))+(velocity SJ select 1),(velocity SJ select 2)];Try it, it works! Now you can make it better by requiring the vehicle to be on the ground (getPos superjeep select 2 < .3) or by creating a loop so you can ramp it and simulate acceleration.
The
velocity command works similar, by the way, it just returns the array containing the vector of the vehicles current velocity. Like if you are driving a jeep straight north on a flat road at a speed of 50,
velocity jeep returns the array [0,50,0]. You can use the select command with this.
Here is a little script I cooked up for seeking something out:
_seek = _this select 0
_hide = _this select 1
_speed = _this select 2
#loop
_seekpos = getPos _seek
_hidepos = getPos _hide
_diff0 = (_hidepos select 0)-(_seekpos select 0)
_diff1 = (_hidepos select 1)-(_seekpos select 1)
_diff2 = (_hidepos select 2)-(_seekpos select 2)
_vecmag = sqrt(abs(_diff0)*abs(_diff0) + abs(_diff1)*abs(_diff1) + abs(_diff2)*abs(_diff2))
_seek setVelocity [(_diff0/_vecmag)*_speed,(_diff1/_vecmag)*_speed,(_diff2/_vecmag)*_speed]
~.01
goto "loop"
_seek is the seeking object, _hide is the target, and _speed is how fast the seeker can go. Try it out.
Discuss setVelocity here, and if you have any questions, post them or PM me, I will try to answer them. (Finally, vector algebra is coming in handy. ;D )