PlayThread

Scripting questions, discussions, etc
3 posts Page 1 of 1
Hodo33
Posts: 94
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Wed Dec 04, 2019 5:42 pm
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?
Azaezel
Posts: 473
Joined: Tue Feb 03, 2015 9:50 pm
 
by Azaezel » Wed Dec 04, 2019 11:00 pm
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.
Hodo33
Posts: 94
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Thu Dec 05, 2019 4:30 am
That works great, thanks....
3 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests