Something wrong with capsule

This commit is contained in:
2023-03-16 23:01:54 -07:00
parent 6099b5afc6
commit d97d19f93c
5 changed files with 75 additions and 46 deletions

View File

@ -6,6 +6,8 @@
#include "PlayerController.hpp"
#include "game/DawnGame.hpp"
#include "scene/components/physics/3d/CapsuleCollider.hpp"
using namespace Dawn;
PlayerController::PlayerController(SceneItem *item) : SceneItemComponent(item) {
@ -34,5 +36,34 @@ void PlayerController::onStart() {
// Move / Update
transform->setLocalPosition(transform->getLocalPosition() + (velocity * delta));
// tEST
auto collider = item->getComponent<CapsuleCollider>();
Collider3DRayResult result;
struct Ray3D ray;
ray.origin = glm::vec3(0, 0.5f, 1);
ray.direction = glm::vec3(10, 0, 0);
struct Color color = COLOR_MAGENTA;
if(collider->raycast(&result, ray)) {
// std::cout << "Collide!" << std::endl;
color = COLOR_WHITE;
getScene()->debugRay({
.start = result.point,
.direction = (result.normal * 100.0f),
.color = COLOR_GREEN
});
}
getScene()->debugRay({
.start = ray.origin,
.direction = ray.direction,
.color = color
});
}, getScene()->eventSceneUpdate);
}