Page 1 of 1

PlayThread

Posted: Wed Dec 04, 2019 5:42 pm
by Hodo33
I have a door with a wheel that turns when you open it. When you close the door it should turn the wheel the other way.

%door.setThreadDir(0,true);
%door.playthread(0,"Wheel");
%door.stopThread(0);

%door.setThreadDir(0,false);
%door.playthread(0,"Wheel");
%door.stopThread(0);

This does not work.... seems stopThread resets the seq to frame 0
I changed the anim to not be cyclic and still does not work.
What am I doing wrong here?

Re: PlayThread

Posted: Wed Dec 04, 2019 11:00 pm
by Azaezel
function smartPlayThread(%obj,%anim,%direction)
{
	if (!isObject(%obj)) return;
	%obj.inTransition = true;
	if (%direction)
	{
		%obj.stopThread(0);
		%obj.playThread( 0,%anim );
		%obj.setThreadDir(0,true);
	}
	else
	{
		//play anim backwards
		%obj.stopThread(0);
		%obj.playThread( 0, %anim );
		%obj.setThreadPosition(0,1);
		%obj.setThreadDir(0,false);
	}
	//while were at it, trip any synced animations for stuff mounted to us
	%count = %obj.getMountedObjectCount();
	for (%i=0; %i<%count; %i++)
	{
		smartPlayThread(%obj.getMountedObject(%i),%anim,%direction);
	}
}
I use this a lot, personally.

Re: PlayThread

Posted: Thu Dec 05, 2019 4:30 am
by Hodo33
That works great, thanks....