RigidbodySynchronizableAddForce(Vector3, ForceMode) Method
Adds a force to the Rigidbody.
Namespace: Alteruna.MultiplayerAssembly: Alteruna (in Alteruna.dll) Version: 2.0.2+dcdb8fba58ad1eb99205b1dc6265fd5b3b7cf8ec
public void AddForce(
Vector3 force,
ForceMode mode = ForceMode.Force
)
Parameters
- force Vector3
- Force vector in world coordinates.
- mode ForceMode (Optional)
- Type of force to apply.
Force is applied continuously along the direction of the force vector. Specifying the ForceMode mode allows the type of force to be changed to an Acceleration, Impulse or Velocity Change.
using UnityEngine;
public class Example : MonoBehaviour
{
public RigidbodySynchronizable RigidbodySync;
public float m_Thrust = 20f;
void FixedUpdate()
{
if (Input.GetButton("Jump"))
{
//Apply a force to this Rigidbody in direction of this GameObjects up axis
RigidbodySync.AddForce(transform.up * m_Thrust);
}
}
}
Reference
[!:https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html]