SetEnableGravity fixed for pedestrians

Also removed some debug prints
This commit is contained in:
Daniel Santos-Olivan 2020-09-30 16:53:16 +02:00 committed by Marc Garcia Puig
parent 95abf25a10
commit 7bd1d6e920
3 changed files with 3 additions and 10 deletions

View File

@ -85,7 +85,6 @@ namespace client {
} }
void Actor::SetEnableGravity(const bool enabled) { void Actor::SetEnableGravity(const bool enabled) {
std::cout << "Actor::SetEnableGravity" << std::endl;
GetEpisode().Lock()->SetActorEnableGravity(*this, enabled); GetEpisode().Lock()->SetActorEnableGravity(*this, enabled);
} }

View File

@ -309,7 +309,6 @@ namespace detail {
} }
void Client::SetActorEnableGravity(rpc::ActorId actor, const bool enabled) { void Client::SetActorEnableGravity(rpc::ActorId actor, const bool enabled) {
std::cout << "SetActorEnableGravity" << std::endl;
_pimpl->AsyncCall("set_actor_enable_gravity", actor, enabled); _pimpl->AsyncCall("set_actor_enable_gravity", actor, enabled);
} }

View File

@ -828,14 +828,12 @@ void FCarlaServer::FPimpl::BindActions()
RESPOND_ERROR("unable to set actor simulate physics: actor not found"); RESPOND_ERROR("unable to set actor simulate physics: actor not found");
} }
UE_LOG(LogCarla, Warning, TEXT("CarlaServer: set_actor_simulate_physics %d!!!!"), bEnabled);
auto Character = Cast<ACharacter>(ActorView.GetActor()); auto Character = Cast<ACharacter>(ActorView.GetActor());
// The physics in the walkers works in a different way so to disable them, // The physics in the walkers works in a different way so to disable them,
// we need to do it in the UCharacterMovementComponent. // we need to do it in the UCharacterMovementComponent.
if (Character != nullptr) if (Character != nullptr)
{ {
auto CharacterMovement = Cast<UCharacterMovementComponent>(Character->GetCharacterMovement()); auto CharacterMovement = Cast<UCharacterMovementComponent>(Character->GetCharacterMovement());
UE_LOG(LogCarla, Error, TEXT("Character::SetEnableGravity %d!!!!"), bEnabled);
if(bEnabled) { if(bEnabled) {
CharacterMovement->SetDefaultMovementMode(); CharacterMovement->SetDefaultMovementMode();
@ -849,7 +847,6 @@ void FCarlaServer::FPimpl::BindActions()
else else
{ {
auto RootComponent = Cast<UPrimitiveComponent>(ActorView.GetActor()->GetRootComponent()); auto RootComponent = Cast<UPrimitiveComponent>(ActorView.GetActor()->GetRootComponent());
UE_LOG(LogCarla, Error, TEXT("Root::SetEnableGravity %d!!!!"), bEnabled);
if (RootComponent == nullptr) if (RootComponent == nullptr)
{ {
RESPOND_ERROR("unable to set actor simulate physics: not supported by actor"); RESPOND_ERROR("unable to set actor simulate physics: not supported by actor");
@ -876,20 +873,19 @@ void FCarlaServer::FPimpl::BindActions()
RESPOND_ERROR("unable to set actor enable gravity: actor not found"); RESPOND_ERROR("unable to set actor enable gravity: actor not found");
} }
UE_LOG(LogCarla, Error, TEXT("CarlaServer: set_actor_enable_gravity %d!!!!"), bEnabled);
auto Character = Cast<ACharacter>(ActorView.GetActor()); auto Character = Cast<ACharacter>(ActorView.GetActor());
// The physics in the walkers works in a different way so to disable them, // The physics in the walkers works in a different way so to disable them,
// we need to do it in the UCharacterMovementComponent. // we need to do it in the UCharacterMovementComponent.
if (Character != nullptr) if (Character != nullptr)
{ {
auto CharacterMovement = Cast<UCharacterMovementComponent>(Character->GetCharacterMovement()); auto CharacterMovement = Cast<UCharacterMovementComponent>(Character->GetCharacterMovement());
UE_LOG(LogCarla, Error, TEXT("Character::SetEnableGravity %d!!!!"), bEnabled);
if(bEnabled) { if(bEnabled) {
CharacterMovement->GravityScale = 1.0f; CharacterMovement->SetDefaultMovementMode();
} }
else { else {
CharacterMovement->GravityScale = 0.0f; if (CharacterMovement->IsFlying() || CharacterMovement->IsFalling())
CharacterMovement->DisableMovement();
} }
} }
// In the rest of actors, the physics is controlled with the UPrimitiveComponent, so we use // In the rest of actors, the physics is controlled with the UPrimitiveComponent, so we use
@ -901,7 +897,6 @@ void FCarlaServer::FPimpl::BindActions()
{ {
RESPOND_ERROR("unable to set actor enable gravity: not supported by actor"); RESPOND_ERROR("unable to set actor enable gravity: not supported by actor");
} }
UE_LOG(LogCarla, Error, TEXT("SetEnableGravity %d!!!!"), bEnabled);
RootComponent->SetEnableGravity(bEnabled); RootComponent->SetEnableGravity(bEnabled);
} }