Find help on the FRENCH REFORGER MOD discord if you need ✅ Check our progress about this wiki here 📜
Skip to main content

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.
(you can download the basic car and see how the make the trunk function) you can go see the vertex part here: tutorial vertex and anim


1. skeleton and bone

PourTo fairemake l'the animation, una bone etand una vertex group doitmust êtrebe crée.created. DansIn lethe tutoriel,tutorial, lethe bone quithat vawill fairemake bougerthe lawheel rouemove vawill s'appelerbe "v_landing_rr"called “v_landing_rr” (vousyou pouvezcan bienof sûrcourse lename nommerit commeanything vousyou lelike). voulez). 

image.png

2. LesProcedural fichiersanimation d'animations procéduralesfiles

VousYou pouvezcan retrouverfind cesthese deuxtwo fichiersfiles enattached pièceat jointesthe enbottom basof dethis cetutorial, tutoriel,you voushave avezthe leright droitto deuse lesthem utiliser librementfreely (vousyou pouvezcan nouscredit créditerus siif vousyou le souhaitezwish 👍).

image.png

VousYou pouvezcan lesplace placerthem dansin "“{YOUR_ADDON}/anims"anims”.

Rappel:Reminder: ExplicationsExplanations duof fonctionnementhow desprocedural animations procédurales:work:

1. lethe .siga file

image.png

  • L'The imput estis le lanceur duthe signal pourlauncher l'for the animation ⚡
  • Value 8 correspondcorresponds Ă to lathe maximum rotation maxof dethe l'animation enin pratiquepractice (-80°).
  • Smoother 10 permetsoftens d'adoucir l'animation pourto Ă©viterprevent qu'elleit soitfrom tropbeing brutaletoo rough
2. L'animationthe .pap file

image.png

  • Signal 1: PermetUsed deto faire le lien entre le fichierlink .siga et leand .pap,pap onfiles, peux y trouver deswith ports pourfor fairelinking desto liensanimation avec les instructions d'animationsinstructions.
  • Rotation MakeMake: permettells deyou direto deperform rĂ©aliser lathe rotation
  • RotationSet: PermetAllows deyou configurerto laconfigure rotation (notammentin pourparticular dĂ©finirto sidefine ouiwhether ouor nonnot onto met Ă  jour lesupdate colliders).
  • Bone: DĂ©finitDefines l'oswhich quibone vawill bougermove








Tips: EnBy cliquantclicking dansin lethe vide,background, vousyou pouvezcan définirdefine unan modèleexample d'exemplemodel, etand avecwith lathe fenêtre "“signal simulation",simulation” vouswindow, pouvezyou testercan entest direct votreyour animation
 live.
image.png

3. Les actions pour pouvoir déclencher l'animation

1. CréerCreate l'action Landing_Gears"Landing_Gears"

image.png

1. CréerCreate l'Additional Action

Add the “SCR_TrunkUserAction” additional action additionnelwith

Ajoutezthe l'action additionnel "SCR_TrunkUserAction" avec le petitsmall + dein lathe catégorie“Additional "AdditionnalActions” Actions"category dansto lethe component ActionManagerComponentActionManagerComponent.

image.png

UneOnce foiscreated, crée,all vousyou avezhave plusto qu'ado mettreis cesput paramètresthese dansparameters l'into action:

  • DansIn "“Parent Context List"List”, mettezset l'the action queyou vouscreated avez crĂ©e plus hautabove
  • Signal Name vawill porterbe lethe nomname queyou voushave avezdefined dĂ©finiin dans le fichierthe signal file (.siga).

image.png

4. Le scriptScript

Rappel:Reminder: PourFor que lethe script soitto prisbe entaken compte,into ilaccount, doitit semust trouverbe danslocated auin minimumat unleast dossierone "“scripts/Game/UserActions"UserActions” folder.

CréerCreate un fichiera script dansfile cein répertoirethis quidirectory s'appellecalled "“SCR_CarTrunkUserAction.c"c”, ouvrezopen leit puisand mettezput ythis cela: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));
	}
}

UneOnce foisyou've toutdone cethis tutorieltutorial, fait,you vouscan pouvezrestart entièrement redémarrer lethe workbench etand siif vousyou've avezdone bieneverything toutright, fait,the leswheels rouesshould devraientmove. seNow déplacer,it's àup vousto maintenantyou deto fairemake ensure sortethey qu'elle le face biendo ^^.

Translated with DeepL by Lucas - 11/20/24