JAMSPOOK-13 - Steering done!

- Torque (steering) implemented!
- Friction tweaked as well.
This commit is contained in:
Fredrick Amnehagen 2020-08-19 21:19:22 +02:00
parent d4a8e9d908
commit f225990f6b
3 changed files with 6 additions and 6 deletions

View File

@ -63,7 +63,7 @@ shared_ptr<Entity> KartFactory::createKart(const vec3 position,
physicsComponent->getCollider()->getRigidBody()->setLinearFactor(btVector3(1,1,1)); // allow all positional movement movement
physicsComponent->getCollider()->getRigidBody()->setAngularFactor(btVector3(1,1,1)); // allow all rotational movement movement
physicsComponent->getCollider()->getRigidBody()->setRestitution(0.1f);
physicsComponent->getCollider()->getRigidBody()->setFriction(0.01f);
// physicsComponent->getCollider()->getRigidBody()->setFriction(0.1f);
// physicsComponent->getCollider()->getRigidBody()->setGravity(btVector3(0, 0, 0)); // no gravity, length of zero
physicsComponent->getCollider()->getRigidBody()->setActivationState(DISABLE_DEACTIVATION); // RigidBody may never sleep. (Note: Or else it will not respond to setLinearVelocity when standing still for too long(a couple of seconds).)

View File

@ -29,20 +29,20 @@ void KartInteractionComponent::onInputDeviceStateChange(const InputDeviceState i
// Handle controls
if (inputDeviceState.left == ButtonState::pressed || inputDeviceState.left == ButtonState::held)
{
accumulatedDirection += vec3(-1.0f, 0, 0);
accumulatedDirection += vec3(1.0f, 0, 0);
}
else if (inputDeviceState.left == ButtonState::released)
{
accumulatedDirection -= vec3(-1.0f, 0, 0);
accumulatedDirection -= vec3(1.0f, 0, 0);
}
if (inputDeviceState.right == ButtonState::pressed || inputDeviceState.right == ButtonState::held)
{
accumulatedDirection += vec3(1.0f, 0, 0);
accumulatedDirection += vec3(-1.0f, 0, 0);
}
else if (inputDeviceState.right == ButtonState::released)
{
accumulatedDirection -= vec3(1.0f, 0, 0);
accumulatedDirection -= vec3(-1.0f, 0, 0);
}
if (inputDeviceState.up == ButtonState::pressed || inputDeviceState.up == ButtonState::held)

View File

@ -45,7 +45,7 @@ void KartPhysicsComponent::update(const milliseconds dtms)
vec3(0, 0, 0));
// Turning torque
mCollider->applyTorque(mat3(mTransform) * vec3(0, mDirection.x * 500, 0));
}
}