# Rally Rush: godot::EnemyCar Class Reference

Loading...
Searching...
No Matches
godot::EnemyCar Class Reference

The enemy car, inherits CarPhysics subclass sandbox and uses a NavigationAgent3D to direct it. More...

`#include <enemy_car.hpp>`

Inheritance diagram for godot::EnemyCar:

## Public Member Functions

virtual void | _enter_tree () override
| Call parent _enter_tree and fetch object references for later use.
virtual void | _process (double delta_time) override
| Update current navigation and acceleration. Recalculate path every recalc_frame_interval frames. Update CarPhysics sandbox functions to drive towards next path position.
void | damage ()
| Destroy this object.
void | start_fleeing ()
| Called from RallyRushGameMode shield pickup observer. Start fleeing from the player.
void | stop_fleeing ()
| Called from RallyRushGameMode shield pickup end observer. Stop fleeing from the player.
Public Member Functions inherited from godot::CarPhysics
virtual void | _enter_tree () override
| Enable _integrate_forces, fetch child nodes, and setup contact monitoring.
virtual void | _physics_process (double delta_time) override
| Fixed-interval process function. Split into process_oversteer and process_understeer.
void | process_oversteer (double delta_time)
| Process the current_oversteer member variable.
void | process_understeer (double delta_time)
| Process the current_understeer member variable.
virtual void | _integrate_forces (PhysicsDirectBodyState3D *state) override
| Custom force integrator. Split into integrate_steering, integrate_engine_acceleration and integrate_oversteer. After calling other integrate_* functions, applies local_velocity to state.velocity.
Vector3 | get_local_velocity () const
| Public getter for current local velocity.
Vector3 | local_to_world_velocity () const
| transform the current local_velocity to world coordinates
Vector3 | world_to_local_velocity () const
| transform the current world velocity to local coordinates
float | get_current_speed () const
| The current forward velocity (local_velocity.z)
void | set_target_speed (float target)
| The target speed.
float | get_target_speed () const
| The target speed.
void | set_current_steering (float steering)
| The current steering input.
float | get_current_steering () const
| The current steering input.
void | set_brake (bool value)
| True if the hand-brake is currently active.
bool | get_brake () const
| True if the hand-brake is currently active.
void | set_oversteer_curve (Ref< Curve > curve)
| The base curve used for oversteering.
Ref< Curve > | get_oversteer_curve () const
| The base curve used for oversteering.
void | set_oversteer_curve_x_scale (float scale)
| The amount of speed represented by x=1 on the oversteer curve.
float | get_oversteer_curve_x_scale () const
| The amount of speed represented by x=1 on the oversteer curve.
void | set_understeer_curve (Ref< Curve > curve)
| The base curve used for understeering.
Ref< Curve > | get_understeer_curve () const
| The base curve used for understeering.
void | set_understeer_curve_x_scale (float scale)
| The amount of speed represented by x=1 on the understeer curve.
float | get_understeer_curve_x_scale () const
| The amount of speed represented by x=1 on the understeer curve.
void | set_acceleration (float value)
| The base engine acceleration of this car.
float | get_acceleration () const
| The base engine acceleration of this car.
void | set_engine_brake_force (float value)
| The base engine braking force of this car.
float | get_engine_brake_force () const
| The base engine braking force of this car.
void | set_handbrake_force (float value)
| The amount of braking force applied by the handbrake.
float | get_handbrake_force () const
| The amount of braking force applied by the handbrake.
void | set_handbrake_oversteer (float value)
| The modifier applied to oversteering when the handbrake is active.
float | get_handbrake_oversteer () const
| The modifier applied to oversteering when the handbrake is active.
void | set_traction_recovery_speed (float value)
| The speed at which the car will return to regular traction after under- or oversteering.
float | get_traction_recovery_speed () const
| The speed at which the car will return to regular traction after under- or oversteering.
void | set_max_slide_speed (float value)
| The maximum sideways speed that can be reached while drifting.
float | get_max_slide_speed () const
| The maximum sideways speed that can be reached while drifting.
void | set_slide_speed_acceleration (float value)
| The sideways acceleration applied when drifting.
float | get_slide_speed_acceleration () const
| The sideways acceleration applied when drifting.
void | set_oversteer_speed_penalty (float value)
| Deceleration applied to forward speed when oversteering.
float | get_oversteer_speed_penalty () const
| Deceleration applied to forward speed when oversteering.
void | set_oversteer_brake_penalty (float value)
| Modifier applied to brake force when oversteering.
float | get_oversteer_brake_penalty () const
| Modifier applied to brake force when oversteering.
void | set_oversteer_steering_speed (float value)
| Modifier applied to brake force when oversteering.
float | get_oversteer_steering_speed () const
| Base amount of steering applied while oversteering.
void | set_slide_resistance (float value)
| Deceleration applied to sideways velocity.
float | get_slide_resistance () const
| Deceleration applied to sideways velocity.
void | set_steering_inward_speed (float value)
| Target amount of velocity towards the centre of a turn while steering.
float | get_steering_inward_speed () const
| Target amount of velocity towards the centre of a turn while steering.

## Protected Member Functions

void | recalculate_navigation ()
| Calculate a new path to the player.
Protected Member Functions inherited from godot::CarPhysics
void | integrate_steering (PhysicsDirectBodyState3D *state)
| Integrate steering into angular and local x velocities. As a side-effect this also applies sliding resistance and sliding recovery. Also detects crashes to avoid glitchy behaviour when accelerating into a wall.
void | integrate_engine_acceleration (PhysicsDirectBodyState3D *state)
| Apply velocity along local z. Accelerates towards value returned by get_true_target_speed at get_current_acceleration m/s^2.
void | integrate_oversteer (PhysicsDirectBodyState3D *state)
| Integrate oversteering to local_velocity to allow drifting.
void | on_body_shape_entered (RID body_rid, Node *node, int body_shape_index, int local_shape_index)
| Detect that an object started colliding with the wheels.
void | on_body_shape_exited (RID body_rid, Node *node, int body_shape_index, int local_shape_index)
| Detect that an object lost contact with the wheels.
float | evaluate_oversteer_curve (float speed) const
| evaluate the oversteer curve with a speed, taking *_x_scale into account
float | evaluate_understeer_curve (float speed) const
| evaluate the understeer curve with a speed, taking *_x_scale into account
float | get_true_target_speed () const
| Returns the maximum speed modified by under/oversteer.
bool | is_grounded () const
| Returns true if there is at least one contact with either of the wheels.
float | get_current_acceleration () const
| Returns acceleration, taking into account braking, throttle, and handbrake.

## Private Member Functions

| GDCLASS (EnemyCar, CarPhysics)

## Static Private Member Functions

static void | _bind_methods ()
| Register damage function.

## Private Attributes

int | next_recalc {0}
| Frame timer to next recalculate_navigation call.
int | recalc_frame_interval {60}
| Interval in frames between calls to recalculate_navigation.
float | turn_target_speed {3.f}
| Desired speed when approaching a corner.
float | max_speed {45.f}
| Max speed when driving straight ahead.
float | brake_distance {7.f}
| Distance from corners at which to start braking.
float | steering_speed {1.5f}
| Speed at which to steer.
bool | flee {false}
| If true, invert goal direction and drive away from the player.
NavigationAgent3D * | agent {nullptr}
| Navigation agent child node.
CarPlayer * | player {nullptr}
| Reference to the player car.

## Detailed Description

The enemy car, inherits CarPhysics subclass sandbox and uses a NavigationAgent3D to direct it.

## Member Function Documentation

## _bind_methods()

void godot::EnemyCar::_bind_methods | ( |  | ) |

staticprivate

Register damage function.

## _enter_tree()

void godot::EnemyCar::_enter_tree | ( |  | ) |

overridevirtual

Call parent _enter_tree and fetch object references for later use.

Reimplemented from godot::CarPhysics.

## _process()

void godot::EnemyCar::_process | ( | double | delta_time | ) |

overridevirtual

Update current navigation and acceleration. Recalculate path every recalc_frame_interval frames. Update CarPhysics sandbox functions to drive towards next path position.

## damage()

void godot::EnemyCar::damage | ( |  | ) |

Destroy this object.

## GDCLASS()

godot::EnemyCar::GDCLASS | ( | EnemyCar | ,
|  | CarPhysics |
| ) |  |

private

## recalculate_navigation()

void godot::EnemyCar::recalculate_navigation | ( |  | ) |

protected

Calculate a new path to the player.

## start_fleeing()

void godot::EnemyCar::start_fleeing | ( |  | ) |

Called from RallyRushGameMode shield pickup observer. Start fleeing from the player.

## stop_fleeing()

void godot::EnemyCar::stop_fleeing | ( |  | ) |

Called from RallyRushGameMode shield pickup end observer. Stop fleeing from the player.

## Member Data Documentation

## agent

NavigationAgent3D* godot::EnemyCar::agent {nullptr}

private

Navigation agent child node.

## brake_distance

float godot::EnemyCar::brake_distance {7.f}

private

Distance from corners at which to start braking.

## flee

bool godot::EnemyCar::flee {false}

private

If true, invert goal direction and drive away from the player.

## max_speed

float godot::EnemyCar::max_speed {45.f}

private

Max speed when driving straight ahead.

## next_recalc

int godot::EnemyCar::next_recalc {0}

private

Frame timer to next recalculate_navigation call.

## player

CarPlayer* godot::EnemyCar::player {nullptr}

private

Reference to the player car.

## recalc_frame_interval

int godot::EnemyCar::recalc_frame_interval {60}

private

Interval in frames between calls to recalculate_navigation.

## steering_speed

float godot::EnemyCar::steering_speed {1.5f}

private

Speed at which to steer.

## turn_target_speed

float godot::EnemyCar::turn_target_speed {3.f}

private

Desired speed when approaching a corner.

The documentation for this class was generated from the following files:

- src/enemy_car.hpp
- src/enemy_car.cpp