Dawn/archive/physics_components/2d/CharacterController2D.hpp

32 lines
826 B
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "SolidController2D.hpp"
#include "TriggerController2D.hpp"
namespace Dawn {
struct CharacterController2DCollisionEventInfo {
std::shared_ptr<SolidController2D> collider;
glm::vec2 normal;
float_t entryTime;
float_t exitTime;
glm::vec2 entryPoint;
glm::vec2 exitPoint;
};
class CharacterController2D : public SceneItemComponent {
public:
// @optional
glm::vec2 velocity = glm::vec2(0, 0);
// @optional
float_t friction = 12.0f;
StateEvent<struct CharacterController2DCollisionEventInfo> eventCollision;
CharacterController2D(std::weak_ptr<SceneItem> i);
void onStart() override;
};
}