Download

Disable actor gravity

I have a class which derives from actor. In this class I have 2 object - one UStaticMeshComponent and the other is fireBallParticle. I want to disable this actor’s gravity. I have been tried to user SetEnableGravity(false) for both components but it doesn’t work:


AFireBall::AFireBall(const FObjectInitializer& ObjectInitializer)
    {
    	PrimaryActorTick.bCanEverTick = true;
    
    	mesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh Component"));
    	RootComponent = mesh;
    
    	fireBallParticle = ObjectInitializer.CreateDefaultSubobject<UParticleSystemComponent>(this, TEXT("fireBallParticle"));
    	fireBallParticle->AttachTo(RootComponent);
    	
    	mesh->SetEnableGravity(false);
    	fireBallParticle->SetEnableGravity(false);
    }

How can I disable the gravity?

I bet you have a Projectile Movement component for your fireball, if so, just set the ProjectileGravityScale to 0.
If you don’t use this component, you should look in GetEffectiveGravityZ() to know how to manage this.

Well, I do not use this component and GetEffectiveGravityZ belongs to Projectile Movement component: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/UProjectileMovementComponent/GetEffectiveGrav-/index.html

Yes it belongs to it, but you should look how it use to repro the GravityManagement in your movement component.