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


// 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"

class OBSTACLEASSAULT_API AMovingPlatform : public AActor
	// Sets default values for this actor's properties

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

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


	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;


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

#include "MovingPlatform.h"

// Sets default values
 	// 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()

StartLocation = GetActorLocation();


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


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

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

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