Author Topic: Bullet Trajectory  (Read 5711 times)

0 Members and 1 Guest are viewing this topic.

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Bullet Trajectory
« on: October 22, 2010, 02:29:56 pm »
I'm developing and advanced weapon editor. Soldat Weapon Factory I'm looking for Soldat's bullet trajectory formula, variables, constancies, and units of measurement. Can anyone provide detail on how bullet trajectory is calculated; and how it is related to the weapon.ini "speed=x" value. I have messaged EnEsCe requesting this information, but he never replied.

-The Soldat Weapon Factory Team-
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Bullet Trajectory
« Reply #1 on: October 25, 2010, 02:23:12 am »
Well if you ever did projectile motion in physics at school, it is pretty much that, but I think there is also some makeshift air resistance in the y axis.

Pretty sure there is a hack which draws the path of the bullets on the screen. Maybe you could just find it and then ask the maker how he did it, would probably be faster than trying to contact enesce or mm.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Re: Bullet Trajectory
« Reply #2 on: October 25, 2010, 03:59:49 pm »
I think there is also some makeshift air resistance in the y axis.

We were able to find this out so at least we're on the right track.

Pretty sure there is a hack which draws the path of the bullets on the screen. Maybe you could just find it and then ask the maker how he did it,

Would you or anyone else know the name of this hack? I guess it would be against forum rules to post a link to it. You can PM me it...

would probably be faster than trying to contact enesce or mm.

I did ask enesce, but I'll ask him again as well as ask MM. Though I doubt either one would even reply...
« Last Edit: October 25, 2010, 04:01:22 pm by vehicledestroyer »
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline Clawbug

  • Veteran
  • *****
  • Posts: 1393
  • 1184!
Re: Bullet Trajectory
« Reply #3 on: October 25, 2010, 05:20:16 pm »
declare speed.x/speed.y/X/Y/Z and assign their values to something.
60(?) times a second:
    move bullet on x axis by speed.x/Z;
    move bullet on y axis by speed.y/Z;
    speed.x -=/*= X;
    speed.y -=/*= Y;

Just modify X, Y and Z and you should be "close enough". Or, take a debugger and skim through the code. :)
Fight! Win! Prevail!

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Re: Bullet Trajectory
« Reply #4 on: October 25, 2010, 07:11:00 pm »
Thank you very much Clawbug. The whole SWF Team is ecstatic to start work on implementing this into Soldat Weapon Factory. which is now in beta.... Go download it!!
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Bullet Trajectory
« Reply #5 on: October 25, 2010, 11:10:31 pm »
    speed.x -=/*= X;
    speed.y -=/*= Y;
Just to clarify, speed.x will have to be *='ed, with X being between 0 and 1, and speed.y will need to be -='ed by some unknown number (which could possibly be 0.06 which is soldats default gravity setting in the scriptcore)
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline TmTgr

  • Retired Soldat Developer
  • Major
  • ******
  • Posts: 55
Re: Bullet Trajectory
« Reply #6 on: November 04, 2010, 12:44:52 am »
speed = value in ini file divided by 10
a = angle of aim

Initial x/y speeds:
dx = cos(a) * speed;
dy = sin(a) * speed;

Initial x/y position:
x = (player gun x) + dx * 7;
y = (player gun y) + dy * 7;



every tick (60 times per second):

x += dx;
dx *= 0.99;

dy += 0.135;
y += dy;
dy *= 0.99;

These should be pretty much correct. The only part I am not sure about is the initial position.

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Re: Bullet Trajectory
« Reply #7 on: November 04, 2010, 01:11:09 am »
Thanks TmTgr! I was just stoping by the forums to ask for more information and then I saw your post. This made my day, I have been having trouble with SWF (mostly the Team) and this will be good new for us all. Expect this to be implemented into SWF in the next week.

Thanks everyone! ;)
-Thee Vehicle Destroyer-
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Re: Bullet Trajectory
« Reply #8 on: December 19, 2010, 05:41:59 pm »
What equations do you use to get the triangle to use the trig functions in these equations?;
dx = cos(a) * speed
dy = sin(a) * speed
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Bullet Trajectory
« Reply #9 on: December 19, 2010, 08:12:41 pm »
I don't follow the question
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Re: Bullet Trajectory
« Reply #10 on: December 19, 2010, 10:51:40 pm »
To use COS and SIN fictions you need a right angled triangle.

With regards to the initial x/y speed of the bullet;
The x/y of the player will be referred to as X and Y.
The initial x/y of the bullet will be referred to as DX and DY.
The x/y of the cursor will be referred to as PX and PY.

Now, the COS and SIN functions only work with a right angled triangles, and every triangle has three points. The first point of the triangle is X and Y (because DX and DY currently equal 0; they have not been calculated). The second point is PX and PY. That gives us a line. You need to tell me where the third point lies, such that it creates a right angled triangle.
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Bullet Trajectory
« Reply #11 on: December 20, 2010, 01:32:38 am »
Diagram is on its way.

aand here it is.

Basically, the triangle is only used to solve for the horizontal and vertical components of the velocity, it isn't actually there.
« Last Edit: December 20, 2010, 01:37:00 am by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline vehicledestroyer

  • Soldier
  • **
  • Posts: 120
  • I'm a Soldat freelancer, and I'm Looking for work.
    • Crash Commando Kings
Re: Bullet Trajectory
« Reply #12 on: December 21, 2010, 04:37:46 pm »
Thanks again chutem, as always very helpful and this will be a big help in my project.

From Teolant:

Ha! This makes things even easier; thank god. I was assuming that we'd have to keep moving it (it == the third point) so it was a completley perfect triangle, but we don't. Now we're ready to use the formula. Yes, it's *that much easier now*!
God I'm excited about this being so less complicated.

We're all excited to get this part of SWF done. Thanks from everyone here at the SWF team.
I am a Soldat freelancer. I'm looking for projects and I have some of my own. I'm ready when you are...
My Projects:
Soldat weapon Factory 1.1
A community appeal
GTA II Mod

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Bullet Trajectory
« Reply #13 on: December 21, 2010, 08:20:23 pm »
No problem, that concept is used all the time in programming and physics especially programming physics engines or games.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs