Home   Help Search Login Register  

Author Topic: Velocity  (Read 974 times)

0 Members and 1 Guest are viewing this topic.

Offline ezol

  • Members
  • *
  • blah
Velocity
« on: 04 Jul 2005, 23:29:56 »
I'm having trouble getting velocity scripts to work consistantly.
The scripts are fairly simple. i.e. Move a Tank at a set velocity
(0,5,0) etc. Repeating it every second etc.

The only problem is that whilst the script works well if executed  very early in the mission, if it's executed after a while, possibly after shots are fired it fails to do anything. Sometimes the tanks will start moving as execpted after being shot themselves (by me) ?

Hopefully I'm just doing something dumb.
Copy of failing script attached

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Velocity
« Reply #1 on: 04 Jul 2005, 23:45:17 »
setVelocity [0,5,0] will always set your tank's velocity at 5 m/s north. So whilst this will work if the tank is pointed directly north or south (since the velocity will be in the driection of the tank's tracks), it probably wont do anything much if the tank is pointed east or west, except give it a small shunt.

If you want the tank to always move forward, you'll need trig.
e.g.
setVelocity [5*sin(getDir _tank), 5*cos(getDir _tank), 0]

Offline ezol

  • Members
  • *
  • blah
Re:Velocity
« Reply #2 on: 04 Jul 2005, 23:52:27 »
I don't think velocity works like that. I've got no trouble with the direction they're heading, with velocity you can get them to fly etc. The main problem is they don't seem keen on velocity commands half way through a mission.

qqqqqq

  • Guest
Re:Velocity
« Reply #3 on: 05 Jul 2005, 00:04:45 »
Fragorl is correct.   It does work like that.

How do you call the script?
« Last Edit: 05 Jul 2005, 00:09:22 by qqqqqq »

Offline ezol

  • Members
  • *
  • blah
Re:Velocity
« Reply #4 on: 06 Jul 2005, 01:14:20 »
I've used several different calling methods, triggers when the enemy are destroy,  scripted timed call and a radio call.

With the radio it works fine if executed at or very near the beginning of a preview mission (basically simulates vehicles floating and landing on beach). It just doesn't work when execute after a while.

Sounds vague I know and there's probably an obvious error
(the direction of the vehicles is consistant with the velocity settings).  I was hoping that this might be a well known noobie issue that requires a simple line of code and alls well etc.

Not to worry thanks for the time anyway. I may post something if I find a good reason why it don't work but if it's embarassing I probably won't.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Velocity
« Reply #5 on: 06 Jul 2005, 03:37:10 »
i think your problem is that the tanks are sinking... :P

cause there is nothing in the script to keep them up

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Velocity
« Reply #6 on: 06 Jul 2005, 10:46:45 »
i think your problem is that the tanks are sinking... :P

cause there is nothing in the script to keep them up


Agreed. :) If you you are trying to keep tanks from sinking in water, then this won't work. Sure, you set their verticle (z) velocity to 0, but you have a huge delay (depending on how many tanks you have) before you do it again. In the meantime, the tank is still falling. You would need a constant loop. Try removing the ~0.01 delay in your script. Replace it with the following:
@true
Which is the shortest possible delay one can have in a script.

If that doesn't work, then you might have to give the tanks some upwards velocity each time, in order to fight the downward pull of gravity.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

qqqqqq

  • Guest
Re:Velocity
« Reply #7 on: 06 Jul 2005, 12:39:17 »
I asked how do you call the script, not where do you call it from.  Perhaps I should have been clearer and asked for an example.    Quoting a script without giving an example of a call is giving only half the story:   many script problems are caused by mistakes in the exec command.