How to make a projectile push player?

I d like to be able to jump on a projectile and travel on it. This also means that projectile has to push my character away instead of bouncing off of it.

I tried to accomplish this by giving a much bigger mass to collision component of my projectile than to collision component of my character, but apparently its not that easy x)

Any help would be greatly appreciated! =)

1 Like

Just disable “bounce” in projectile properties + change collision type from collision sphere to “block all”. Now it will push player + you can also jump onto it :slight_smile: (everything done in component tab of projectile)

Thanks for quick response!:slight_smile:

I set up a new fps bp scene to be sure. If I do what you say, i am able to jump onto projectiles- wich is great. But if I for example fire a projectile, stop time, walk arround it and let it hit me - it just stops instead of pushing me away.

Apart from that, I need projectile to bounce…

Any Ideas?=)

Hey iNviSible.yuno,

A physics object will not push an actor that does not Simulate Physics. Characters cannot Simulate Physics because it interferes with Character Movement component, which fakes its own physics for movement input. So if you want to push character when a physics object collides with it, you need to fake it by moving character during contact.

You can read about a way to implement that method here:

https://answers.unrealengine/questions/48892/collision-not-working-when-standing-still.html

Hope that helps!

Thanks :slight_smile:

Hi, i had same problem, i found a solution that i think can be considered accepted given few options:

i created following blueprint structure:

341025-capture.png

c++ code for above is:

ADrawer::ADrawer() {
	PrimaryActorTick.bCanEverTick = true;

	rootSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("rootSceneComponent"));
	rootSceneComponent->SetupAttachment(RootComponent);

	staticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("staticMeshComponent"));
	staticMeshComponent->SetupAttachment(rootSceneComponent);

	boxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("boxComponent"));
	boxComponent->SetupAttachment(staticMeshComponent);
}

then in BeginPlay function i calculate bounding box volumes ir orden to avoiding doing it manually:

FVector min, , center;
staticMeshComponent->GetLocalBounds(min, );
center =  - min;
boxComponent->SetRelativeLocation(min + center/2);
boxComponent->SetBoxExtent(center/2);

and then finally in Tick function i make following calculation before and after updating object (drawer) location:

location = boxComponent->GetComponentLocation();

// put here code that updates you object location

deltaLocation = location - boxComponent->GetComponentLocation();
TSet<AActor*> set;
boxComponent->GetOverlappingActors(set, AMyCharacter::StaticClass());
if (set.Num() > 0) {
	UE_LOG(LogTemp, Warning, TEXT("set = %d"), set.Num());
	AMyCharacter* character = Cast<AMyCharacter>(set[FSetElementId::FromInteger(0)]);
	character->AddActorWorldOffset(-deltaLocation);
}

Hope it helps…