unity addforce

using UnityEngine;public class ExampleClass : MonoBehaviour
{
    public float thrust = 1.0f;
    public Rigidbody rb;    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.AddForce(0, 0, thrust, ForceMode.Impulse);
    }
}

3.71
7
Shem 95 points

                                    public class Example : MonoBehaviour
{
    Rigidbody m_Rigidbody;
    public float m_Thrust = 20f;

    void Start()
    {
        //Fetch the Rigidbody from the GameObject with this script attached
        m_Rigidbody = GetComponent&lt;Rigidbody&gt;();
    }

    void FixedUpdate()
    {
        if (Input.GetButton(&quot;Jump&quot;))
        {
            //Apply a force to this Rigidbody in direction of this GameObjects up axis
            m_Rigidbody.AddForce(transform.up * m_Thrust);
        }
    }
}

3.71 (7 Votes)
0
3.6
5
Kryfon 125 points

                                    public Rigidbody rb; //make reference in Unity Inspector

public float SpeedX = 0.1f;
public float SpeedY = 0.5f;

rb.AddForce(new Vector2(SpeedX, SpeedY));

3.6 (5 Votes)
0
4.5
4

                                    rb.AddForce(0, 0, 5 * Time.deltaTime);

// Time.deltaTime is optional ( Make sure that &quot;T&quot; is caps)

4.5 (4 Votes)
0
3.8
5
Mosakyrie 95 points

                                    m_Rigidbody.AddForce(transform.up * m_Thrust);

//rigidbodyToApplyForceTo.AddForce(Direction*Force);

3.8 (5 Votes)
0
3.5
8
Valerian 90 points

                                    rb = GetComponent&lt;Rigidbody&gt;();
rb.AddForce(new Vector3(1.5f,1.5f,1.5f));

3.5 (8 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to use addForce in unity 3 how to use addForce in unity 2 unity addforce right rigidbody addforce to object unity directly addforce rigidbody.addforce unity c# unity what does .addforce do? addforce unity custom rigidbody addforce unity addforce without rigidbody unity how to addforce in rigidbody unity rigidbody.addforce unity unity rigidbody addforce 2d rigidbody addforce in a direction unity unity 2d rigidbody addforce unity rigid body addforce unity add force to rigidBody rigidbody unity addforce unity rigidbody addforce direction rigidbody unity adding force unity rigidbody.addforce alternative unity rigid.addforce rigidbody.addforce at position rigidbody.add force unity addforce without rigidbody unity rigidbody add force unity c# rigidbody addforce rigidbody addforce at position rigidbody 2d addforce unity rigidbody addforce all forcemodes unity rigidbody addforce forcemodes unity rigidbody addforce forcemode unity move rigidbody addforce unity rigidbody2d addforce not working unity rigidbody addforce at point unity addforce to rigidbody right after creation Unity addForce faster unity rigidbody addforce character unity rigidbody addforce to position unity api5 addforce to rigidbody unity move rigidbody to position using addforce unity move rigidbody to positionusing addforce addforce rigidbody 2d rigidbody add force unity how to addforce to rigidbody in code addforce to rigidbody unity unity rb .add force towards vector 3 unity2d appy force rb add force down how to add force to up in unity c# C# unity force unity trb.addforce unity rigidbody 2d addforce unity addforce code adding a force unity 2d how to addforce down in unity how does rb.add force work rb.AddForce(shotPoint.transform.forward * 1000); unity add force simulation with transform add force from the rigidbody unity addforce not working how to add force in unity unity 2d how to use ridbody.addforce 2d forces unity how to add force scripting unity force unity c sharp C# vector3 forcemode types unity rigidbody apply force unity addforce to sprite unity rigidbody2d.addforce charactercontroller.move vs rigidbody.addforce unity 2d addforce to right unity 2d add force to right unity2d addforce to right Unity2D why doesn't rigidbody2D.addforce(Vector2.left * variable, ForceMode2D.Impulse) add force forward uniyt rb.addfore 2d direction rb.add force unity addforce Vector2 addforce gameobject unity unity rb add force unity addforce 3d c# apply force rigid body 2d addforce unity add force x y z add rotation to rigidbody2d unity unity apply force to a rigidbody when it touches an object C# unity addforce unity rigidbody addforce forward unity adForse c# gameobject add rigidbody unity force push 2d radius add force y direction unity rb add force unity c# get rigid body force how to script rigidbody2d.AddForce() Rigidbody2D.AddForce() how to add force using a rigidbody unity 2d apply force up unity 2d apply force add force 3d unity addforce at unity C# addforce unity rigid body add force to world backward rb force unity add force rb2d rb2d add force unity rigidbody addtorque how to get a rb force unity how to add force to an object in unity 2d addforce return unity rb.AddForce(-Vector3.forward * ballSpeed); add force to up unity 2d how to add force to an object in unity 2d script unity how to add force to rigidbody unity addforce to rigidbody2d add force rigid body unity 2d rb addforce unity add force 3d addforce unity 2d example how to make addforce apply consistently rigidbody add force gameobject.getcomponent rigidbody2d (speed = 20).addforce; unity rigid body add force unit3yd 2d AddForce unityd unity ad force 2d move up unity rigidbody force untiy forces unity unity rigidbody.force unity addforce rigidbody 3d add force forward, up unity add force forward unity GetComponent&lt;Rigidbody&gt;().AddForce(Vector3.up * 5, ForceMode.VelocityChange); Rigidbody.AddForce 2d how to add force to z axis unity c# addforce vertical unity rb.addforce c# rigidbody2d apply impulse unity 2d AddForce object add velocity or add force unity 2d addforce 2d unity unity addforce rb 2d 2d unity addforce adforce unity unity addforce rigidbody2d rigidbody add force API adding force to 2d rigidbody unity impulse force 2d addforce in unity unity addforce towa0 how to apply impulse force rigidbody 2d how to apply impulse force rigidbody 2s how to add force for rigidbody2d unity 2d addforce to object unity addforce script unity add force script Add Force unityy addforce unity script add force unity script unity transform add force addforce in unity 2d add impluse rigidbody unity random impulse force unity 2d how to add force to rigidbody unity rigidbody static addforce right way to apply force in unity 3d unity add force to float add force 2d how do you add force to an element add force in y axis unity 2d rigidbody unity 2d addforce add horizontal force addforce parameter in unity 2d rb add force GetComponent&lt;Rigidbody&gt;().AddForce(Vector3.up,ForceMode.VelocityChange = 2); rigidbody2d.addforce unity c# rb.addforce unity rigidbody2d push get force on a 2d rigidbody unity physics2d rigidbody addforce applying forces unity unity apply force to rigidbody add rigidbody force to gameobject transform.addforce how to get rigid body 2d to add force vector 2 add force addforce script unity A starenemy add force rigidbody.addforce in a circular loop how to add force to other rigidbody unity unity apply force to gameobject apply force vector to rigidbody 2d unity unity sety forward force unity forward force unity 3d forces code unity 3d forces unity docs rigidbody add force how does Ridigbody.AddForce work C# unity add forward force unity unity rigid body 2d add force add force to game object unity add force in a direction unity how to set force not add force in unity addforce from world point how to apply a force to a rigidbody to the direction adding force to a gameobject unity adding force to a gameobject addforce to gameobject unity &iquest;unity add force movement unity rigidbody addforce thrust unity rigidbody 2d add force unity api addforce unity rigging 2d addforce how add force on gameobject in unity addforce vector3 forward unity force example unity addforce2d how to apply forward force with rigidbody in unity unity rigidbody2d addforce rigidbody addforce 2d unity 2d movement rigidbody addforce apply a force to a rigidbody rb.AddForce 2d forcemode how to apply force to rigidbody unity adding forces unity up force force unity unity addforce types rb.AddForce 2d unity if w down move forward force add force forward add force unity add force command tutorial unity how to add force forwards unity3d add forces to object rb add force vector3 unity rb addforce vector3 how to add force to an object in unity apply force unity behind aunity addforce unity addfroce unity rigidbody addforce force mode addforce 2d unity c# addfroce in unity how to make a forward force in unity how to apply force to game object unity unity 2d addforce up unity 2d set force add force to object unity unity rb2d addforce howdo you add force to a rigidbody in unity unity addfore physics add force unity addforce unity2d apply force to rigidbody2d unity unity add force to 2d rigidbody all ways to add force in unity unity addforec addforce forward unity how to use addforce in unity how to add force to rigidbody unity how to add just once force to the gameobject c# addforce function in unity unity rigidboy force object addforce unity how to addforce ibn unity force2d.force not working unity unity add force forward how to addforce in unity 2d how to add force in 2d in unity how to addforce in unity unity how to add vector3 to rb addforce how to add a force to an object unity unity add force 2d unity rb addforce c# add force add force towards green gizmo of object apply force to rigidbody unity force 2d unity unity 2d force how to apply a rigidbody force in unity rb.addforce unity3d add force forwards unity rigidbody unity addforce types unity forces all type of add force code in unity2d unity addforce to rigidbody force in unity 2d unity rb addforce right unity rb add force right unity adding force to rigidbody add force to 2d object unity unity 2d addforce addfoce to looked at object unity unity addforce to gameobject addforce arguments unity 3d addforce unity 3d unity addforce using vectory how to add force to object in unity 2d addforce unity addforce example force in unity apply force unity how to use addforce in unity 2d how to use add force un unity unity add force add force unity adding forward force to objects in unity adding force to rigidbodys in unityu how to apply a force unity addforce unity 2d unity 2d add force unity force apply force unity scripting UNITY ADD FORCE TO GAME OBJECT component UNITY ADD FORCE TO GAME OBJECT www.how to use addforce in unity 2d www.how to use addforce in unity 2e www.what is addfoce in unity add force unity 5 add 2d force unity add 2d foree unity how to set the force of a rigidbody2d in unity how to apply force unity modify the code to the effect that: as the Player moves front, the Enemy moves towards it at twice the same force in c# unity unity addforce 2d www.how to use addforce methis in unity how to make rb.addforce 2d unity rigidbody addforce unity how to add force to something forawrd force unity forward force unity unity 3d rigidbody addforce unity rb.addforce unity 3d addforce how to add force to a rigidbody unity c# AddForce apple force to rigidbody unity addfortce =AddForce rb.addforce in unity how to add force to a rigidbody in unity Rigidbody addforce adding force unity unity rigidbody force types unity apply force add force code in unity addforce rigidbody.addforce unity addforce unity addforce settings rb.addforce unity 2D add force in X empleos programador pythons addforce unity c# unity ad force unity addforce declaration rigidbody addforce unity unity input ato apply force physics .addforce unity unity rigidbody.addforce add force c# force rigidbody unity 3d unity add forc types of add force unity addforce unity ADDFROCE UNITY how to add force to rigidn body in script unity c# unity add fore how to add a force in unity how to aaddforce unity how to add force unity How to add force to an object unity force mods unity how to add force
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source