Updated the out-of-bounds reset
- Now resets to initial position, and not a random one.
This commit is contained in:
parent
b3b270ae67
commit
1372ac4a6b
|
@ -20,7 +20,8 @@ KartPhysicsComponent::KartPhysicsComponent(mat4 transform,
|
||||||
physicsSystem,
|
physicsSystem,
|
||||||
physicsCollisionSubSystem,
|
physicsCollisionSubSystem,
|
||||||
physicsColliderQuerySubSystem,
|
physicsColliderQuerySubSystem,
|
||||||
collider)
|
collider),
|
||||||
|
mInitialTransform(transform)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
KartPhysicsComponent::~KartPhysicsComponent()
|
KartPhysicsComponent::~KartPhysicsComponent()
|
||||||
|
@ -33,9 +34,8 @@ void KartPhysicsComponent::update(const milliseconds dtms)
|
||||||
|
|
||||||
if (getPosition().y < -100.0f)
|
if (getPosition().y < -100.0f)
|
||||||
{
|
{
|
||||||
setPosition(vec3(getFloatInRange(-10.0f, 10.0f),
|
setPosition(vec3(0, 0, 0), true);
|
||||||
10, /// above the ball
|
setTransform(mInitialTransform);
|
||||||
getFloatInRange(-10.0f, 10.0f)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glm::length(mDirection) > 0)
|
if (glm::length(mDirection) > 0)
|
||||||
|
|
|
@ -77,6 +77,7 @@ class KartPhysicsComponent:
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
vec3 mDirection;
|
vec3 mDirection;
|
||||||
|
mat4 mInitialTransform; ///< Used for reset.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KartPhysicsComponent(mat4 transform,
|
KartPhysicsComponent(mat4 transform,
|
||||||
|
|
Loading…
Reference in New Issue