Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why isn't IsValidBlockingHit() Triggering?

I'll attach relevant code at the bottom of this post, but essentially my pawn isn't reacting to collision at all. It's set up with a camera + boom, a cubic mesh with disabled collision, and a UBoxComponent fitted to the mesh for collision purposes.

The object I want to collide has a custom collision preset known as worldActor, while the other object has preset worldGeometry. Both are set to ignore all collision channels except for each other-- they block one another. I'd look at this setup for a problem if I hadn't already been having the issue before implementing this.

I've tried to test to see if any collision is detected at all, by destroying the pawn on collision or disabling movement, to no avail. Thus, I've determined that I'm missing something concerning IsValidBlockingHit() in my JumperMovement class.

My pawn spawns in the world moving forward and right, diagonally, hence the "xyzSpeed" FVector. Take a look. (If there's any way to make these code blocks collapsible, I'm sorry for being unaware.)


 #pragma once
 #include "CoreMinimal.h"
 #include "Components/BoxComponent.h"
 #include "GameFramework/SpringArmComponent.h"
 #include "Camera/CameraComponent.h"
 #include "GameFramework/Pawn.h"
 #include "JumperMovement.h"
 #include "Jumper.generated.h"
 class PLATFORMER_API AJumper : public APawn
     // Sets default values for this pawn's properties
     UBoxComponent* boundBox;
     UStaticMeshComponent* staticMesh;
     USpringArmComponent* springBoom;
     UCameraComponent* springCamera;
     UJumperMovement* movementComponent;
     FVector xyzSpeed = FVector(10.0f, 10.0f, 0.0f);
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     // Called every frame
     virtual void Tick(float DeltaTime) override;
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;


 #include "Jumper.h"
 #include "Runtime/CoreUObject/Public/CoreUObject.h"
 // Sets default values
      // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
     RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
     RootComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 3.0f));
     boundBox = CreateDefaultSubobject<UBoxComponent>(TEXT("boundBox"));
     boundBox->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
     boundBox->SetWorldScale3D(FVector(1.57f, 1.57f, 1.57f));
     boundBox->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f));
     boundBox->SetCollisionResponseToChannel(ECC_GameTraceChannel2, ECollisionResponse::ECR_Block);
     springBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("springBoom"));
     springBoom->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 80.0f), FRotator(-10.0f, 0.0f, 0.0f));
     springBoom->TargetArmLength = 500.0f;
     springBoom->bEnableCameraLag = true;
     springBoom->bEnableCameraRotationLag = true;
     springBoom->CameraLagSpeed = 5.0f;
     springBoom->CameraRotationLagSpeed = 5.0f;
     springBoom->CameraLagMaxDistance = 0.0f;
     springCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("springCamera"));
     springCamera->SetupAttachment(springBoom, USpringArmComponent::SocketName);
     springCamera->bUsePawnControlRotation = false;
     staticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("staticMesh"));
     staticMesh->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
     static ConstructorHelpers::FObjectFinder<UStaticMesh> cubeTestMesh(TEXT("/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube"));
     if (cubeTestMesh.Succeeded())
     movementComponent = CreateDefaultSubobject<UJumperMovement>(TEXT("UJumperMovement"));
     movementComponent->UpdatedComponent = RootComponent;
     AutoPossessPlayer = EAutoReceiveInput::Player0;
 // Called when the game starts or when spawned
 void AJumper::BeginPlay()
 // Called every frame
 void AJumper::Tick(float DeltaTime)
     movementComponent->speedVector = xyzSpeed;
     /*FVector deltaMove = GetActorLocation();
     deltaMove.X += xSpeed;
     deltaMove.Y += ySpeed;
     deltaMove.Z += zSpeed;
 // Called to bind functionality to input
 void AJumper::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)


 #pragma once
 #include "CoreMinimal.h"
 #include "GameFramework/PawnMovementComponent.h"
 #include "JumperMovement.generated.h"
 class PLATFORMER_API UJumperMovement : public UPawnMovementComponent
         virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
         FVector speedVector = FVector(0.0f, 0.0f, 0.0f);

JumperMovement.cpp // Fill out your copyright notice in the Description page of Project Settings.

 #include "JumperMovement.h"
 void UJumperMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
     FHitResult collideResult(1.f);
     TGuardValue<EMoveComponentFlags> ScopedFlagRestore(MoveComponentFlags, MoveComponentFlags | MOVECOMP_NeverIgnoreBlockingOverlaps);
     if (!collideResult.IsValidBlockingHit())
         SafeMoveUpdatedComponent(speedVector, UpdatedComponent->GetComponentRotation(), true, collideResult);
     else if (collideResult.IsValidBlockingHit())
         HandleImpact(collideResult, DeltaTime, speedVector);
         SlideAlongSurface(speedVector, collideResult.Time - 1, collideResult.Normal, collideResult);
Product Version: UE 4.16
more ▼

asked Aug 08 '17 at 02:22 AM in C++ Programming

avatar image

1 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question