"OnLeftCollision" function?

Hey! I am a developer and coming from Unity, I find it quite odd that I can’t find a certain function, as it seems like a pretty vital component for making a game. “OnLeftCollision” is a function (in Unity) that detects the point when the player is not colliding with anything (meaning he leaves the ground, is in air, and is not colliding with any world objects). Anybody know if there is an equivalent to that in the Unreal Engine API? I would really appreciate if someone could enlighten me, as I have searched forever :stuck_out_tongue: Thank you in advance!

There are delegates available for that - OnBegin(Actor/Component)Overlap and OnEnd(Actor/Component)Overlap. Check documentation to see how to use delegates.
In short: create function with matching signature and bind it to delegate like this:

OnEndComponentOverlap.AddDynamic(this, &AMyCharacterOrAnythingElse::MyFunction)

Character movement component also has function to check if actor is flying(is in air).

I tried “OnEndOverlap”, but that only works when one of the colliding object’s collision mode is actually set to overlap the other (so it doesnt work if they are simply colliding with each other)

If its a Pawn or character you want to know is in the air you can use APawn::IsFalling and APawn::IsWalking

You can call them by using the Pawns MovementComponent.


I dont think people are quite getting what I mean. Let me give an example:

void AFPSCharacter::OnLeftCollision()

Have a look at the AActor:: class AActor::OnActorHit and/ or AActor::OnActorBeginOverlap.
You should be able to use the FHitResult structure and Player/ Actor Location, Rotation to calculate where the hits is coming from and call the apropriate function.

May be a better way for it but its an idea.

Yes, this is a way to get collisions, but how will that help me to know when the player walks off a ledge?



If its true then your in the air.
To be certen you can do.

if (CharacterMovement->IsFalling() && !CharacterMovement->IsOnTheGround() ) // CharacterMovement->IsWalking();
// Player is falling (is in the air) Do somthing...

NB: Am at work so am unable to check if the name of IsOnTheGround() is correct but its somthing like that.
Hope this helps.

Wow I just noticed that a new function was added in 4.2 called “Character::OnWalkingOffLedge()”, which means that I won’t be able to use it (I only have 4.1). Oh well, guess I will stick to CharacterMovement->IsFalling().

Wouldn’t this require me to use “Tick” to see if the player is falling and therefore require plenty of extra cpu power (as it is checking for it every frame)? Please correct me if I am wrong.

Have a look on the events available for the character controller component. There should be an “OnMovementModeChanged” or similar (can’t remember the exact name). That will tell you if you went from walking to falling for instance. If falling is what you’re interested in.

Does falling include when the player jumps (so not actually falling, but just generally in air)?

OnMovementModeChanged is probably what you want, as zoombapup suggested, if you want to detect the transition from one mode to another (falling most likely). The new OnWalkingOffLedge() function is similar, detecting when the walking code changes the mode to falling, but more specific because it excludes things like jumping or forces launching the player in the air.

That’s correct! Unless of course you’ve specifically set the mode to flying :slight_smile:

Well that is actually perfect, thank you very much! Will look into it. :cool: