Why two trigger volume doesn't work?

Good evening,

I’m trying to use the Volume Trigger twice to open the door the green one (created in the course) works perfectly instead the red one doesn’t. I tried to use UE_LOG to print the actor name but nothing unfortunately.
Header:

float MassaTotaleInAproPortaVerde() const; //green door
float MassaTotaleInAproPortaRossa() const; //red door
//other code
UPROPERTY(EditAnywhere)
ATriggerVolume* Pedana;

UPROPERTY(EditAnywhere)
ATriggerVolume* PedanaRossa;

CPP

if(MassaTotaleInAproPortaVerde() > QuantoPesoAproPorta && QuantoPesoAproPorta < MassaTotaleInAproPortaRossa() )
	{
		AproPorta(DeltaTime);
		ContatoreUltimaChiusura = GetWorld()->GetTimeSeconds();
	}
//othercode
float UAproPorta::MassaTotaleInAproPortaVerde() const
{
	float MassaTotale = 0.f;

	//Trovare cosa è dentro
	TArray<AActor*> VerdiActor;
	Pedana->GetOverlappingActors(OUT VerdiActor);

	//Aggiungere le masse dei attori
	for (AActor* AttoreVerde : VerdiActor)
	{
		UE_LOG(LogTemp, Warning, TEXT("%s"), *AttoreVerde->GetName());
		if (AttoreVerde->GetName() == "pallina-verde")
		{
			MassaTotale += AttoreVerde->FindComponentByClass<UPrimitiveComponent>()->GetMass();
		}
	}
	return MassaTotale;
}

float UAproPorta::MassaTotaleInAproPortaRossa() const
{
	float MassaTotaleRossa = 0.f;

	//Trovare cosa è dentro
	TArray<AActor*> RossaActor;
	PedanaRossa->GetOverlappingActors(OUT RossaActor);
	//Aggiungere le masse dei attori
	for (AActor* AttoreRosso : RossaActor)
	{
		UE_LOG(LogTemp, Warning, TEXT("%s"), *AttoreRosso->GetName());
		if (AttoreRosso->GetName() == "pallina-rossa")
		{
			MassaTotaleRossa += AttoreRosso->FindComponentByClass<UPrimitiveComponent>()->GetMass();
		}
	}
	return MassaTotaleRossa;
}

Image :

Are you successfully compiling? What is the note about line 137?

I confirm, it compiles and everything works correctly except that trigger. now i’m at work after i look at the line you wrote

i try to deactive green and see result and red work. seems like just one trigger volume can work in the scene :scream:

EDIT:
i find the problem now don’t work if i try to catch name of actor, for example if name is equal to green add mass else not…


Solution:

Finally find a solution, instead of use name i use Tags like:

for (AActor* AttoreRosso : RossaActor)
	{
		if (AttoreRosso->ActorHasTag("pallinarossa")) //if ball have red tag
		{
			MassaTotaleRossa += AttoreRosso->FindComponentByClass<UPrimitiveComponent>()->GetMass();
		}
	}

and in the actor i added tag name

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

Privacy & Terms