OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: acepilotray on 05 Sep 2005, 05:41:39

Title: set velocity wont work
Post by: acepilotray on 05 Sep 2005, 05:41:39
when i try to use this setvelocity 10 i get a message that says "unknown operator setvelocity"
how do i use the setveloty code
Title: Re:set velocity wont work
Post by: Fragorl on 05 Sep 2005, 06:32:22
SetVelocity. (http://www.ofpec.com/editors/comref.php?letter=S#setVelocity)

Velocity takes an array of 3 numbers, similar to setpos.

example
plane setvelocity [100,100,0]

The numbers say in which direction along each of the axes, and how fast, the plane travels.
The numbers do not depend on the direction the plane is facing. Rather they relate to directions on the map. The first number is the east-to-west component (+100 means going east on the map). the second is the south-to-north component (+100 means north). The third number is the upwards/downwards component. +10 would mean up. -10 would mean down.

How fast the plane travels after this can be calculated by pythagoras' theorem.

You can also calculate the direction of movement using trig. Using the sin and cos functions, you can make the plane move in what ever direction it's facing.

Example
car setvelocity [10*sin(getdir car),10*cos(getdir car),0]
Title: Re:set velocity wont work
Post by: macguba on 05 Sep 2005, 12:10:30
Velocity is a vector:  it has both magnitude and direction.

Speed is a scalar:  it has only magnitude.

Velocity and speed are fundamentally different.
Title: Re:set velocity wont work
Post by: 2nd Ranger on 05 Oct 2005, 20:06:08
Hello,

I have been wondering about this for a while. I was curious if setvelocity could determine the speed of a chopper when the game begins.

What I mean by that is - if you start a chopper in the air, the mission doesn't begin with the chopper flying along its waypoint. It first has to accelerate before it actually moves. Could setvelocity be used to make the helo be moving when the mission starts?

If not, is there another way to do this?
Title: Re:set velocity wont work
Post by: Kyle Sarnik on 05 Oct 2005, 21:00:30
Hello,

I have been wondering about this for a while. I was curious if setvelocity could determine the speed of a chopper when the game begins.

What I mean by that is - if you start a chopper in the air, the mission doesn't begin with the chopper flying along its waypoint. It first has to accelerate before it actually moves. Could setvelocity be used to make the helo be moving when the mission starts?

If not, is there another way to do this?

You could, but I would advise against that. I know from experience that it is crucial to let the AI choppers do their thing at the start of a mission. The reason it takes AI so long to start moving at the start of a mission is because they first have to climb/descend to the proper altitude that they wish (or are ordered) to fly at. AI are very anal about this, and will do this before even starting to move forward. If you force him to go right away, I can't garuntee that he won't stop or slow down to adjust his altitude. Another thing is that if you use setvelocity at the start, its like pushing the helicopter forward before its ready to fly forward (it will still be level, won't have enough horizontal thrust, etc...) and so that can cause problems too. I don't understand why you just can't wait a little for the chopper to start, it only takes a few seconds. And if you don't want anyone to notice, then just black the screen out for a few seconds.
Title: Re:set velocity wont work
Post by: Triggerhappy on 05 Oct 2005, 22:32:16
@acepilotray
(in addition to what mac and frag said) you need to use trig to do what you're trying. since setvelocity is not relative to the unit it is affecting, you need to factor in the direction of the thing you're setting the velocity for

so, the code for pushing it 10 m/s in the direction its facing:

this setvelocity [10*cos(getdir this),10*sin(getdir this),0]