How to make a ballistic weapon arc just a little

How to make a ballistic weapon arc just a little

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

How to make a ballistic weapon arc just a little

Post by Erik »

Hijacking: How to make a ballistic weapon arc just a little, i only saw the "hightrajectory" tag (which has a ridiculus arc height)?
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: How to make a ballistic weapon arc just a little

Post by Das Bruce »

Don't hijack threads. You're allowed to make your own.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: How to make a ballistic weapon arc just a little

Post by FLOZi »

Play around with gravityAffected = true and various myGravity = x settings, as well as the velocity of the weapon.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How to make a ballistic weapon arc just a little

Post by Google_Frog »

For a Cannon make the weaponVelocity high or myGravity low.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to make a ballistic weapon arc just a little

Post by Forboding Angel »

Google_Frog wrote:For a Cannon make the weaponVelocity low or myGravity high.
Fixed :-)
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How to make a ballistic weapon arc just a little

Post by Google_Frog »

From my understanding he wants it to arc "just a little" not a lot, as in a mostly flat trajectory. Your fixes are wrong forb.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to make a ballistic weapon arc just a little

Post by Forboding Angel »

If your ballistic shot is so fast that the trajectory is flat, you slow down the projectile and it will start being fired in an arc. OR You increase gravity on the projectile so that the unit must aim higher to get more distance. My fixes are very right.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: How to make a ballistic weapon arc just a little

Post by Erik »

a problem i encountered with this is that the procetile isn't fired at the maximum range and also has problems with targeting higher terrain.

What i want would be: behaviour similar to "hightrajectory" aka fire in the air with at least 45 degrees angular but without the shot going to the moon and back.
Perhaps the missile weapontype is more usefull for that?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: How to make a ballistic weapon arc just a little

Post by knorke »

Erik wrote:Perhaps the missile weapontype is more usefull for that?
imo yes, it has the TrajectoryHeight tag.
ie TrajectoryHeight = 2.5
->arc is 2.5 times as high as long
usually needs turnrate to hit though.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to make a ballistic weapon arc just a little

Post by Forboding Angel »

Yeah knorke is right. Achieving that kind of angle and still getting maximum range on a cannon weapontype is very difficult if not outright impossible. In this way, missiles are a lot easier to get along with.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How to make a ballistic weapon arc just a little

Post by Google_Frog »

Forboding Angel wrote:If your ballistic shot is so fast that the trajectory is flat, you slow down the projectile and it will start being fired in an arc. OR You increase gravity on the projectile so that the unit must aim higher to get more distance. My fixes are very right.
This appears to be a misunderstanding stemming from the colloquial phrase 'just a little'. I interpret it that he wants a reduction of value; 'just a little, not a lot'. Whereas you interpreted it as 'just a little more than the current nothing'.

Using a missile is not a good solution. A missile will not look like a ballistic projectile, the arc and velocity is not quite the same, it doesn't gain or lose ranged based on height in the same way (I know this one can be modified, but it wouldn't look balistic).

A 45 degree firing is easy but a bit tedious. Set myGravity on the weapon to something around 0.1-0.2 depending on weaponVelocity and range. Here is an example:
  • range = 820
  • weaponVelocity = 300
  • myGravity = 0.11
Those are some values to give you a sense of scale, if weaponVelocity is higher or range lower you can set myGravity higher.

Then execute this algorithm:

Code: Select all

While (not fedUp)

    if actualRange < range then 
         decrease myGravity

    if angle < 45 degrees then 
         increase myGravity 

    restart Spring
end while
actualRange can be measured by spawning a unit in the top left corner of the man and checking the position of the range ring. Check the tooltip for position numbers, they have the same units as range.

angle can be measured by 'eyeing-off' the projectile as your unit fires, scroll down to look at it side on.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to make a ballistic weapon arc just a little

Post by Forboding Angel »

45 degrees isn't just a little. It's quite a bit. But as I originally stated. You would achieve it by increasing gravity or decreasing velocity.

Google, I dunno when the last time you messed with ballistic projectiles was, but the synopsis is this: Lower velocity = more arc (come on, this just makes sense... When you are throwing a baseball as far as you can you don't throw it flat, you arc it so you get more distance, it works the same way in spring).

Increasing gravity is similar to lowering velocity (in effect, you actually are lowering velocity... in a way). But that's all retarded theory of BS bla bla. If you want a faster projectile, then increase velocity and gravity and you will have your arc with a fast moving projectile. The inverse applies, etc etc.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How to make a ballistic weapon arc just a little

Post by Google_Frog »

Google_Frog wrote:
Forboding Angel wrote:If your ballistic shot is so fast that the trajectory is flat, you slow down the projectile and it will start being fired in an arc. OR You increase gravity on the projectile so that the unit must aim higher to get more distance. My fixes are very right.
This appears to be a misunderstanding stemming from the colloquial phrase 'just a little'. I interpret it that he wants a reduction of value; 'just a little, not a lot'. Whereas you interpreted it as 'just a little more than the current nothing'.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: How to make a ballistic weapon arc just a little

Post by FLOZi »

Getting ballistic weapons to fire exactly (well, so long as map gravity is ~120) at 45 degrees at their maximum range is easy btw.

Code: Select all

local GRAVITY = 120

for weapName in pairs(WeaponDefs) do 
	if WeaponDefs[weapName].customparams then
		if WeaponDefs[weapName].customparams.howitzer then
			WeaponDefs[weapName].weaponvelocity = math.sqrt(WeaponDefs[weapName].range * GRAVITY)
		end
	end
end
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: How to make a ballistic weapon arc just a little

Post by knorke »

FLOZi wrote:GRAVITY = 120
Game.gravity?
or does that not work in _post file?

missile/ballistic depends on what you need.
if you just want a slight arc so that tanks can fire over each other when in close formation, I found missiles easier to use.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: How to make a ballistic weapon arc just a little

Post by FLOZi »

knorke wrote:
FLOZi wrote:GRAVITY = 120
Game.gravity?
or does that not work in _post file?.
Bingo, not available at defs loading stage.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: How to make a ballistic weapon arc just a little

Post by KDR_11k »

Just force it with myGravity, keeps maps from fucking with your balancing.

Anyway, cannons in Spring are simulated according to physics and since the bullets are fired at a fixed speed the angle varies according to the target distance. If you want a hightrajectory shot to stay low then slow the projectile down. If that decreases the range then you are asking the impossible from your gun, that it shoots a bullet further than physically possible given the velocity it's fired at. Many games cheat and vary gravity or something to make their shots arc at 45┬░ at any range but Spring isn't designed for that nonsense.
User avatar
KingRaptor
Zero-K Developer
Posts: 838
Joined: 14 Mar 2007, 03:44

Re: How to make a ballistic weapon arc just a little

Post by KingRaptor »

Old page by Evil4Zerggin, dunno if it's still accurate.
Weaponvelocity and Range
If a weapon with a ballistic trajectory does not have enough weaponvelocity, it will not be able to hit its listed range.

To hit a target at the same level as the firer, the required weaponvelocity is given as follows:

v >= sqrt(gR)

where v is the weaponvelocity, R is the desired maximum range, and g is the map gravity. If the target is directly above the firer, this becomes

v >= sqrt(2gR)

Map gravity rarely exceeds 150 or so, and most firing points are elevated above surface level, so 150 is generally a good minimum value to use for g.

Weaponvelocity and Firing Angle

More generally speaking, if the firing angle is a, the angle needed to hit a target at the same level as the firer is given by

a = arcsin(gr/v^2)/2

where r is the distance to the target. From this, the following will cause the firing angle to differ more from 45 degrees:
  • Low map gravity.
  • A close target.
  • High weaponvelocity.
User avatar
SirDario
Posts: 1
Joined: 16 Feb 2012, 09:19

Re: How to make a ballistic weapon arc just a little

Post by SirDario »

KDR_11k wrote:Just force it with myGravity, keeps maps from fucking with your balancing.

Anyway, cannons in Spring are simulated according to physics and since the bullets are fired at a fixed speed the angle varies according to the target distance. If you want a hightrajectory shot to stay low then slow the projectile down. If that decreases the range then you are asking the impossible from your gun, that it shoots a bullet further than physically possible given the velocity it's fired at. Many games cheat and vary gravity or something to make their shots arc at 45┬░ at any range but Spring isn't designed for that nonsense.
Nicely done.
In second thought, if a high powered ballistic weapon fired at its maximum or limit distance that would probably do a curve trajectory on it bullet,right?

Vindicator wrote:Field target cross bows are usually hand-made, often home-made by their users.
Last edited by SirDario on 21 Feb 2012, 08:53, edited 1 time in total.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How to make a ballistic weapon arc just a little

Post by Google_Frog »

Idk exactly what you mean so I'll just say a few broad things. Some may be relevant.

A weapon cannot shoot further than it's range. The physical properties (velocity, gravity etc...) have no effect on this fact.

More distance fired = greater fire pitch. Weapon velocity is unchanged, pitch is used to aim between distances.

Projectiles with gravity always curve.
Post Reply

Return to “Game Development”