添加手雷对吊桥扰动

main
wuyize 2023-04-20 13:40:05 +08:00
parent a60cd33221
commit dbae5cb272
2 changed files with 12 additions and 3 deletions

View File

@ -65,7 +65,7 @@ DemoWorld::DemoWorld()
if (i != 0) if (i != 0)
{ {
float ks = 300, kd = 100; float ks = 300, kd = 500;
physicsManager.addSpring(particles[i - 1], particle, 0.005, ks, kd); physicsManager.addSpring(particles[i - 1], particle, 0.005, ks, kd);
} }
} }
@ -93,9 +93,18 @@ void DemoWorld::logicalTick(float deltaTime)
if (abs(throwPerson->getAnimatorCurrentTime() - 3.41f) < 1e-2f) if (abs(throwPerson->getAnimatorCurrentTime() - 3.41f) < 1e-2f)
{ {
mk2->setPosition(throwPerson->getPosition() + glm::vec3(-0.5, 2.2, 0)); mk2->setPosition(throwPerson->getPosition() + glm::vec3(-0.5, 2.2, 0));
mk2->setSpeed(glm::mat3_cast(throwPerson->getRotation() * glm::rotation(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(0, 1, 1)/*方向*/))) * glm::vec3(15/*速度*/, 0, 0)); mk2->setSpeed(glm::mat3_cast(throwPerson->getRotation() * glm::rotation(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(0, 2, 1)/*方向*/))) * glm::vec3(10/*速度*/, 0, 0));
mk2->setEnableGravity(true); mk2->setEnableGravity(true);
} }
if (mk2->getPosition().y < 6.5f && mk2->getSpeed().y<0)
{
particles[particles.size() / 2]->setSpeed(particles[particles.size() / 2]->getSpeed() + mk2->getSpeed()/2.f);
mk2->setEnableGravity(false);
mk2->setSpeed(glm::vec3(0));
//mk2->setPosition({ 0,-100,0 });
}
} }
void DemoWorld::rendererTick(float deltaTime) void DemoWorld::rendererTick(float deltaTime)

View File

@ -120,8 +120,8 @@ void Particle::setEnableGravity(bool enable)
if (!gravity) if (!gravity)
{ {
gravity = std::make_shared<Force>(glm::vec3(0.f, -getMass() * 9.80665f, 0.f)); gravity = std::make_shared<Force>(glm::vec3(0.f, -getMass() * 9.80665f, 0.f));
addForce(gravity);
} }
addForce(gravity);
} }
else else
{ {