CharacterController
Namespace:
namespace Lenga\Engine\Core;
class CharacterController
Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\CharacterController;
use Lenga\Engine\Core\Vector3;
use Lenga\Engine\Core\Time;
class PlayerMovement extends Behaviour
{
public float $speed = 5.0;
public function update(): void
{
$controller = $this->getComponent(CharacterController::class);
$moveDirection = new Vector3(0, 0, 0);
if (Input::getKey(KeyCode::W)) {
$moveDirection->z += 1;
}
if (Input::getKey(KeyCode::S)) {
$moveDirection->z -= 1;
}
$delta = Vector3::scale($moveDirection, $this->speed * Time::deltaTime());
$collisionFlags = $controller->move($delta);
}
}