Answers for "rb.addforce"

C#
11

Rigidbody.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);
    }
}
Posted by: Guest on February-09-2020
7

unity rigidbody addforce

rb = GetComponent<Rigidbody>();
rb.AddForce(new Vector3(1.5f,1.5f,1.5f));
Posted by: Guest on February-15-2020
1

rb.addforce c#

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

// Time.deltaTime is optional ( Make sure that "T" is caps)
Posted by: Guest on December-06-2020
0

rb.addforce

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test: MonoBehaviour {
    Rigidbody rb;
	void Start() {
    	//Get the Rigidbody to the code
    	rb = GetComponent<Rigidbody>();
    }
    
    //Fixed Update is for handling physics and it updates every frame
    void FixedUpdate() {
    	//Move a gameobject up
    	rb.AddForce(Vector3.up * 4f);
    }
}
Posted by: Guest on October-25-2021
-2

rb.addforce 3d c#

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

// time.deltaTime is optional
Posted by: Guest on December-06-2020

C# Answers by Framework

Browse Popular Code Answers by Language