---
tags:
    - "Physics, 2D"
---

# Rigidbody 2D Add Force X

[Physics 2D](../index.md) / [Rigidbody 2D](index.md) / **Rigidbody 2D Add Force X**

## Description

Executes the Add Force X method on the Rigidbody 2D component

## Parameters

| Name | Description |
| :--- | :---------- |
| Force |  |
| Mode |  |

## Code

```cs
// <auto-generated>
// This script was automatically generated using the Visual Script Transpiler.
// Do not modify. Changes to this file will be lost when updating the package.
// </auto-generated>

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Rigidbody 2D Add Force X")]
    [Category("Physics 2D/Rigidbody 2D/Add Force X")]
    [Description("Executes the Add Force X method on the Rigidbody 2D component")]
    
    [Image(typeof(IconPhysics), ColorTheme.Type.Lime, typeof(Badge2D))]
    [Keywords("Physics, 2D")]
    
    [Parameter("Force")]
    [Parameter("Mode")]
    
    [Serializable]
    public class GenInstructionRigidbody2D_AddForceX_2 : Instruction
    {
        [SerializeField] private GetGameObject m_Rigidbody2D = new GetGameObject(
            new GenTypeGameObject_Rigidbody2D()
        );
        
        [SerializeField] private GetNumber m_Force = new GetNumber();
        
        [SerializeField] private ForceMode2D m_Mode = default;
        
        protected override string GetTitle(GameObject source)
        {
            string method = TextUtils.ThemeAsKeyword("Add Force X");
            return $"{this.m_Rigidbody2D} {method} ({this.m_Force}, {this.m_Mode})";
        }
        
        protected override Awaitable Run(Args args)
        {
            Rigidbody2D component = this.m_Rigidbody2D.Get<Rigidbody2D>(args);
            if (component == null) return Done;
            
            component.AddForceX(
                (float) this.m_Force.Get(args),
                this.m_Mode
            );
            
            return Done;
        }
    }
}


```

