Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Creating a rope for soft body simulation:

Create a rope entity with mesh and transform for soft body simulation.

Create a rope entity with mesh and transform for soft body simulationCreates a 1D chain of vertices along the -Y axis, suitable for soft body rope simulation. After creation, add a SoftBody component to enable physics:

Parameters
coreEngine core reference
infoParameters for creating the rope (segmentCount, segmentLength, position, rotation, scale)
Returns
Engine::Entity The created entity with mesh and transform
auto rope = Object::Helper::CreateRope(core, { .segmentCount = 20, .segmentLength = 0.1f, .position = glm::vec3(0, 5,
0) }); auto& soft = rope.AddComponent<Physics::Component::SoftBody>(core, SoftBodySettings::Rope(0.9f));
soft.PinVertex(0); // Pin top of rope
decltype(auto) AddComponent(TComponent &&component)
Add a component to an entity.
Definition Entity.hpp:55
Engine::Entity CreateRope(Engine::Core &core, CreateRopeInfo info)
Definition CreateShape.cpp:88
Soft body physics component.
Definition SoftBody.hpp:241
void PinVertex(uint32_t vertexIndex)
Pin a vertex (fix it in space).
Definition SoftBody.hpp:284

a rope for soft body simulation: