# 4. Optional features available from official French Reforger Mod vehicles

This category allows you to integrate the features of French Reforger Mod vehicles if you wish.

# Make a landing gear system for a helicopter

## ****Introduction****

The idea is to use the basic car trunk script from Bohemia's tutorial, modifying it to move (translate/rotate) a bone in the skeleton.  
<span style="white-space: pre-wrap;">(you can </span>[download](https://github.com/BohemiaInteractive/Arma-Reforger-Samples/tree/main/SampleMod_NewCar%20)<span style="white-space: pre-wrap;"> the basic car and see how the make the trunk function) you can go see the vertex part here: </span>[tutorial vertex and anim](https://wiki.nabla.sh/books/creating-a-vehicle-from-scratch/page/animation-finition-doit-etre-rework)

---

### ****1. skeleton and bone****

<p class="callout info"><span style="white-space: pre-wrap;">To make the animation, a bone and a vertex group must be created. In the tutorial, the bone that will make the wheel move will be called “v\_landing\_rr” (you can of course name it anything you like). </span></p>

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/mpximage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/mpximage.png)

### ****2.****<span style="white-space: pre-wrap;"> </span>****Procedural animation files****

<p class="callout success">You can find these two files attached at the bottom of this tutorial, you have the right to use them freely (you can credit us if you wish 👍).</p>

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/yoEimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/yoEimage.png)

You can place them in “{YOUR\_ADDON}/anims”.

<details id="bkmrk-rappel%3A-explications">#### **Reminder: Explanations of how procedural animations work:**

##### ****1. the .siga file****

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/l8Simage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/l8Simage.png)

- The imput is the signal launcher for the animation ⚡
- Value 8 corresponds to the maximum rotation of the animation in practice (-80°).
- Smoother 10 softens animation to prevent it from being too rough

##### ****2. the .pap file****

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/Q7Vimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/Q7Vimage.png)

- Signal 1: Used to link .siga and .pap files, with ports for linking to animation instructions.
- Rotation Make: tells you to perform the rotation
- RotationSet: Allows you to configure rotation (in particular to define whether or not to update colliders).
- Bone: Defines which bone will move

<p class="callout success align-center">Tips: By clicking in the background, you can define an example model, and with the “signal simulation” window, you can test your animation live.  
[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/9uGimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/9uGimage.png)</p>

</details>### ****3. Les actions pour pouvoir déclencher l'animation****

#### 1. Create action "Landing\_Gears"

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/iiQimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/iiQimage.png)

#### 1. Create Additional Action

Add the “SCR\_TrunkUserAction” additional action with the small + in the “Additional Actions” category to the ActionManagerComponent.

![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/e6Timage.png)Once created, all you have to do is put these parameters into action:

- In “Parent Context List”, set the action you created above
- Signal Name will be the name you have defined in the signal file (.siga).

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-11/scaled-1680-/EpLimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-11/EpLimage.png)

### ****4. Script****

<p class="callout warning">Reminder: For the script to be taken into account, it must be located in at least one “scripts/Game/UserActions” folder.</p>

Create a script file in this directory called “SCR\_CarTrunkUserAction.c”, open it and put this in it:

```
//French Reforger Mod - Landing Gears tutorial

class SCR_TrunkUserAction : ScriptedUserAction
{
	[Attribute(defvalue: "Drawer 1", uiwidget: UIWidgets.EditBox, desc: "Signal name of trunk action in procedural animation project")]
	protected string m_sSignalName;	//for pairing with the user action
	
	[Attribute(defvalue: "0", uiwidget: UIWidgets.EditBox, desc: "Value of signal when trunk is closed")]
	protected float m_fSignalMin;
	
	[Attribute(defvalue: "1", uiwidget: UIWidgets.EditBox, desc: "Value of signal when trunk is opened")]
	protected float m_fSignalMax;

	[Attribute(defvalue: "Open", uiwidget: UIWidgets.EditBox, desc: "Text for the 'Open' action")]
	protected string m_sOpenText;  // Texte pour l'action "Open"
	
	[Attribute(defvalue: "Close", uiwidget: UIWidgets.EditBox, desc: "Text for the 'Close' action")]
	protected string m_sCloseText;  // Texte pour l'action "Close"

	[Attribute(defvalue: "SOUND_CONTAINER_OPEN", uiwidget: UIWidgets.EditBox, desc: "Sound event name when opening")]
	protected string m_sOpenSoundEvent;  // Événement sonore pour l'ouverture
	
	[Attribute(defvalue: "SOUND_CONTAINER_CLOSE", uiwidget: UIWidgets.EditBox, desc: "Sound event name when closing")]
	protected string m_sCloseSoundEvent;  // Événement sonore pour la fermeture

	protected int m_iSignalIndex = -1;

	//! Signal manager to pass signals into proc anim
	private SignalsManagerComponent m_SignalsManager;
	//! Sound component
	private SCR_VehicleSoundComponent m_SoundComponent;

	//------------------------------------------------------------------------------------------------
	override bool CanBeShownScript(IEntity user)
	{
		return CanBePerformedScript(user);
	}

	//------------------------------------------------------------------------------------------------
	override bool CanBePerformedScript(IEntity user)
	{
		if(!m_SignalsManager)
			return false;

		if (m_iSignalIndex < 0)
		{
			m_iSignalIndex = m_SignalsManager.FindSignal(m_sSignalName);
			return false;
		}

		return true;
	}

	//---------------------------------------------------------
	override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
	{
		float targetValue = Math.AbsFloat((m_SignalsManager.GetSignalValue(m_iSignalIndex)) - m_fSignalMax);
		m_SignalsManager.SetSignalValue(m_iSignalIndex, targetValue);

		// Play sound
		if (m_SoundComponent)
		{
			if(targetValue > 0)
			{
				m_SoundComponent.SoundEvent(m_sOpenSoundEvent);  // Utilise l'événement sonore défini pour l'ouverture
			}
			else
			{
				m_SoundComponent.SoundEvent(m_sCloseSoundEvent);  // Utilise l'événement sonore défini pour la fermeture
			}
		}
	}

	//------------------------------------------------------------------------------------------------
	override bool GetActionNameScript(out string outName)
	{
		if((m_SignalsManager.GetSignalValue(m_iSignalIndex)) == 0)
		{
			outName = m_sOpenText;  // Utilise le texte défini pour l'ouverture
		} else
		{
			outName = m_sCloseText;  // Utilise le texte défini pour la fermeture
		}
		return true;
	}

	//------------------------------------------------------------------------------------------------
	override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
	{
		m_SignalsManager = SignalsManagerComponent.Cast(pOwnerEntity.FindComponent(SignalsManagerComponent));
		m_SoundComponent = SCR_VehicleSoundComponent.Cast(pOwnerEntity.FindComponent(SCR_VehicleSoundComponent));
	}
}
```

<p class="callout success">Once you've done this tutorial, you can restart the workbench and if you've done everything right, the wheels should move. Now it's up to you to make sure they do ^^.</p>

### ****5. Setup the custom sound of the animation****

<span style="white-space: pre-wrap;">First you will have to create the audio file of your futur sound to be called use the one provide in this tutorial </span>[landinggear.acp](https://wiki.nabla.sh/attachments/3)  
put the file in a sound folder and open it

\- change the sound that need to be played you will need to have a .wav file and import it in the Workbench

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-12/scaled-1680-/mekimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-12/mekimage.png)

Change the name of the event sound name

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-12/scaled-1680-/yOOimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-12/yOOimage.png)

\- add the file to the vehicle

<p class="callout warning">It's important to add the sound file to the sound component of your vehicule !</p>

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-12/scaled-1680-/4weimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-12/4weimage.png)

\- add the name of you sound event in the component Trunkaction

[![image.png](https://wiki.nabla.sh/uploads/images/gallery/2024-12/scaled-1680-/9PLimage.png)](https://wiki.nabla.sh/uploads/images/gallery/2024-12/9PLimage.png)

# Camo Net