Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

RigidBody

Add this in your code:

#include <engine/physics/rigidbody.h>

Description

Component to add physics to the GameObject.

Public Methods


GetVelocity

Get the velocity.

const Vector3& GetVelocity() const

SetVelocity

Set the velocity.

Parameters:

  • velocity: New velocity
void SetVelocity(const Vector3& velocity)

GetTorque

Get the torque applied to the rigidbody.

Vector3 GetTorque() const

ApplyTorque

Apply torque.

Parameters:

  • torque: Torque to apply
void ApplyTorque(const Vector3& torque)

GetAngularVelocity

Get the angular velocity.

Vector3 GetAngularVelocity() const

SetAngularVelocity

Set the angular velocity.

Parameters:

  • angularVelocity: Angular velocity to set
void SetAngularVelocity(const Vector3& angularVelocity)

AddAngularVelocity

Add angular velocity.

Parameters:

  • angularVelocity: Angular velocity to add
void AddAngularVelocity(const Vector3& angularVelocity)

GetDrag

Get the drag value.

float GetDrag() const

SetDrag

Set the drag value.

Parameters:

  • drag: Drag value to set
void SetDrag(float drag)

GetAngularDrag

Get the angular drag value.

float GetAngularDrag() const

SetAngularDrag

Set the angular drag value.

Parameters:

  • angularDrag: Angular drag value to set
void SetAngularDrag(float angularDrag)

GetBounce

Get the bounce value.

float GetBounce() const

SetBounce

Set the bounce value.

Parameters:

  • bounce: Bounce value to set
void SetBounce(float bounce)

GetGravityMultiplier

Get the gravity multiplier.

float GetGravityMultiplier() const

SetGravityMultiplier

Set the gravity multiplier.

Parameters:

  • gravityMultiplier: Gravity multiplier value to set
void SetGravityMultiplier(float gravityMultiplier)

IsStatic

Get if the rigidbody is static.

float IsStatic() const

SetIsStatic

Set if the rigidbody is static.

Parameters:

  • isStatic: Is static value to set
void SetIsStatic(float isStatic)

GetMass

Get the mass of the rigidbody.

float GetMass() const

SetMass

Set the mass of the rigidbody.

Parameters:

  • mass: Mass value to set
void SetMass(float mass)

GetFriction

Get the friction value.

float GetFriction() const

SetFriction

Set the friction value.

Parameters:

  • friction: Friction value to set
void SetFriction(float friction)

Activate

Activate the rigidbody (used to wake up the rigidbody if it was sleeping).

void Activate()

GetLockedMovementAxis

Get locked movement axis.

const LockedAxis& GetLockedMovementAxis() const

SetLockedMovementAxis

Set locked movement axis.

Parameters:

  • axis: Axis to lock
void SetLockedMovementAxis(LockedAxis axis)

GetLockedMovementAxis

Get locked rotation axis.

const LockedAxis& GetLockedRotationAxis() const

SetLockedMovementAxis

Set locked rotation axis.

Parameters:

  • axis: Axis to lock
void SetLockedMovementAxis(LockedAxis axis)

IsSleepDisabled

Check if sleep is disabled.

bool IsSleepDisabled() const

SetIsSleepDisabled

Set if sleep is disabled. (Can be useful for objects that froze after few seconds). Not recommended for performance reasons.

Parameters:

  • disableSleep: True to disable sleep optimization
void SetIsSleepDisabled(bool disableSleep)