User Tools

Site Tools


arma2:modeling:user_animation

User Animation Tutorial

Primary target - Vehicles

This tutorial is to show the basics of how to animate a section of a vehicle model with a USER action. Specific subject pictures are a aircraft ramp, but any vehicle can have similar.

Model

First thing that needs to be done is create the section to be animated (an access ramp in this case).

This section needs its own name in O2. “RAMP1” in this example.

This section needs to be created and named in every Resolution LOD as well as the Geometry LOD.

If someone is going to walk on this section, then it should also be created and named in the Roadway as well.

In the Memory LOD you need to create 2 points/vertexes that mimic the “hinge” point. The points form the line around which the ramp will rotate.

These 2 points need also to be named. “AXIS_RAMP1” in this case.

For the USER/Player to access the Action menu of the vehicle, we definite points or locations where the required action will appear in the player menu.

These User Action point(s) we name for our example “ACTION_RAMP1”

Model.cfg

In the CFG Skeleton section of the model.cfg file you should add something like this;

class CfgSkeletons
{
	class Plane;
	class myPlaneBones: Plane
	{
		isDiscrete=1;
		skeletonInherit = "";
		skeletonBones[]=
		{
			"RAMP1","",
			xxxxxx, xxxxx,
			etc etc

Its important to have the ,“” bit, as this defines “ramp1” as being hinged off the ROOT or main part of the model. In the CFG Model section of the model.cfg you should add something like this;

class CfgModels
{
	class Plane;
	class NameofmyP3Dfile: Plane
	{
		sectionsInherit = "";
		skeletonName = "myPlaneBones";
		sections[] = {};
		class Animations
		{
			class AnimateRAMP1
			{
				type="rotation";
				source="UserRamp1";
				sourceAddress = "clamp";
				selection="RAMP1";
				axis="AXIS_RAMP1";
				memory=1;
				angle0="rad 0";
				angle1="rad 22";
				minValue=0.000;
				maxValue=1.000;
			};
			etc etc

TIP: If you have saved the model.cfg in your addon project file, when you reopen your model in O2, in Buldozer you can use the middle mouse button and wheel to select/change/view the demo animation in action.

If the animation / ramp animations in the wrong direction, just change “rad 22” (which is 22 degrees) to “rad -22”

“UserRamp1” (the animation “Source”) is defined (will be defined) in the config.cpp file.

Config.cpp

Inside you CFGVehicle definition you need to have something like;

class AnimationSources: AnimationSources
{
	class  UserRamp1
	{
		source = "user";
		animPeriod = 20;
		initPhase=0;
	};
};

The “UserRamp1” here must be the same name as used in the model.cfg as “source”.

source: The controller is defined as a user animation. Always “user” in these cases.

animPeriod: The animation period used for this controller. In seconds.

initPhase: Initial phase / status when object is created. 0 = CLOSED or O2 default modeled state.

To create the pop-up menu near the vehicle that allows players to open or close the ramp, add code like this inside the CFGVehicle definition;

class UserActions
{
	class OpenRamp
	{
		displayName="Open Ramp";
		position="ACTION_RAMP1";
		onlyforplayer=0;
		radius=8;
		condition="(this animationPhase ""AnimateRAMP1"" == 0)";
		statement="this animate [""AnimateRAMP1"",1];";
	};
	class CloseRamp
	{
		displayName="Close Ramp";
		position="ACTION_RAMP1";
		onlyforplayer=0;
		radius=8;
		condition="(this animationPhase ""AnimateRAMP1"" == 1)";
		statement="this animate [""AnimateRAMP1"",0];";
	};
};

ACTION_RAMP1 is the point(s) we named in the Memory LOD

AnimateRAMP1 is the same name we used in the CfgModel section of the model.cfg

“Open Ramp” and “Close Ramp” are exactly the menu actions the player will see.

RADIUS is the radius in meters around the ACTION_RAMP1 points that players will see the action in menu.

House Door

model.cfg:

class cfgSkeletons
 
	class VTE_tigercage_Skeleton: Default
	{
		skeletonInherit = "Default";
		skeletonBones[] =
		{
			"VTE_tg1_door", ""
		};
	};
 
class CfgModels
 
	class VTE_tigercage: Default
	{
		skeletonName = "VTE_tigercage_Skeleton";
		sections[] = {};
 
		class Animations
		{
			class vte_tigercage_door: Rotation
			{
				axis = "axis_door";
				selection = "VTE_tg1_door";
			};
		};
	};

config.cpp:

		class AnimationSources
		{
			class vte_tigercage_door
			{
				animPeriod = 1;
			};
		};
 
		class UserActions
		{
			class OpenTigerCage_door
			{
				displayName = "Open Door";
				position = "VTE_tg1_door";
				radius = 4;
				OnlyForPlayer = true;
				condition = "this animationPhase ""vte_tigercage_door"" < 0.5";
				statement = "this animate [""vte_tigercage_door"", 1];";
			};
 
			class CloseTigerCage_door: OpenTigerCage_door
			{
				displayName = "Close Door";
				condition = "this animationPhase ""vte_tigercage_door"" >= 0.5";
				statement = "this animate [""vte_tigercage_door"", 0];";
			};
		};

Summary

VTE_tg1_door is the selection in Resolution LOD.

axis_door is the memory point in Memory LOD.

Note about Geometry LOD

When you animate a door, in Geometry LOD it has to have ComponentXX and also the selection name like in our above example VTE_tg1_door, otherwise when you open the door it wont let you pass as geometry doesn't recognize anything happening.

arma2/modeling/user_animation.txt · Last modified: 2016-10-03 12:39 (external edit)