Rally Rush
Loading...
Searching...
No Matches
enemy_car.hpp
Go to the documentation of this file.
1#ifndef ENEMY_CAR_HPP
2#define ENEMY_CAR_HPP
3
4#include "car_physics.hpp"
5#include "car_player.hpp"
6#include "godot_cpp/classes/navigation_agent3d.hpp"
7
8namespace godot {
10class EnemyCar : public CarPhysics {
13 static void _bind_methods();
14public:
16 virtual void _enter_tree() override;
18 virtual void _process(double delta_time) override;
20 void damage();
22 void start_fleeing();
24 void stop_fleeing();
25protected:
28private:
36 float max_speed{45.f};
38 float brake_distance{7.f};
40 float steering_speed{1.5f};
42 bool flee{false};
44 NavigationAgent3D *agent{nullptr};
46 CarPlayer *player{nullptr};
47};
48}
49
50#endif // !ENEMY_CAR_HPP
Subclass Sandbox for car physics. Uses _integrate_forces and local_velocity to abstract the behaviour...
Definition car_physics.hpp:13
Sandboxed subclass of CarPhysics.
Definition car_player.hpp:18
The enemy car, inherits CarPhysics subclass sandbox and uses a NavigationAgent3D to direct it.
Definition enemy_car.hpp:10
float max_speed
Max speed when driving straight ahead.
Definition enemy_car.hpp:36
static void _bind_methods()
Register damage function.
Definition enemy_car.cpp:9
GDCLASS(EnemyCar, CarPhysics)
float turn_target_speed
Desired speed when approaching a corner.
Definition enemy_car.hpp:34
void recalculate_navigation()
Calculate a new path to the player.
Definition enemy_car.cpp:51
NavigationAgent3D * agent
Navigation agent child node.
Definition enemy_car.hpp:44
float brake_distance
Distance from corners at which to start braking.
Definition enemy_car.hpp:38
int recalc_frame_interval
Interval in frames between calls to recalculate_navigation.
Definition enemy_car.hpp:32
float steering_speed
Speed at which to steer.
Definition enemy_car.hpp:40
virtual void _process(double delta_time) override
Update current navigation and acceleration. Recalculate path every recalc_frame_interval frames....
Definition enemy_car.cpp:25
void stop_fleeing()
Called from RallyRushGameMode shield pickup end observer. Stop fleeing from the player.
Definition enemy_car.cpp:47
void damage()
Destroy this object.
Definition enemy_car.cpp:39
virtual void _enter_tree() override
Call parent _enter_tree and fetch object references for later use.
Definition enemy_car.cpp:14
int next_recalc
Frame timer to next recalculate_navigation call.
Definition enemy_car.hpp:30
bool flee
If true, invert goal direction and drive away from the player.
Definition enemy_car.hpp:42
void start_fleeing()
Called from RallyRushGameMode shield pickup observer. Start fleeing from the player.
Definition enemy_car.cpp:43
CarPlayer * player
Reference to the player car.
Definition enemy_car.hpp:46
Definition beacon_powerup.cpp:6