PhysicalProjectileInstance ​
Inherits: BaseProjectileInstance < Node3D
Physics-based projectile with gravity, RigidBody3D physics, and raycast collision detection Uses hybrid approach: RigidBody3D for realistic physics + raycast for reliable collision detection
Variables ​
RigidBody3D | rigid_body | |
CollisionShape3D | collision_shape | |
float | gravity_scale | 1.0 |
float | projectile_mass | 1.0 |
float | linear_damping | 0.0 |
float | angular_damping | 0.1 |
bool | use_gravity | true |
Vector3 | previous_position | |
float | raycast_range | 5.0 |
bool | use_raycast_collision | true |
Methods ​
void | set_projectile_mass( mass: float ) |
void | set_gravity_scale( grav_scale: float ) |
void | set_use_gravity( enabled: bool ) |
void | set_linear_damping( damping: float ) |
void | activate_projectile() |
void | deactivate_projectile() |
Vector3 | get_velocity() |
float | get_current_speed() |
void | stop_projectile() |
void | apply_impulse( impulse: Vector3 ) |
void | set_velocity( new_velocity: Vector3 ) |
float | get_distance_to_target() |
bool | is_near_target( threshold: float ) |
Vector3 | get_direction_to_target() |
Vector3 | get_movement_direction() |
void | reset_projectile() |
Dictionary | get_physics_info() |
Variable descriptions ​
RigidBody3D rigid_body ​
RigidBody3D for physics simulation
CollisionShape3D collision_shape ​
CollisionShape3D for physics collision
float gravity_scale = 1.0 ​
Gravity scale for this projectile
float projectile_mass = 1.0 ​
Mass of the projectile
float linear_damping = 0.0 ​
Linear damping (air resistance)
float angular_damping = 0.1 ​
Angular damping
bool use_gravity = true ​
Whether to use gravity
Vector3 previous_position ​
Previous position for raycast collision detection
float raycast_range = 5.0 ​
Raycast range per frame for collision detection
bool use_raycast_collision = true ​
Always use raycast collision (no RigidBody3D collision signals)
Method descriptions ​
void set_projectile_mass( mass: float ) ​
Set projectile mass
void set_gravity_scale( grav_scale: float ) ​
Set gravity scale
void set_use_gravity( enabled: bool ) ​
Enable/disable gravity
void set_linear_damping( damping: float ) ​
Set linear damping (air resistance)
void activate_projectile() ​
Override activate to setup raycast collision
void deactivate_projectile() ​
Override deactivate - no special cleanup needed
Vector3 get_velocity() ​
Get current velocity from RigidBody3D
float get_current_speed() ​
Get current speed
void stop_projectile() ​
Stop the projectile (set velocity to zero)
void apply_impulse( impulse: Vector3 ) ​
Apply impulse to projectile (for explosive launches, etc.)
void set_velocity( new_velocity: Vector3 ) ​
Set velocity directly (for movement strategies)
float get_distance_to_target() ​
Get distance to target (useful for movement strategies)
bool is_near_target( threshold: float ) ​
Check if within distance of target
Vector3 get_direction_to_target() ​
Get direction to target
Vector3 get_movement_direction() ​
Override movement direction getter to use physics velocity
void reset_projectile() ​
Override cleanup to handle physics components
Dictionary get_physics_info() ​
Get physics info for debugging