Something wrong with capsule

This commit is contained in:
2023-03-16 23:01:54 -07:00
parent 11af9d147a
commit 669b02ca06
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);
}

View File

@ -38,9 +38,8 @@ namespace Dawn {
wallHitbox->min = -(wallHitbox->max = glm::vec3(1, 1, 5));
camera = Camera::create(this);
// camera->transform->lookAt(glm::vec3(0, 0, 8), glm::vec3(0, 0, 0));
// auto gameCamera = camera->item->addComponent<GameCamera>();
camera->transform->lookAt(glm::vec3(4, 4, 4), glm::vec3(0, 0, 0));
// auto gameCamera = camera->item->addComponent<GameCamera>();
// gameCamera->player = player;
}