Collison with pillar not working

when i add the BP_MovingPlatform class to my level scene i just walk right through it when i approach the pillar . I dont understand why this is happening . I actually got further along in this project but when i reopened UE5 i couldnt walk or interact with the platform. attached is my code below

MovingPlatform.h

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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MovingPlatform.generated.h"

UCLASS()
class OBSTACLEASSAULT_API AMovingPlatform : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMovingPlatform();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

private:

	UPROPERTY(EditAnywhere, Category="Moving Platform")
	FVector PlatformVelocity = FVector(100,0,0);
	UPROPERTY (EditAnywhere, Category="Moving Platform")
	float MoveDistance = 100;
	UPROPERTY(EditAnywhere, Category="Rotation")
	FRotator RotationVelocity;
	

	FVector StartLocation;

	void MovePlatform(float DeltaTime);
	void RotatePlatform(float DeltaTime);

	bool ShouldPlatformReturn() const;
	float GetDistanceMoved() const;
};

MovingPlatform.cpp

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


#include "MovingPlatform.h"

// Sets default values
AMovingPlatform::AMovingPlatform()
{
 	// 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;

}

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

StartLocation = GetActorLocation();



}

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

	MovePlatform(DeltaTime);
	RotatePlatform(DeltaTime);
	
}

void AMovingPlatform::MovePlatform(float DeltaTime)
{
	
		// reverse direction of motion if gone to far 
	if (ShouldPlatformReturn())
	{
		FVector MoveDirection = PlatformVelocity.GetSafeNormal();
	 	StartLocation = StartLocation + MoveDirection * MoveDistance;
		SetActorLocation(StartLocation);
		PlatformVelocity = -PlatformVelocity;
	}
	else
	{
		//move platform forwards
		// get current location
	FVector CurrentLocation = GetActorLocation();
		// add vector to location
	CurrentLocation = CurrentLocation + (PlatformVelocity * DeltaTime);
		// set the location 
	SetActorLocation(CurrentLocation);
	// Send platform back if gone to far
		
	}
}

void AMovingPlatform::RotatePlatform(float Deltatime)
{
FRotator CurrentRotation =GetActorRotation();
CurrentRotation = CurrentRotation + RotationVelocity *Deltatime;
SetActorRotation(CurrentRotation);
}

bool AMovingPlatform::ShouldPlatformReturn() const
{
// check how far we moved
  return GetDistanceMoved() > MoveDistance;
}

float AMovingPlatform::GetDistanceMoved() const
{
	return FVector::Dist(StartLocation, GetActorLocation());
}

So you can always walk through it? In the top left of the viewport could you change the visibility of your viewport from “Lit” to “Player Collision” and show that?

I checked and the collision around the BP_Moving Platform is completely destroyed it wasnt like this when i reopened Unreal Engine 5 is that a bug ?

If you open the mesh for the platform inside Unreal, you should be able to check the collision to ensure it is there. Have a look and see what is there. You may need to add collision.

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

Privacy & Terms