CARLA
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
AWalkerBase Class Reference

#include <WalkerBase.h>

+ Inheritance diagram for AWalkerBase:

Public Member Functions

void AttachWheelchair ()
 Attach the wheelchair prop to the walker and switch the walker to the sitting animation.
 
 AWalkerBase (const FObjectInitializer &ObjectInitializer)
 
virtual void BeginPlay () override
 
void Kill (FVector ImpactVelocity, AActor *Killer=nullptr)
 Kill the walker as if run over: stop navigation and movement, stop blocking vehicles, ragdoll (or play the directional death animation when the episode requests deterministic ragdolls) and start the after-death life span.
 
void StartDeathLifeSpan ()
 
void TagWheelchair ()
 Re-tag this walker's components.
 

Public Attributes

bool bAlive = true
 
bool bUsesWheelChair = false
 Whether this walker was spawned riding a wheelchair (the "use_wheelchair" user attribute).
 
float LifeSpanAfterDeath = 10.0f
 
float VehicleBodyAllowance = 90.0f
 Lateral clearance (cm) added on top of the capsule radius and sensor margin when testing a fast vehicle's predicted path.
 
float VehicleKillSpeed = 50.0f
 A vehicle touching the walker while moving at least this fast (cm/s) kills it - ue4-dev parity, where any moving-vehicle contact was lethal.
 
float VehicleSensorMargin = 50.0f
 How far beyond the capsule radius the vehicle proximity check reaches (cm).
 
float VehicleSensorPeriod = 0.02f
 Vehicle proximity poll period in seconds.
 
float VehicleSensorSpeedBound = 8333.0f
 Fastest closing speed (cm/s) the proximity query is sized for (default 300 km/h).
 
TObjectPtr< USkeletalMeshComponent > WheelchairComponent = nullptr
 The wheelchair mesh attached by AttachWheelchair(), null for walkers spawned without one.
 

Private Member Functions

void CheckVehicleImpact ()
 
void OnBodyHit (AActor *SelfActor, AActor *OtherActor, FVector NormalImpulse, const FHitResult &Hit)
 
void TryKillFromVehicle (AActor *OtherActor)
 

Private Attributes

FTimerHandle VehicleSensorTimer
 

Detailed Description

Definition at line 18 of file WalkerBase.h.

Constructor & Destructor Documentation

◆ AWalkerBase()

AWalkerBase::AWalkerBase ( const FObjectInitializer &  ObjectInitializer)

Definition at line 27 of file WalkerBase.cpp.

Member Function Documentation

◆ AttachWheelchair()

void AWalkerBase::AttachWheelchair ( )

Attach the wheelchair prop to the walker and switch the walker to the sitting animation.

Called by the walker factory right after spawn when the "use_wheelchair" attribute is set (ue4-dev did this from the factory blueprint's AddWheelchairToWalker). All content is soft-loaded: if the wheelchair assets are missing the walker stays a normal pedestrian and a warning is logged. Idempotent.

Definition at line 44 of file WalkerBase.cpp.

References TagWheelchair(), and WheelchairComponent.

Referenced by AWalkerActorFactory::SpawnActor().

◆ BeginPlay()

void AWalkerBase::BeginPlay ( )
overridevirtual

◆ CheckVehicleImpact()

void AWalkerBase::CheckVehicleImpact ( )
private

◆ Kill()

void AWalkerBase::Kill ( FVector  ImpactVelocity,
AActor *  Killer = nullptr 
)

Kill the walker as if run over: stop navigation and movement, stop blocking vehicles, ragdoll (or play the directional death animation when the episode requests deterministic ragdolls) and start the after-death life span.

Idempotent.

Definition at line 323 of file WalkerBase.cpp.

References AWalkerBase_IsMirror(), bAlive, UCarlaStatics::GetCurrentEpisode(), and StartDeathLifeSpan().

Referenced by CheckVehicleImpact(), and TryKillFromVehicle().

◆ OnBodyHit()

void AWalkerBase::OnBodyHit ( AActor *  SelfActor,
AActor *  OtherActor,
FVector  NormalImpulse,
const FHitResult &  Hit 
)
private

Definition at line 206 of file WalkerBase.cpp.

References bAlive, and TryKillFromVehicle().

Referenced by BeginPlay().

◆ StartDeathLifeSpan()

void AWalkerBase::StartDeathLifeSpan ( )
inline

Definition at line 84 of file WalkerBase.h.

Referenced by Kill().

◆ TagWheelchair()

void AWalkerBase::TagWheelchair ( )

Re-tag this walker's components.

Called by the walker blueprint after attaching a wheelchair mesh, as freshly attached components carry no semantic-segmentation tag.

Definition at line 33 of file WalkerBase.cpp.

References ATagger::TagActor().

Referenced by AttachWheelchair().

◆ TryKillFromVehicle()

void AWalkerBase::TryKillFromVehicle ( AActor *  OtherActor)
private

Definition at line 215 of file WalkerBase.cpp.

References Kill(), Vehicle, and VehicleKillSpeed.

Referenced by OnBodyHit().

Member Data Documentation

◆ bAlive

bool AWalkerBase::bAlive = true

Definition at line 28 of file WalkerBase.h.

Referenced by CheckVehicleImpact(), Kill(), and OnBodyHit().

◆ bUsesWheelChair

bool AWalkerBase::bUsesWheelChair = false

Whether this walker was spawned riding a wheelchair (the "use_wheelchair" user attribute).

The walker blueprint reads it to attach the wheelchair mesh; the bounding-box calculator enlarges the walker bounds accordingly.

Definition at line 38 of file WalkerBase.h.

Referenced by AWalkerActorFactory::SpawnActor().

◆ LifeSpanAfterDeath

float AWalkerBase::LifeSpanAfterDeath = 10.0f

Definition at line 31 of file WalkerBase.h.

◆ VehicleBodyAllowance

float AWalkerBase::VehicleBodyAllowance = 90.0f

Lateral clearance (cm) added on top of the capsule radius and sensor margin when testing a fast vehicle's predicted path.

Stands in for the vehicle body's half width, since the prediction sweeps the actor center, not the collision geometry.

Definition at line 75 of file WalkerBase.h.

Referenced by CheckVehicleImpact().

◆ VehicleKillSpeed

float AWalkerBase::VehicleKillSpeed = 50.0f

A vehicle touching the walker while moving at least this fast (cm/s) kills it - ue4-dev parity, where any moving-vehicle contact was lethal.

The threshold only exempts effectively stationary vehicles (a walker bumping into a parked or stopped car survives). It must stay low: an alive walker's capsule is query-only, so a sub-threshold moving contact has no physical response at all and the car visibly interpenetrates the standing pedestrian.

Definition at line 48 of file WalkerBase.h.

Referenced by CheckVehicleImpact(), and TryKillFromVehicle().

◆ VehicleSensorMargin

float AWalkerBase::VehicleSensorMargin = 50.0f

How far beyond the capsule radius the vehicle proximity check reaches (cm).

The margin makes the kill trigger before the first physical contact: the capsule is a kinematic body, so to a simulating vehicle it is an infinite-mass wall - the impulse of a real contact is what used to launch and spin cars. The capsule is query-only, so vehicles never physically contact it - what launched cars was the wheel suspension raycasts riding the blocking capsule like a rigid bollard. The kill therefore fires from this proximity poll just before the wheels reach the capsule, and the collision event is delivered to the vehicle's sensors explicitly from Kill().

Definition at line 62 of file WalkerBase.h.

Referenced by CheckVehicleImpact().

◆ VehicleSensorPeriod

float AWalkerBase::VehicleSensorPeriod = 0.02f

Vehicle proximity poll period in seconds.

A timer rather than Tick(): the walker blueprints keep actor tick disabled for performance, and the timer must not depend on that.

Definition at line 68 of file WalkerBase.h.

Referenced by BeginPlay(), and CheckVehicleImpact().

◆ VehicleSensorSpeedBound

float AWalkerBase::VehicleSensorSpeedBound = 8333.0f

Fastest closing speed (cm/s) the proximity query is sized for (default 300 km/h).

Only affects the overlap query radius; the per-vehicle path prediction uses the vehicle's actual velocity.

Definition at line 81 of file WalkerBase.h.

Referenced by CheckVehicleImpact().

◆ VehicleSensorTimer

FTimerHandle AWalkerBase::VehicleSensorTimer
private

Definition at line 128 of file WalkerBase.h.

Referenced by BeginPlay(), and CheckVehicleImpact().

◆ WheelchairComponent

TObjectPtr<USkeletalMeshComponent> AWalkerBase::WheelchairComponent = nullptr

The wheelchair mesh attached by AttachWheelchair(), null for walkers spawned without one.

Definition at line 114 of file WalkerBase.h.

Referenced by AttachWheelchair().


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