Something wrong with capsule
This commit is contained in:
@ -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);
|
||||
}
|
Reference in New Issue
Block a user