RigidbodySynchronizableAddForce(Single, Single, Single, ForceMode) Method

Adds a force to the Rigidbody.

Definition

Namespace: Alteruna.Multiplayer
Assembly: Alteruna (in Alteruna.dll) Version: 2.0.1+a1176e08a0b4a6bfd8fefeddde6163a16d29e5ab
C#
public void AddForce(
	float x,
	float y,
	float z,
	ForceMode mode = ForceMode.Force
)

Parameters

x  Single
Size of force along the world x-axis.
y  Single
Size of force along the world y-axis.
z  Single
Size of force along the world z-axis.
mode  ForceMode  (Optional)
Type of force to apply.

Example

This example applies an Impulse force along the Z axis to the GameObject's Rigidbody.
C#
using UnityEngine;
public class Example : MonoBehaviour
{
    public float thrust = 1.0f;
    public RigidbodySynchronizable rb;

    void Start()
    {
        rb.AddForce(0, 0, thrust, ForceMode.Impulse);
    }
}

See Also

Reference

[!:https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html]