Surface Orientation




Last updated




Last updated
// ZCCharacterMovementComponent.h
public:
//...
UFUNCTION(BlueprintPure)
FVector GetClimbSurfaceNormal() const { return CurrentClimbingNormal; }// ZCClimbingCharacter.cpp
void AZCClimbingCharacter::Move(const FInputActionValue& Value)
{
// input is a Vector2D
FVector2D MovementVector = Value.Get<FVector2D>();
if (Controller != nullptr)
{
// Our climbing code
if (MovementComponent && MovementComponent->IsClimbing())
{
FVector SurfaceUpDirection = FVector::CrossProduct(GetActorRightVector(), MovementComponent->GetClimbSurfaceNormal());
FVector SurfaceRightDirection = FVector::CrossProduct(MovementComponent->GetClimbSurfaceNormal(), GetActorUpVector());
AddMovementInput(SurfaceUpDirection, MovementVector.Y);
AddMovementInput(SurfaceRightDirection, MovementVector.X);
}
else
{
// existing logic
// ...
}
}
}