Jump to content
Sign in to follow this  
D. Patterson

Math Issues

Recommended Posts

_Shell = "Sh_120mm_HE" createvehicle [((_Pos select 0) - (sin _dir * 900)),((_Pos select 1) - (cos _dir * 900)),(1500 + _Height)];    
_Shell setVelocity [(sin _dir * 202.8), (cos _dir * 202.8), -338]; 

This is the relevant parts of my code. That 900 might need to be fixed to compensate for the fact that the shell bleeds velocity as it travels, but as it stands it should be off by the same amount every time. However depending where I execute it on the map, and what direction I use, I get different results. For example 50m wide right on the East side of the island might end up 50m wide left on West side. 180 degrees might miss by 5m, 270 degrees might miss by 30m.

Share this post


Link to post
Share on other sites

can you please clarify with real use case what is wrong and what you expect as result ? :)

Share this post


Link to post
Share on other sites

Like @code34 stated, elaborate further what you're trying to achieve.

 

Setting the velocity might not be enough, certain projectiles use some kind of glideslope/air friction.

If you're trying to apply a velocity to such an object you need to make sure it has the proper direction first.

Also try using setVelocityModelspace.

 

Cheers

Share this post


Link to post
Share on other sites

It's for an achilles module. Basically I want to click on a point on the map and actually see the shells rain down. The sh120he looks like a giant white tracer. It works as of right now, it's just not accurate.

Share this post


Link to post
Share on other sites

This seems to consistently hit:

MakeArtyStrike = {
    params ["_targetASL", "_fromDir", ["_shellClass", "Sh_120mm_HE"]];
    private _altitude = 1500;
    private _horizDist = 900;
    private _horizSpeed = 202.8;
    private _vertSpeedCorrectionFactor = 0.908;
  
    private _flightTime = _horizDist / _horizSpeed;
    private _spawnPosASL = _targetASL getPos [_horizDist, _fromDir];
    _spawnPosASL set [2, (_targetASL select 2) + _altitude];
    private _shellVelocity = [0,0,0] getPos [_horizSpeed, _fromDir-180];
    _shellVelocity set [2, -(_altitude / _flightTime * _vertSpeedCorrectionFactor)];
    private _shell = _shellClass createVehicle _spawnPosASL;
    _shell setPosASL _spawnPosASL;
    private _upDir = _spawnPosASL vectorFromTo _targetASL;
    _upDir set [2, 1 + (_upDir select 2)];
    _shell setVectorDirAndUp [
        (_targetASL vectorDiff _spawnPosASL),
        _upDir
    ];
    _shell setVelocity _shellVelocity;
    _shell
};

[getposasl target, 280] call MakeArtyStrike;

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×