collision problem with spawned actor

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.


// 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);
}

any ideas?

What is this?


StartRoom->Attiva = true;

Got the feeling that is some typo for Active, though i could be completely wrong ofc.

Another thing i noticed is this: SpawnActor docs
While the function syntax says Location, Rotation, SpawnParameters the example code & your code has another argument infront of those (some class pointer?) you could try without that argument maybe?

No clue if any of these things are relevant

Code:


StartRoom->Attiva=true;

I used this to set the camera inside the Room. And it works.

Ah ok :slight_smile:
How about the SpawnActor syntax?

the syntax is correct, all the components are generated correctly. The boxes (the walls of the room) block the player. the triggerbox (teleports to the other rooms) work. the only thing that does not work is the movement of the player who seems to not collide with the floor.

ah, in the Project setting I set the values ​​of gravity to 0. but if set values ​​to -0.01, the PlayerStart to 50 in the Z axis. and expect the player to fall to the floor, after that the player will move properly in the room.