|
Capycore Engine
0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
|
A 2D rigidbody component that adds physics properties to a GameObject. More...
#include <rigidbody_2d.h>
Public Member Functions | |
| Rigidbody2D (BodyType2D::Type type=BodyType2D::Dynamic, float mass=default_rigidbody_mass, bool use_gravity=default_rigidbody_use_gravity, float gravity_scale=default_rigidbody_gravity_scale) | |
| ~Rigidbody2D () override | |
| void | update (float dt) override |
| Rigidbody2D & | teleport (const Vector3 &position) noexcept |
| BodyType2D::Type | type () const noexcept |
| Rigidbody2D & | type (BodyType2D::Type value) noexcept |
| float | mass () const noexcept |
| Rigidbody2D & | mass (float value) noexcept |
| bool | use_gravity () const noexcept |
| Rigidbody2D & | use_gravity (bool value) noexcept |
| float | gravity_scale () const noexcept |
| Rigidbody2D & | gravity_scale (float value) noexcept |
| Body2D | body () const noexcept |
| void | body (const Body2D &value) noexcept |
| void | apply_force (const Vector3 &force) noexcept |
| Applies a force to the rigidbody. | |
| void | apply_impulse (const Vector3 &impulse) noexcept |
| Applies an impulse to the rigidbody. | |
| void | velocity (const Vector3 &value) noexcept |
| Retrieves the current velocity of the rigidbody. | |
| Vector3 | velocity () const noexcept |
| Retrieves the current velocity of the rigidbody. | |
| void | mark_network_dirty () noexcept |
| void | on_serialize (std::vector< uint8_t > &out) const override |
| Serializes the component's state into a byte array. | |
| void | on_deserialize (const std::vector< uint8_t > &data, size_t &offset) override |
| Deserializes the component's state from a byte array. | |
| std::string | type_name () const override |
| Provides a consistent type name for the component. | |
Public Member Functions inherited from Component | |
| Component () | |
| virtual | ~Component ()=default |
| bool | active () const noexcept |
| Checks if the component is active. | |
| Component & | active (bool value) noexcept |
| bool | marked_for_deletion () const noexcept |
| Activates the component. | |
| Component & | mark_for_deletion () noexcept |
| virtual void | on_attach () |
| Called when the component is attached to a GameObject. | |
| virtual void | on_detach () |
| Called when the component is detached from a GameObject. | |
| const std::optional< std::reference_wrapper< GameObject > > & | parent () const noexcept |
| Gets the parent GameObject of this component. | |
| std::optional< std::reference_wrapper< GameObject > > & | parent () noexcept |
| Gets the parent GameObject of this component. | |
| Component & | parent (GameObject &parent) |
| Component & | parent (std::nullopt_t nullopt) |
| size_t | add_on_attach (const std::function< void(Component &)> &action) |
| Retrieves the type information of the component. | |
| void | remove_on_attach (size_t index) |
| size_t | add_on_detach (const std::function< void(Component &)> &action) |
| Adds an action to be performed when the component is attached. | |
| void | remove_on_detach (size_t index) |
A 2D rigidbody component that adds physics properties to a GameObject.
This component allows a GameObject to interact with the physics engine, enabling features such as gravity, collisions, and movement based on physical forces.
Usage:
| Rigidbody2D::Rigidbody2D | ( | BodyType2D::Type | type = BodyType2D::Dynamic, |
| float | mass = default_rigidbody_mass, |
||
| bool | use_gravity = default_rigidbody_use_gravity, |
||
| float | gravity_scale = default_rigidbody_gravity_scale |
||
| ) |
|
override |
|
noexcept |
Applies a force to the rigidbody.
| force | The force vector to apply. |
|
noexcept |
Applies an impulse to the rigidbody.
| impulse | The impulse vector to apply. |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
overridevirtual |
Deserializes the component's state from a byte array.
| data | The byte array containing the serialized state. |
| offset | The current offset in the byte array from which to start reading. This offset will be updated as bytes are read. |
Reimplemented from Component.
|
overridevirtual |
Serializes the component's state into a byte array.
| out | A vector to which the serialized bytes will be appended. |
Reimplemented from Component.
|
noexcept |
|
noexcept |
|
noexcept |
|
overridevirtual |
Provides a consistent type name for the component.
Implements Component.
|
overridevirtual |
Implements Component.
|
noexcept |
|
noexcept |
|
noexcept |
Retrieves the current velocity of the rigidbody.
|
noexcept |
Retrieves the current velocity of the rigidbody.