Hi,
Im trying to override the TickVehicle function, but it is never called?
class MY_API UMyWheeledVehicleMovementComponent: public UWheeledVehicleMovementComponent
{
GENERATED_BODY()
virtual void TickVehicle(float DeltaTime) override;
}
is this perhaps because the vehicle manager might fire the function still on the baseclass ?
PhysXVehicleManager.h
// All instanced vehicles
TArray<TWeakObjectPtr<class UWheeledVehicleMovementComponent>> Vehicles;
I edited the code to what i have now, but still not working.
Anyone could help? thanks
Lhorkan
(Lhorkan)
June 6, 2017, 2:50pm
3
Can you show us your .cpp? If Tick functions aren’t called, I’ve found it can be because you forgot to call Super::BeginPlay() in BeginPlay.
When you override a virtual function, the implementation in your child class will definitely be used.
Hi, thanks for the reply
The .cpp code i have might be as expected:
void UMyWheeledVehicleMovementComponent::TickVehicle(float DeltaTime)
{
Super::TickVehicle(DeltaTime);
UE_LOG(LogTemp, Warning, TEXT(">>> TickVehicle<<<"));
}
The ue_log is not showing up…
I do not have BeginPlay implemented. Why would that matter?
Lhorkan
(Lhorkan)
June 6, 2017, 3:34pm
5
Because with regular ticks, if Super::BeginPlay() isn’t called, the actor / component will never tick. However, since you don’t override it, it’s fine.
I just checked the API, and neither UWheeledVehicleMovementComponent nor any of its parents or interfaces has a TickVehicle function. Are you sure you’re not supposed to be overriding TickComponent instead?
Okay well, the UWheeledVehicleMovementComponent api indeed has no TickVehicle… wierd.
However, in the class:
//WheeledVehicleMovmentComponent.h
/** Tick this vehicle sim right before input is sent to the vehicle system */
virtual void TickVehicle( float DeltaTime );
//WheeledVehicleMovmentComponent.cpp
void UWheeledVehicleMovementComponent::TickVehicle( float DeltaTime )
{
if (AvoidanceLockTimer > 0.0f)
{
AvoidanceLockTimer -= DeltaTime;
}
// movement updates and replication
if (PVehicle && UpdatedComponent)
{
APawn* MyOwner = Cast<APawn>(UpdatedComponent->GetOwner());
if (MyOwner)
{
UpdateSimulation(DeltaTime);
}
}
// update wheels
for (int32 i = 0; i < Wheels.Num(); i++)
{
Wheels*->Tick(DeltaTime);
}
UpdateDrag(DeltaTime);
}
I need to be able to only use the wheels and implement my own movement inside TickVehicle
is there any way how i could do that?
This VehicleTick function is being called inside the vehicle manager:
//PhysXVehicleManager.cpp
inside the Update function:
// Tick vehicles
{
SCOPE_CYCLE_COUNTER(STAT_PhysXVehicleManager_TickVehicles);
for (int32 i = Vehicles.Num() - 1; i >= 0; --i)
{
Vehicles*->TickVehicle(DeltaTime);
}
}
BulleTime
(BulleTime)
July 17, 2017, 12:48pm
7
Because with regular ticks, if Super::BeginPlay() isn’t called, the actor / component will never tick. However, since you don’t override it, it’s fine.
I just checked the API, and neither UWheeledVehicleMovementComponent nor any of its parents or interfaces has a TickVehicle function. Are you sure you’re not supposed to be overriding TickComponent instead?
Since 4.16 (or lower) there is a TickVehicle… But still im not able to override it.
UWheeledVehicleMovementComponent