add Hitbox.gravityMultiplier
This commit is contained in:
parent
f3201b7742
commit
f52a435aea
@ -307,7 +307,6 @@ void Entities::updatePhysics(float delta) {
|
|||||||
delta,
|
delta,
|
||||||
substeps,
|
substeps,
|
||||||
false,
|
false,
|
||||||
1.0f,
|
|
||||||
true,
|
true,
|
||||||
eid.uid
|
eid.uid
|
||||||
);
|
);
|
||||||
|
|||||||
@ -65,7 +65,6 @@ struct Rigidbody {
|
|||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
Hitbox hitbox;
|
Hitbox hitbox;
|
||||||
std::vector<Trigger> triggers;
|
std::vector<Trigger> triggers;
|
||||||
float gravityMultiplier = 1.0f;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UserComponent {
|
struct UserComponent {
|
||||||
|
|||||||
@ -97,6 +97,7 @@ void Player::updateInput(PlayerInput& input, float delta) {
|
|||||||
|
|
||||||
hitbox->linearDamping = PLAYER_GROUND_DAMPING;
|
hitbox->linearDamping = PLAYER_GROUND_DAMPING;
|
||||||
hitbox->verticalDamping = flight;
|
hitbox->verticalDamping = flight;
|
||||||
|
hitbox->gravityMultiplier = flight ? 0.0f : 1.0f;
|
||||||
if (flight){
|
if (flight){
|
||||||
hitbox->linearDamping = PLAYER_AIR_DAMPING;
|
hitbox->linearDamping = PLAYER_AIR_DAMPING;
|
||||||
if (input.jump){
|
if (input.jump){
|
||||||
@ -118,7 +119,7 @@ void Player::updateInput(PlayerInput& input, float delta) {
|
|||||||
(input.noclip && flight == noclip)){
|
(input.noclip && flight == noclip)){
|
||||||
flight = !flight;
|
flight = !flight;
|
||||||
if (flight){
|
if (flight){
|
||||||
hitbox->grounded = false;
|
hitbox->velocity.y += 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input.noclip) {
|
if (input.noclip) {
|
||||||
|
|||||||
@ -43,6 +43,7 @@ struct Hitbox {
|
|||||||
float linearDamping;
|
float linearDamping;
|
||||||
bool verticalDamping = false;
|
bool verticalDamping = false;
|
||||||
bool grounded = false;
|
bool grounded = false;
|
||||||
|
float gravityMultiplier = 1.0f;
|
||||||
|
|
||||||
Hitbox(glm::vec3 position, glm::vec3 halfsize);
|
Hitbox(glm::vec3 position, glm::vec3 halfsize);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -22,7 +22,6 @@ void PhysicsSolver::step(
|
|||||||
float delta,
|
float delta,
|
||||||
uint substeps,
|
uint substeps,
|
||||||
bool shifting,
|
bool shifting,
|
||||||
float gravityScale,
|
|
||||||
bool collisions,
|
bool collisions,
|
||||||
entityid_t entity
|
entityid_t entity
|
||||||
) {
|
) {
|
||||||
@ -33,6 +32,7 @@ void PhysicsSolver::step(
|
|||||||
const glm::vec3& half = hitbox->halfsize;
|
const glm::vec3& half = hitbox->halfsize;
|
||||||
glm::vec3& pos = hitbox->position;
|
glm::vec3& pos = hitbox->position;
|
||||||
glm::vec3& vel = hitbox->velocity;
|
glm::vec3& vel = hitbox->velocity;
|
||||||
|
float gravityScale = hitbox->gravityMultiplier;
|
||||||
|
|
||||||
bool prevGrounded = hitbox->grounded;
|
bool prevGrounded = hitbox->grounded;
|
||||||
hitbox->grounded = false;
|
hitbox->grounded = false;
|
||||||
|
|||||||
@ -24,7 +24,6 @@ public:
|
|||||||
float delta,
|
float delta,
|
||||||
uint substeps,
|
uint substeps,
|
||||||
bool shifting,
|
bool shifting,
|
||||||
float gravityScale,
|
|
||||||
bool collisions,
|
bool collisions,
|
||||||
entityid_t entity
|
entityid_t entity
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user