Jump to content

Recommended Posts

Hi,

 

I am trying to add a new functionality for a Spike launcher that we have in our mod.

This functionality consists in that once the missile is launched you can control the point of impact manually (as seen in the video).

For this I have created an invisible vehicle:

Quote

class cfgVehicles
{
    class Car_F;
    class FFAA_InvisibleTargetVehicle_base_F: Car_F
    {
        displayName = "Invisible Vehicle Target";
        //model = "\A3\Structures_F\Training\InvisibleTarget_F.p3d";
        model = "\ffaa_spike_data\InvisibleTargetVehicle.p3d";
        side = 0;
        scope = 2;
        faction = "OPF_F";
    };
};

 

 

and this is the code that controls the missile (you can test it easily, in any mission with a Titan AT turret):

Quote

// V5

SPK_sensitivity_1 = 0.6;
SPK_MEM = false;

_this addEventHandler ["Fired", {
    _this spawn {
        params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];

        // camera setup
        _cam = "camera" camCreate (position _projectile);
        _cam camSetTarget [0,0,0];
        _cam cameraEffect ["internal", "BACK"];
        _cam attachTo [_projectile,[0,1,0]];
        _cam camSetFov 0.03; 
        _cam camCommit 0;

        // Objective setup
        _target = createVehicle ["FFAA_InvisibleTargetVehicle_base_F",[0,0,900],[],0,"CAN_COLLIDE"];
        _target allowDamage false; 
        _target setVehicleTIPars [1, 1, 1];         

        // DEBUG ------
        _dummy = createVehicle ["VR_3DSelector_01_default_F",[0,0,900],[],0,"CAN_COLLIDE"];
        _dummy attachTo [_target,[0,0,0]];
        // DEBUG ------

        // In case of a previous locked target
        _actualTarget = missileTarget _projectile;
        if(!isNull(_actualTarget))then{_target attachTo [_actualTarget,[0,0,0]];};

        // At the beginning we put the position of the objective to where the camera is looking.
        _target setPos (screenToWorld [0.5,0.5]); 

        // Management of the missile once fired ...
        while { alive _projectile } do {

            // Camera reset
            _cam camSetTarget _target;
            _cam camCommit 0;

            // Objective reset
            _projectile setMissileTarget _target;

            // Heading reset
            _target setDir (getDir _projectile);
            _sensitivity_aux = SPK_sensitivity_1;
            
            // Missile target movement
            /*             
            if (inputAction "TurnRight" > 0) then   {_target setPos (_target getRelPos [_sensitivity_aux, 90]);};
            if (inputAction "TurnLeft" > 0) then    {_target setPos (_target getRelPos [_sensitivity_aux, -90]);};
            if (inputAction "MoveForward" > 0) then {_target setPos (_target getRelPos [_sensitivity_aux, 180]);};
            if (inputAction "MoveBack" > 0) then    {_target setPos (_target getRelPos [_sensitivity_aux, 0]);};    
            */

            _sensitivity_aux = 0.01;
            if (inputAction "TurnRight" > 0) then   {_target setPos (screenToWorld [0.5+_sensitivity_aux,0.5]);};
            if (inputAction "TurnLeft" > 0) then    {_target setPos (screenToWorld [0.5-_sensitivity_aux,0.5]);};
            if (inputAction "MoveForward" > 0) then {_target setPos (screenToWorld [0.5,0.5+_sensitivity_aux]);};
            if (inputAction "MoveBack" > 0) then    {_target setPos (screenToWorld [0.5,0.5-_sensitivity_aux]);};    
            

            // Missile lock change
            if (inputAction "lockTarget" > 0 AND !SPK_MEM) then  {
                SPK_MEM = true;
                if !isNull(cursorTarget)then{
                    if(isNull attachedTo _target)then{
                        _target attachTo [cursorTarget,[0,0,0]];
                    }else{
                        detach _target;
                    };
                };
            }else{
                if(inputAction "lockTarget" == 0)then{
                    SPK_MEM = false;
                };
            };

            systemChat format["SENS: %1",_sensitivity_aux];

            sleep 0.001;
        };

        // Finishing
        _cam cameraEffect ["terminate", "BACK"];
        camDestroy _cam;
        deleteVehicle _target;
        _gunner switchCamera "INTERNAL";

        // DEBUG ------
        deleteVehicle _dummy;
        // DEBUG ------
    };
}];

 

 

 

Problem:
I don't know why the setPos doesn't behave as we expect in the hills. Even if we give it the order to go down, it always goes up in the same direction.

Video to reproduce:

 

How it works From 0:00 to 1:00
Arma 3 1:00 to end

 

Thx,

 

Spyke.

Share this post


Link to post
Share on other sites

Unless I am wrong setPos does some collision checks which can alter the Z coordinate 

 

try setposATL or setposASL instead

 

 

Edited by gc8
meant set not get
  • Thanks 1

Share this post


Link to post
Share on other sites

@gc8 thx for your reply.

 

I have tested it with setposATL and setposASL but the isse persists.

Share this post


Link to post
Share on other sites

Firewill has done it with one of his missiles. You should look through some of his stuff. I think his PDF guide that comes with AWS details it.

  • Thanks 1

Share this post


Link to post
Share on other sites

@beno_83au I have been looking and I have found this:


It hasn't been released yet, although the code is public: https://github.com/itc-addons/ITC_Land_Systems/tree/feature-spike/Addons/itc_land_spike

 

I would like my code to work, it's a loot simpler than his code and the only thing "not working" is the setPos 😞.

Share this post


Link to post
Share on other sites

SOLVED:

With the help of Leopard20 on the Arma 3 Official Discord.

 

_target setPosWorld AGLToASL (screenToWorld [0.5+_sensitivity_aux,0.5]);

  • Like 1

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

×