Sdk/PhysicsSystem3D: Fix CollisionComponent3D teleportating causing velocity increase in physical objects
This commit is contained in:
parent
e9cba3ab6c
commit
78c2e06b58
|
|
@ -60,6 +60,18 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
m_dynamicObjects.Remove(entity);
|
m_dynamicObjects.Remove(entity);
|
||||||
m_staticObjects.Insert(entity);
|
m_staticObjects.Insert(entity);
|
||||||
|
|
||||||
|
// If entities just got added to the system, teleport them to their NodeComponent position/rotation
|
||||||
|
// This will prevent the physics engine to mess with the scene while correcting position/rotation
|
||||||
|
if (justAdded)
|
||||||
|
{
|
||||||
|
auto& collision = entity->GetComponent<CollisionComponent3D>();
|
||||||
|
auto& node = entity->GetComponent<NodeComponent>();
|
||||||
|
|
||||||
|
Nz::RigidBody3D* physObj = collision.GetStaticBody();
|
||||||
|
physObj->SetPosition(node.GetPosition());
|
||||||
|
physObj->SetRotation(node.GetRotation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_world)
|
if (!m_world)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue