Hey! I am trying to create a script to allow me to check if the surface that the player has collided with is a wall, so that they can wall jump. Here is what I thought about doing:
//Get Collision Info
void AFPSCharacter::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if (Hit.Rotation > wJumpSteepness && CharacterMovement->IsMovingOnGround())
{
canWallJump = true;
}
}
With Hit.Rotation replacing the steepness of the surface. Is this possible? If someone could help me with this, it would be much appreciated! Thank you in advance.
Rama
(Rama)
May 27, 2014, 1:55am
2
#ImpactNormal
What you want is
Hit.ImpactNormal
This is the Vector representing the facing direction of the surface at the point of impact, in world space
to get this as a rotation:
const FRotator SurfaceRotation = Hit.ImpactNormal.Rotation();
Just know this is in world space and you can decide what qualifies as a sufficient angle for wall jumping
for example
if you wanted all walls to be at elast 70 degrees from the flat ground plan (almost totally vertical)
you would do
const FRotator SurfaceRotation = Hit.ImpactNormal.Rotation();
if(FMath::Abs(SurfaceRotation.Pitch) > 70)
{
//yes this is a wall jump
}
to make sure you are getting the numbers you expect
make sure to LOG or output this value so you can see it exactly
const FRotator SurfaceRotation = Hit.ImpactNormal.Rotation();
#Log / To Screen Wiki
After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
Reading time: 1 mins 🕑
Likes: 14 ❤
Thank you very much (this is somewhat how it works in Unity as well)!