Jolt Physics. Персонаж скользит по полу, как будто на льдуC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Jolt Physics. Персонаж скользит по полу, как будто на льду

Сообщение Anonymous »

Даже если я создаю персонажа с трением 0,99, он скользит по полу. Вот код: < /p>

Код: Выделить всё

// Floor creation
BoxShapeSettings floor_shape_settings(Vec3(10000.0f, 1.0f, 10000.0f));
floor_shape_settings.SetEmbedded(); // A ref counted object on the stack (base class RefTarget) should be marked as such to prevent it from being freed when its reference count goes to 0.

// Create the shape
ShapeSettings::ShapeResult floor_shape_result = floor_shape_settings.Create();
ShapeRefC floor_shape = floor_shape_result.Get(); // We don't expect an error here, but you can check floor_shape_result for HasError() / GetError()

// Create the settings for the body itself. Note that here you can also set other properties like the restitution / friction.
BodyCreationSettings floor_settings(floor_shape, RVec3(0.0_r, -1.0_r, 0.0_r), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING);

// Create the actual rigid body
//Body* floor = body_interface->CreateBody(floor_settings); // Note that if we run out of bodies this can return nullptr
floor = body_interface.CreateBody(floor_settings); // Note that if we run out of bodies this can return nullptr

// Add it to the world
body_interface.AddBody(floor->GetID(), EActivation::DontActivate);

// Character creation
CapsuleShapeSettings characterShapeSettings(20.f, 5.f);
characterShapeSettings.SetEmbedded();
ShapeSettings::ShapeResult characterShapeResult = characterShapeSettings.Create();
ShapeRefC characterShape = characterShapeResult.Get();

CharacterSettings characterSettings{};
characterSettings.mFriction = 0.99f;
characterSettings.mLayer = Layers::MOVING;
characterSettings.mShape = characterShape;
m_Character = std::make_unique(&characterSettings, Vec3(0.f, 20.f, 0.f), Quat::sIdentity(), 0, physics_system.get());
m_Character->AddToPhysicsSystem();
Я ожидаю, что символ скользит только на наклонных поверхностях.

Подробнее здесь: https://stackoverflow.com/questions/797 ... -if-on-ice
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»