Home   Help Search Login Register  

Author Topic: Set The Velocity Of An Object, and set Distances  (Read 2603 times)

0 Members and 1 Guest are viewing this topic.

RunAwayScientist

  • Guest
Set The Velocity Of An Object, and set Distances
« on: 09 Feb 2003, 21:40:53 »


     Heh heh, here I go again...

         We've all seen it, Police Pursuits. The Police effectivly attempt to ram the car off the road. What if this were in OFP? What if a car rammed into the other one, causing damage to both vehicles, and in OFP, they'd both stop and the drivers jump out. Then the office simply walks up to him, and the suspect is arrested...Yay!

        My question is, how do I set the velocity of an object, or detect the velocity of an object in, of course, Kilometers per Hour. And, my other queestion, is how do I set the distance between two objects (Preferably Cars).

       Basically, what I'd like to do, is to make a car speed just enough to close the gap between him and a nice Red Speeding car. Say the Speeding car is going 80, and the car that's trying to close to gap, whatever speed neccesary to ram the Red Car.

        Ehhh, any ideas on the matter, or do I ask too many hard questions? Err...Do I?

     -RunAwayScientist

Kaliyuga

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #1 on: 09 Feb 2003, 22:41:56 »
It's possible..   just need a couple of triggers.. or a script ....

the command you're gonna be looking for is :

this setvelocity  [x,y,z]


perhaps you could make a repeatable trigger.. with this as it's condition:

car1 distance car2 > 10

and something like this as the activation...

car2 setvelocity [x,y,z]  

you'd have to fool around with the numbers , but this would result in car2 getting a small boost of speed whenever the gap between car1 and car2 exceeded 10 meters....

if using scripting.. you could also incorporate a loop where the chase car was getting the position of the lead car every few seconds.. and then the driver was told to move to that exact position.....  instead of having to use waypoints at all....

Kaliyuga

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #2 on: 09 Feb 2003, 23:22:19 »
u can just use da speed command

speed carname - wil give u da speed of da car in KMH

or if u want da velocity use

velocity carname - give u array wid da velocity in X axis Y axis and Z axis

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #3 on: 10 Feb 2003, 04:02:13 »

       Ehhh, and distance?

    I don't think there is a setvelocity command, a Speed command, or a Velocity command. I've not tried your suggestions, but if there were such commands, this post wouldn't be here...heh heh, kinda of makes ya think eh?

    -RunAwayscientist

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #4 on: 10 Feb 2003, 04:16:13 »

     Wait, There is a Speed command. I just found it...The command I can't find is SetSpeed and SetVelocity...You sure about that?

       I'll try out the suggestions, not sure if it'll work or not....

   Thanks for your help, and suggestions...Err..I think...(Eats Cherry Pie)

   -RuNAwayScientist

Kaliyuga

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #5 on: 10 Feb 2003, 06:23:21 »
Works fine for me ::)   what version of OFP are you running ? ;)

make an empty jeep..... name it j  
make yourself a West Soldier...
make a trigger....  activated by West present
activation:  j  setvelocity [1,111,5]

then get in the jeep... and drive into the trigger.. watch what happens


Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #6 on: 10 Feb 2003, 06:40:29 »
dere is no setspeed command but

hre is a qoute from da command referance

Quote
vehicle setVelocity [x, z, y]

Operand types:
vehicle: Object
[x, z, y]: Array
Type of returned value:
Nothing
Description:
Set velocity (speed vector) of vehicle.

and a link setVelocity command

or da velocity command

Quote
velocity vehicle

Operand types:
vehicle: Object
Type of returned value:
Array
Description:
Return velocity (speed vector) of vehicle as array [x, z, y].

and a link Velocity command

or da speed command

Quote
speed obj

Operand types:
obj: Object
Type of returned value:
Number
Description:
Object speed (in km/h)

Example:
speed player



and a link Speed command

dats bout it i think :P

muhahahhahhahhaa

nd now u have 2 change us sig line and write somin like

"I kiss LCDs legs 4 teachin me da wrong from da right and 4 takin time and givin me links 2 da command referance - I wil never think da Cartel member is wrong"

and go 2 da Eveon Cartel website and D/L all da addons

and

if u stil have time go 2 da beta testing forums and test all da misions i made ;D

muhahahahahhahahahahahahaha

 ::) ::) ::) ::) ::) ::) ::)

LCD OUT

@ OFPEC mods - i woke up in strange mod 2day  ::)
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #7 on: 11 Feb 2003, 07:02:52 »

"I kiss LCDs legs 4 teachin me da wrong from da right and 4 takin time and givin me links 2 da command referance - I wil never think da Cartel member is wrong"

       Uhhh...A Couple of Grammar mistakes...It should be:

   ""I kiss OFPEC 4 teachin me da wrong from da right and 4 takin time and givin me links 2 da command referance - I wil never think da OFPEC Cartel Team Member is wrong, but that of right."

     There we go....

        Ehh, setVelocity escaped me a couple of times, no wonder I had no idea about that command...Same thing for the "Speed" command...To think I just heard about it, after my Experience? Compared to the time the U.N. takes, I think I'd win...Heh, heh....

    Well, thank you for your help. Maybe I should stick with SetSpeedMode...It sets the basic acceleration for the unit, which builds up to speed over time, rather than having a "setSpeed" Function Command (HInt Hint, run and do yo scriptin' thing now), CodeMasters put in SetSpeedMode...

       Yay for CodeMasters! (Boo...Don't tell them anything, they're watching me...They got me once, but never again man!)

     Once again, thanks for you help...As my Random Insanity Continues do excpect more questions, and I think that a "SetSpeed" Function would really prove...Well...Functional to a mission...

  -RunAwayScientist

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #8 on: 11 Feb 2003, 13:11:30 »
OFPEC didnt give u links 2 nothin  :P

only da EC have power were i post (and prooly Tomb  and BM  ::))

i gave u links 2 da CR

da EC wil chace u 4 ever

m stopin 2 answer ur Qs  :P  ;D

but bout da function thingy - just gotta make funtion dat find da direction of da vehicle and give him reight setvelocity :P - but im not gonna right it :Pcuz ill never help u ahgain  ;D

 ;D ;D ;D ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #9 on: 12 Feb 2003, 04:39:22 »


     Uhhh, are you high on Cartel or something?

      Man, I love your MOD though. Mind if I ask a question? Is your MOD based on GTA3, and with all the gangs and Gang Type Activity going on there? It seems like it, and a very, very, interesting mod indeed.

          -RunAwayScientist

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #10 on: 12 Feb 2003, 10:46:11 »
high is my ever status  :o :wow: :toocool:

and da mod is not based on GTA3 :P we are da Everon Cartel not GTA3 based MOD  :P :P ;D

but well have looooots of gang activity around  ;)  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #11 on: 12 Feb 2003, 10:52:04 »
just saw wat u wrote 2 sui

Quote
                        I love you Sui man! Err...Not literally...Really, not Literally...Oh you think I'm gay now eh? C'mon, I'll be here all week...Again...Eating Cherry Pie on the Can...Wait, does the Can refer to a Soda Can, or a Can-Can (I think I can!)? There's too many cans...

  RunAwaySci list "Cans";
  RunAwaySci exec "BlowUp.sqs";
  RunAwaySci exec "Just Kiddin'.sqs";
  RunAwaySci globalchat "BOOM!";
  RunAwaySci globalchat "Just kiddin'...";
  RunAwaySci globalchat "Heh, I didn't even need to script it...wait, did that bomb have a timer? Uh oh...";
  RunAwaySci action ["(Open Cell Phone)"];
  RunAwaySci action ["(Call Mommy)"];
  RunAwaySci globalchat "MOMMMIIIII!!!!!";
  RunAwaySci AskChat "Do I really need ";" at the end of my commands in a scrip? I mean, it's like a huge activation field, right? Right?!!!!";
  RunAwaySci exec "End;.sqs";


        Ehhh, I just kind of got a little creative there, with all the numbers   and all...Ow, my eye hurts. I can't make it stop! I can't make it stop! AHHH!  

      Thanks for your help Sui, all hail and praise the might Sui...Heh heh, Sui Corn, Sui Potatoes, Candy is Sui. Sui is kind of like "Sweet", but more Mexican/Spainish/Canadian/American/Black/Japaneese/PyJingo type language...Ehh, don't ask me, he's the Mexican/Spainish/Canadian/American/Black/Japaneese/PyJingo  person.

        -RunAwayScientist

and he is OFPEC mod y u r not hailing OFPEC wid him ?  :P

just hail me and get over wid it ;) - or u can just solve dat thread ccuz u dont have probs wid dat nymore  ;D

LCD OUT

[edit] and u dont need ; @ da end of each line in script  ;)
« Last Edit: 12 Feb 2003, 10:52:34 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #12 on: 16 Feb 2003, 08:30:36 »

          Well, and distances?

     -RunAwaySci

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #13 on: 23 Feb 2003, 19:06:55 »

   Well, my question remains unanswered...Ehh, a little help plz? Anyone that can help me from the top?

     -RunAwayScientist

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #14 on: 23 Feb 2003, 20:24:17 »
distance wat ?  ::)

u got da distance command ;D

wat u exactly need on distances ? ;D (use full words 2 describe it cuz i didnt lear all da english shortname 4 everything  ::)) (beter even describe wat u meen ;D)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

teeBore

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #15 on: 25 Feb 2003, 07:03:19 »
Hey RunAwaySci, if you still have a question about speed and velocity in OFP, I'll be glad to help you broi cos I have it pretty much figured. I just don't exactly know what you are asking.

No offende LCD but why r u aint help da man who ask da question, probly cos r u not spekin englais my frien?

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #16 on: 25 Feb 2003, 12:27:27 »
@ teebore - just wait a sec  :P - read wat u write and read my latest posts

Quote
I just don't exactly know what you are asking.

No offende LCD but why r u aint help da man who ask da question, probly cos r u not spekin englais my frien?

Quote
probly cos r u not spekin englais my frien?

both from teebore

im on da same situation - i donno wat he wants :P

Quote
distance wat ?  

u got da distance command

wat u exactly need on distances ?

(from me)

bout da englih thingy - im stil beter dan u :P
- and 2 think english is my 3rd lang

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

teeBore

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #17 on: 28 Feb 2003, 05:12:42 »
yeah sorry LCD, I didn't take the 30 minutes needed to decipher your posts, so I didn't take them into account. ;)

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #18 on: 28 Feb 2003, 18:01:23 »
lol

dere is special dictionary ;D

from LCDish 2 Tombish and den u need 1 from Tombish 2 ny oder lang ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #19 on: 01 Mar 2003, 23:33:27 »

   Alright dudes, stop sniffing the same Cartel.

        Lemme explain what I'd like in a litte more detail (Sense).

       What I want, is to be able, to tell a driver of a car, to follow another car, at a certain distance from it.

       An example of this, is in the game itself. Remember those nice fire fights, where you stuck close to your leader? He cussed you out and to return to formation? The yellow box dancing around your leader?

     In Even More Sense: When in a formation, a unit under command of the leader stays in (Formation). A certain distance away from the leader. How do you do this?

      In othere words, what I'd like:

    - A Police Car to ram a suspects car.

    -Hence, the distance required for the Police Car to stay away from the Suspect is 0.

    -Meaning, the Police car will try to keep a distance of 0, between him and the Suspect.

      -Because it's 0, the Police car will try to drive directly ontop of the car, meaning that it'll ram it.

    Think about it, if you set Car2's required distance to Car 1 to 5, that means it'll follow 5 Meters behind. But what if it was 0? Then Car2 would drive right into Car1.

      Understand? If not, stop taking cartel, get help, buy a new wife, sell your kids, eat milk, drink chocolate, and above all...Don't get glad, get Happy!!

     -RunAwayScientist

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Set The Velocity Of An Object, and set Distances
« Reply #20 on: 02 Mar 2003, 07:34:40 »
dere is no way 2 do it exactly but u can try dat (wil b more or less)

Code: [Select]
_car = _this select 0
_destcar = _this select 1
_distance = _this select 2

#loop
if  (_car distance _destcar > _distance) then {
_car stop false;
_car move getpos _destcar;
}
else {_car stop _true}
if (_car distance _destcar < (_distance+5)) then {_car setspeedmode "limited"} else
{
if (_car distance _destcar > (_distance+20)) then {_car setspeedmode "full"} else {_car setspeedmode "normal"}
}
~1
goto "loop"

hop i didnt make ny syntax erors ;D

LCD OUT
« Last Edit: 02 Mar 2003, 07:36:11 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Quantum69

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #21 on: 03 Mar 2003, 05:30:58 »
Heres the script I threw together that may work for you:

; used to place aircraft at a given altitude and speed
;
; input: [object, altitude, speed] (based off map placed heading)
;
; Quantum69
;
_ac = _this select 0
_alt = _this select 1
_spd = _this select 2

_x = (getpos _ac) select 0
_y = (getpos _ac) select 1
_z = (getpos _ac) select 2

_ac setpos [_x, _y, _alt]

_curdir = getdir _ac

_raddir = _curdir * 0.0174

_xvel = _spd * (sin _raddir)
_yvel = _spd * (cos _raddir)

_ac setvelocity [_xvel, -_yvel, 0]

exit

I put this together because I didn't like the initial setting of "Flying" for the aircraft.  You can delete the altitude section and just use the velocity section.

Of note;
        It's cos(y) and sin(x) because North is 0 degrees, if it were sin(y) and cos(x) then EAST would be 0 degrees.  Also, it's (-yvel) because North and South values are backwards.  COS and SIN work with RADIANS, so that's why it's (current direction * 0.0174), 0.0174 radians per degree:  1 radian = 1 degree * (PI / 180).

"One day algebra will save your life."  Val Kilmer, RED PLANET

Hope it helps,
Quantum69

RunAwayScientist

  • Guest
Re:Set The Velocity Of An Object, and set Distances
« Reply #22 on: 09 Mar 2003, 02:36:58 »

    Ehhhhhhhhhhhhhhhh.....I believe this script sets the INITIAL speed, and altitude. But I don't think it makes the computer AI driving the Car, stay at that speed. Am I correct?

     Well I must say, it's very elaborate, and might be of use to other people in different instances.

      Remember, what I'm trying to achie-!!!!

     I just thought of something....Lemme finish my scentence...

       Remember, what I'm trying to achieve is the same idea when you keep formation, while another AI Commands you.

        Alright, remember the Single Player mission, the first level? Remember how when you followed your Commander around, there was that yellow box, that told you exactly where to stand in formation?

        Same idea here, except I want the little formation box, to be right over a Suspect's car, meaning the Police Officer's car will ram into it.

         Well, now to my brainstorming idea! (Rains Brains)

       What I just thought of, is how the yellow box kind of resembles it's large cousin, the Waypoint box. The WayPoint box tells you were to go.

         What if I were to kind of create, a waypoint of the Suspect's car for the Cop to follow. And I don't mean the 'move' command. Kind of like the destroy command, or so.

       Well, what are your thoughts scripters, and modders? Come to me! I've got Key Lime Pie!!!!

          -RunAwayScientist ('Can't we all just, get along? Or does Peace Not Last So Long?' - RunAwayScientist)