Jump to content
dystopian

Player/Playable Unit play Animation on Trigger Act.

Recommended Posts

Hello all I am working on a single player immersive Zombie mission and I am attempting to get my player to play an animation. 

I've never really done this I've normally always made the AI do them.  So I have my guy here and a trigger.  

 

His name is [p1]

I have in the Trigger act: p1 play or switchmove "AinvPercMstpSrasWlnrDnon_G01";

I walk into the Trigger and nothing.  

 

So is there something I need to know about animating an actual player not an AI unit?  

Share this post


Link to post
Share on other sites

Not sure if this will work but maybe try PlayMove rather than SwitchMove

 

just an idea to try until someone can give you the correct code (if possible). 

Share this post


Link to post
Share on other sites
p1 play or switchmove "AinvPercMstpSrasWlnrDnon_G01"; 

That's not a working syntax.

Care to give out more details on what you want to do, how it should happen and why it has to be a trigger in the first place?

 

Cheers

Share this post


Link to post
Share on other sites

Because I'm not too savvy with scripting.  

I'm trying to have this animation activate when the player reaches the height in order to "boost radio frequency";  

So the player does an animation of listening to radio for a few seconds and then back to playable. 

 

 

Any help is appreciated. 

Share this post


Link to post
Share on other sites

Ah, allright. So you want the animation to play once the player is at a certain altitude?

Could be as simple as this:

 

_playAnimAtAltitude = [player,408] spawn {

	params ["_unit","_altitudeNeeded"];

	waitUntil {sleep 1;(getPosASL _unit select 2) >= _altitudeNeeded};
	systemchat "Altitude reached. Stop to listen to the radio.";
	waitUntil {speed _unit isEqualTo 0};
	_unit playMove "AinvPercMstpSrasWlnrDnon_G01";
	systemchat "Listening to radio.";

};

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the reply however I am not sure how to find the exact altitude which is why I was using a trigger so once you climb to the desired point it activates.  

Share this post


Link to post
Share on other sites

Altitude above sea level (ASL) is displayed in the bottom left corner of the 3d editor, using the cursor position.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Sorry Old man I got no idea what the hell I'm doing here.  

I found this script searching and it spawns the Antenna for placement which is awesome, however I am currently running it in the init of an object.  

An I want it so that when the player reaches this trigger it activates the addAction, placement.  

placeBarrier = {
    grabBA = player addAction ["Grab Barrier", 
    {
        _barrier = "Land_Antenna" createVehicle position player;
        _barrier attachTo [player,[0, 5, 0]];
        player removeAction grabBA;
        call dropBarrier;        
    }];
};
dropBarrier = 
{
    dropBA = player addAction ["Place Barrier",
    {
        detach _barrier = "Land_Antenna";
        player removeAction dropBA;
    }];
};
call placeBarrier;

HOWEVER, It lets me spawn the object and move it around but when I click addaction Place Barrier it gives me an error regarding variables in:

"player removeAction dropBA;... Error undefined variable in expression: _barrier

So what exactly is the error saying?  Also I want this option only available when I hit this trigger, I have a Radio.sqf file with this in it, but when I try to activate it by trigger I get nothing... 

Share this post


Link to post
Share on other sites

That's because everything inside the script/code parameter of the addAction command has its own scope.

Variables that are defined outside of this scope don't exist there.

You can circumvent this issue by using setVariable/getVariable on the object the action is being added to.

To solve your issue try this:

//init.sqf
Dyst_fnc_placementPointReached = false;

//in trigger that activates when the player reaches your altitude point:
Dyst_fnc_placementPointReached = true;

//initPlayerLocal.sqf:
player addAction ["Grab Barrier",
{
    params ["_object","_caller","_ID"];
    _barrier = "Land_Antenna" createVehicle [0,0,100];
    _object setVariable ["Dyst_fnc_attachedAntenna",_barrier];
    _barrier attachTo [_caller,[0, 5, 0]];
    _object removeAction _ID;

},nil,1,true,true,"","_target isEqualTo _this AND isNull objectParent _this AND Dyst_fnc_placementPointReached"];


player addAction ["Place Barrier",
{
    params ["_object","_caller","_ID"];
    _barrier = _object getVariable ["Dyst_fnc_attachedAntenna",objNull];
    detach _barrier;
    _object removeAction _ID;


},nil,1,true,true,"","_target isEqualTo _this AND isNull objectParent _this AND !isNull (_this getVariable ['Dyst_fnc_attachedAntenna',objNull])"];

 

No idea what "Land_Antenna" is supposed to be, must be a mod object. Tried it with "Land_BarrelEmpty_F" and works.

 

Cheers

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

×