Official Soldat Forums
Soldat Fans => Developers Corner => Topic started by: vehicledestroyer on October 22, 2010, 02:29:56 pm
-
I'm developing and advanced weapon editor. Soldat Weapon Factory (http://forums.soldat.pl/index.php?topic=38866.0) 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-
-
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.
-
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...
-
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. :)
-
Thank you very much Clawbug. The whole SWF Team is ecstatic to start work on implementing this into Soldat Weapon Factory (http://forums.soldat.pl/index.php?topic=38866.msg478402#new). which is now in beta.... Go download it!!
-
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)
-
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.
-
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-
-
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 don't follow the question
-
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.
-
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.
-
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.
-
No problem, that concept is used all the time in programming and physics especially programming physics engines or games.