Jump to content
EricJ

Animating wheels on helicopter

Recommended Posts

I've been trying for the life of me trying to get wheels on a helicopter to rotate. I'd like to know a good model.cfg entry that I can use to get this working.

Share this post


Link to post
Share on other sites

I dont think helicopter wheels turn at all. The simulation type does not have that animationSource available.

Unless I remember wrong.

 

Share this post


Link to post
Share on other sites

But You can make it with this script (add it to init of chopper).

 

[heli] spawn script.sqf

and in script.sqf:


params ["_heli"];

_frontwheel = (_heli selectionPosition "wheel_F_axis_view");
_lastpoint = (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"));
_turnanim = "noseWheelTurn";
_lastpos = _heli animationsourcephase _turnanim;
_dir = 0;
_speed = 0.5;
_lastagle = 0;

while {alive _heli} do
{
waituntil {sleep 0.1; ((local _heli) && (alive (currentPilot _heli))) || !(alive _heli)};
        if ((_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"))#2 <= 0.55) then {
            if ((_lastpoint isNotEqualTo (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"))) && (_lastpoint distance2d (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound")) > 0.05)) then {
            _agle = (_heli worldToModelVisual _lastpoint) getDir (_heli selectionPosition "wheel_F_bound");

                if ((abs((_lastagle mod 360) - _agle)) > 180) then {
                    _agle = _agle-360;
                };
            _heli animatesource [_turnanim,_agle/360,_speed];_lastagle = _agle;
            _lastpoint = (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"));
            _lastpos = _heli animationsourcephase _turnanim;

            };
        }else {
            //if (_heli animationsourcephase _turnanim != 0) then {_heli animatesource [_turnanim,0,0.1];};
        };

};

Share this post


Link to post
Share on other sites

I make update of this script - with defined in wheels class fake wheels for simulate dampers for front wheel script controling animation of turning and spinig of wheel:

 

 

//if (!isServer) exitWith {};
params ["_heli"];

_time_delay = 0.1;
_lastpoint = (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"));  //last memebered position of wheel damper
_turnanim = "noseWheelTurn";  //anim name of wheel turning (left/right)
_lastanimstate = _heli animationsourcephase _turnanim; //last state of turning anim
_wheelanim = "noseWheel"; //name of animation for wheel turning around
_wheellenght = 1.88; //lenght of wheel around = (2*pi*wheel diameter)
_minimalmove = 0.02; //in meters - minmal distance when script decide to anim wheel
_minspeed = (_minimalmove/_wheellenght)/_time_delay; //minimal speed for turning wheel
_newwheel = _heli animationsourcephase _wheelanim; //new target wheel round anim state
_actualwheel = _heli animationsourcephase _wheelanim; //actual wheel turn anim state
_speedwheel = 0; //speed of turning wheel in anim value/time
_lastspeed = 0; //last measured speed of wheel turning
_dir = 0;
_agle = 0;
_speed = 0.5;
_lastagle = 0;


while {alive _heli} do
{
waituntil {sleep _time_delay; ((local _heli) && (alive (currentPilot _heli))) || !(alive _heli)};
        _time_delay = 0.1;
        if ((_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"))#2 <= 0.55) then {
            if ((_lastpoint isNotEqualTo (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"))) && (_lastpoint distance2d (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound")) > _minimalmove)) then {
                //speed of front wheel
                _speedwheel = ((_lastpoint distance2d (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound")))/_wheellenght)/_time_delay;
                hint format ["speed %1",_speedwheel];
                //turning front wheel
                _agle = (_heli worldToModelVisual _lastpoint) getDir (_heli selectionPosition "wheel_F_bound");

                    if ((abs((_lastagle mod 360) - _agle)) > 180) then {
                        _agle = _agle-360;
                    };
                _heli animatesource [_turnanim,_agle/360,_speed];_lastagle = _agle;

                //rounding front wheel
                if ((_lastspeed != _speedwheel) && (_speedwheel > _minspeed)) then {
                    _actualwheel = (_heli animationsourcephase _wheelanim);
                    _newwheel = _actualwheel + 1;
                    if ((_heli animationsourcephase _wheelanim) != _newwheel) then {_heli animatesource [_wheelanim,_newwheel,_speedwheel];_lastspeed = _speedwheel};
                };
                if ((_speedwheel < _minspeed) && ((_heli animationsourcephase _wheelanim) != _newwheel)) then {
                    _newwheel = (_heli animationsourcephase _wheelanim);
                    _heli animatesource [_wheelanim,_newwheel,_speedwheel];_lastspeed = 0;
                };
            }else {
                if ((_heli animationsourcephase _wheelanim) != _newwheel) then {
                    _newwheel = (_heli animationsourcephase _wheelanim);
                    _heli animatesource [_wheelanim,_newwheel,_speedwheel];
                    _lastspeed = 0;
                };
            };


        _lastpoint = (_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"));
        _lastanimstate = _heli animationsourcephase _turnanim;

        }else {
            if ((_agle/360) isnotequalto (_heli animationsourcephase _turnanim)) then {_heli animatesource [_turnanim,(_heli animationsourcephase _turnanim),_speed];_lastagle = (_heli animationsourcephase _turnanim)*360;};
        };

        if (!(local _heli) || !(alive (currentPilot _heli)) || ((abs speed _heli < 0.02) && !(isengineon _heli)) || ((_heli modelToWorldVisual (_heli selectionPosition "wheel_F_bound"))#2 > 10)) then {_time_delay = 1;};
};

Share this post


Link to post
Share on other sites

Thanks, I'll look into this sometime.

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

×