The cell won't go up


I connected the blue print like this.

But when I run the game, the Cell has to go up, but it doesn’t go up.

Why isn’t it going up?

Do you get any errors or such in the output log? What value do you have for the offset?

image
The z is 440

FVector TargetLocation = OriginalLocation;	
	if (ShouldMove)
	{
		TargetLocation = OriginalLocation + MoveOffset;	
		
	}
	FVector CurrentLocation = GetOwner()->GetActorLocation();
	float Speed = MoveOffset.Length() / MoveTime; 


	FVector NewLocation = FMath::VInterpConstantTo(CurrentLocation, TargetLocation, DeltaTime, Speed);	
	GetOwner()->SetActorLocation(NewLocation);	

I wrote the code like this.

Have you tried adding logs to see where it’s going wrong?

The log comes out like this.

LogTemp: Warning: BeginPlay
LogEnhancedInput: Warning: Called AddMappingContext with a null Mapping Context! No changes have been applied.
PIE: 서버가 로그인했습니다.
PIE: 에디터에서 플레이 총 시작 시간 0.91초입니다.
LogSlate: Took 0.022556 seconds to synchronously load lazily loaded font ‘…/…/…/Engine/Content/Slate/Fonts/Roboto-Light.ttf’ (167K)
LogWorldSubsystemInput: UEnhancedInputDeveloperSettings::bEnableWorldSubsystem is false, the world subsystem will not be created!
LogWorldSubsystemInput: UEnhancedInputDeveloperSettings::bEnableWorldSubsystem is false, the world subsystem will not be created!
LogWorldSubsystemInput: UEnhancedInputDeveloperSettings::bEnableWorldSubsystem is false, the world subsystem will not be created!

void UMover::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);


	FVector TargetLocation = OriginalLocation;	
	if (ShouldMove)
	{
		TargetLocation = OriginalLocation + MoveOffset;	
		UE_LOG(LogTemp, Error, TEXT("Move"));
	}
	FVector CurrentLocation = GetOwner()->GetActorLocation();
	float Speed = MoveOffset.Length() / MoveTime; 


	FVector NewLocation = FMath::VInterpConstantTo(CurrentLocation, TargetLocation, DeltaTime, Speed);
	GetOwner()->SetActorLocation(NewLocation);
}

So you aren’t getting that log when you expect to? When ShouldMove should be true?

Yes, I didn’t receive the log.

I don’t know if the opening of the cell is related to the code sent above, but I sent the one that seems as relevant as possible.

void UTriggerComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	AActor* Actor = GetAcceptableActor();
	if (Actor != nullptr)	// 가고일이 영역 안에 있으면 트리거 컴포넌트와 무버가 잠금 해제
	{
		// UprimitiveComponent라면 해당 컴포넌트의 포인터를 리턴, 아니라면 널 포인터 리턴
		UPrimitiveComponent* Component = Cast <UPrimitiveComponent>(Actor->GetRootComponent());	// 액터의 루트 컴포넌트 가져옴
		if (Component != nullptr)
		{
			// 물리 시뮬레이션 비활성화
			Component->SetSimulatePhysics(false);
		}
		Actor->AttachToComponent(this, FAttachmentTransformRules::KeepWorldTransform);
		Mover->SetShouldMove(true);
	}
	else// 가고일을 꺼내면 무버가 다시 잠금
	{
		Mover->SetShouldMove(false);
	}
}

This code is true once you pick up the gargoyle and leave it at the door. You pick up the gargoyle and leave it at the door, and you get a log. But


The cell in this picture doesn’t get a log. Is it a different code in the first place?

I don’t know if I explained it correctly…

Is this part being reached? (add a log before it)

While watching the lecture again, I checked if there was anything I missed.
image
I didn’t enter this part .After entering the input, Cell was uploaded.
Fortunately, it was output.

Why do I enter the tag name in Trigger Component?

I’m not quite sure what you mean by this.

Because that’s what your checking for it to know whether or not the statue is in the trigger and if it should move.

Relevant code:

I typed “Unlock2” into the tag and it went up. I forgot and couldn’t write “Unlock2” :sweat_smile:

AActor* UTriggerComponent::GetAcceptableActor() const
{
	TArray<AActor*> Actors;
	GetOverlappingActors(Actors);
for (AActor* Actor : Actors)
	{
		bool HasAcceptableTag = Actor->ActorHasTag(ActorTagName);
		bool IsGrabbed = Actor->ActorHasTag("Grabbed");
		if (HasAcceptableTag && !IsGrabbed)
		{
			return Actor;
		}	
	}
	return nullptr;	
}

This might seem a little silly question. When I go through ISGrabbed, I return the actor with the Grabbed tag added.

But I don’t know why I need HasAcceptableTag. Can’t I just return it if the “Grabbed” tag is added? Why are you adding “Unlock1” and “Unlock2” to the tag?

The condition is if it is not grabbed. So it doesn’t move whilst the statue is in the trigger whilst you’re still holding it.

So it only moves when the correct actor is in the trigger (the one with the matching tag). The point of this is for them to act as keys and so not any old key would do.

Then the reason for attaching Unlock is that there is an object that has a trigger component.
You mean the door opens when you check if the statue has the same tag as the object?

The statue is a tag added by Physics, and the tag of the object with the Trigger component is ActorTagName.
Are you saying that if these two tags are the same, they move?

ActorHasTag (ActorTagName) This code then checks if the statue has ActorTagName, right?

The actor has the same tag as the trigger component’s ActorTagName. You can easily test this by putting different actors into the trigger.

You’re probably talking about the “Grabbed” tag here, that’s only for preventing it being acceptable if it’s being held. The actor tag was added in the details tab before you started playing.

The value of ActorTagName and not literally “ActorTagName”. You can also easily test this and this

Thank you! :blush:

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

Privacy & Terms