Make Games in UE5 with C++: Collision Detection

here is an odd one. following the lesson, and the instructor suggests doing a clean then a build. as soon as I do the clean I get errors like crazy. see photo. it no longer builds at all. I checked task manager but unreal isn’t running. it seems to not be able to find the source file for the build? how do I fix this?

In the tools menu of the Unreal Editor, there’s a refresh project option. Select that and it should help resolve the errors. You may need to restart the code editor after.

unfortunately, when trying to open the uproject for desertracer I get a prompt that it was built in a different version (weird. see picture). I click yes to rebuild and it fails and tells me to build from source.
unrealprojecterror

if I click no and try and built it tells me the module DesertRacer can not be found and then doesn’t open.

Ok, right click on the uproject and select generate visual studio files. Open the project and build there. See what it says.

1 Like

this got me back in the ballpark. I was able to get the visual studio files generated again. found out I had a typo that was causing errors as well!

once again, you’re a lifesaver!

1 Like

Just glad to be in the right place at the right time. Good luck!

1 Like

sorry to bother you again. so I have my VS and Unreal up and running again. it is time to test everything out, and when I hit play and take control I do not get any text displayed to the screen, nor does my car stop moving. here is my code for the Obstacle.cpp:


#include "Obstacle.h"
#include "PlayerCharacter.h"

// Sets default values
AObstacle::AObstacle()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleComp"));
	SetRootComponent(CapsuleComp);

	ObstacleSprite = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("ObstacleSprite"));
	ObstacleSprite->SetupAttachment(CapsuleComp);

}

// Called when the game starts or when spawned
void AObstacle::BeginPlay()
{
	Super::BeginPlay();

	CapsuleComp->OnComponentBeginOverlap.AddDynamic(this, &AObstacle::OverlapBegin);
	
}

// Called every frame
void AObstacle::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void AObstacle::OverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult)
{
	APlayerCharacter* Player = Cast<APlayerCharacter>(OtherActor);
	if (Player)
	{
		GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::White, TEXT("OVerlapped with player"));
		if (Player->CanMove)
		{
			Player->CanMove = false;
		}
	}
}

I also double checked my blueprints for both the tire and the fence, and they are set up how the instructor sets them up: correct sprite texture with NoCollision, correct material with SortPriority, match and line up the capsule component, collision on capsule component is set to OverlapAllDynamic. I checked the player blueprint as well, those settings match that video.

I tried a clean and rebuild in VS. opened Unreal back up and hit play, still no message or stop in movement. Did I type something wrong or is Unreal not “seeing” this code somehow?

Did something change in 5.4 compared to 5.3?

EDIT:: I have a feeling it has something to do with the capsulecomp but everything seems correct.

Check out the y axis of the obstacle. I suspect it isn’t 0

Also check the collision properties.

I’m also go a direct you to project settings. If you scroll down, there’s a 2d settings section and some options. One is enable a feature where you can automatically set the y on an item based on presets. I don’t have access to it at the moment. I only found this myself yesterday.

There’s another one too that enables a combined move and rotate widget for 2d.less useful but still.

1 Like

I just checked both the tire and the fence, it all seems correct? here is what I see:


tireproperties2

the player blueprint seems correct as well, with a Y-Axis of 0.

EDIT:: You were right! So when I dropped the Blueprints into the viewport, it assigned them a weird Y-Axis value, like -32000. That makes NO sense to me, because they looked fine in the viewport and when I clicked play. When I changed them to 0, it worked! I said it before, and I’ll say it again, you’re the best! I’ve been searching all day and finding forum post after forum post about the Overlap function not working, but no one suggested checking the Axis. The most common issue was people forgetting UFUNCTION()

1 Like

Yeah, I hate that. You can use the tool I mentioned to quick set assets to the correct y depth.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms