hi guys!
premise, I’m developing a game 2d top down. I created a class called room. If the editor drag and drop my class in the level, everything works fine. But if I create the class at run time, it does not collide in right way with the player.
I checked all the preset collision and are setup in the same way into both cases.
sry for my bad english
edit: in the class there are some invisible boxcomponents that serve as walls of the room. These work perfectly. The problem is with the player’s movements. After the player receives a movements input, it will not stop, as if he could not collide with the floor of the room.
Spawner code:
// Fill out your copyright notice in the Description page of Project Settings.
#include "HeoressDoodle.h"
#include "LevelGenerator.h"
// Sets default values
ALevelGenerator::ALevelGenerator()
{
// 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 ALevelGenerator::BeginPlay()
{
Super::BeginPlay();
SpawnStartRoom();
}
// Called every frame
void ALevelGenerator::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
void ALevelGenerator::SpawnStartRoom()
{
UE_LOG(LogTemp, Error, TEXT("SpawnStartRoom--->STARTED "));
UWorld * World = GetWorld();
if (World)
{
StartRoom = World->SpawnActor<ARoom>(ARoom::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator);
if (StartRoom)
{
UE_LOG(LogTemp, Warning, TEXT("StartRoom --->IMPOSTATA "));
UE_LOG(LogTemp, Warning, TEXT("nome StartRoom : %s"), *StartRoom->GetName());
}
else
{
UE_LOG(LogTemp, Warning, TEXT("StartRoom --->FALLITA "));
}
}
StartRoom->Attiva = true;
StartRoom->SetActorEnableCollision(true);
}