Hello everyone! I am making a multiplayer game and at the moment I am making the ability to move on the ceiling for AI by moving only the mesh, the problem is that it only works on the server and nothing happens at all on the client
.cpp
#include "Task_GoToCeiling.h"
#include "BTAIController.h"
#include "ZombieEnemyCPP.h"
#include "Net/UnrealNetwork.h"
#include "LineTrace.h"
#include "Kismet/GameplayStatics.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "DrawDebugHelpers.h"
#include "Components/TimelineComponent.h"
#include "Kismet/BlueprintFunctionLibrary.h"
EBTNodeResult::Type UTask_GoToCeiling::
ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
ZombieActorChar = OwnerComp.GetAIOwner()->GetCharacter();
FVector StartCapsule = ZombieActorChar->GetCapsuleComponent()->GetComponentLocation();
FVector EndCapsule = StartCapsule + ZombieActorChar->GetCapsuleComponent()->GetUpVector() * 400.0f;
FCollisionObjectQueryParams CollisionParams;
FCollisionQueryParams CollisionQueryParams;
CollisionQueryParams.AddIgnoredActor(ZombieActorChar);
ZombieActorChar->GetWorld()->LineTraceSingleByObjectType(OUT HitResult,
StartCapsule,
EndCapsule,
CollisionParams,
CollisionQueryParams);
UE_LOG(LogTemp, Warning, TEXT("wtf"));
DrawDebugLine(
GetWorld(),
StartCapsule,
EndCapsule,
FColor::Red,
false,
3.0f,
0,
5.0f
);
if (HitResult.bBlockingHit && HitResult.GetComponent()->ComponentHasTag("Ceiling"))
{
UE_LOG(LogTemp, Warning, TEXT("HELLO"));
FRotator CeilingRotation = (FRotator(180.0f, -90.0f, ZombieActorChar->GetControlRotation().Yaw));
ZombieActorChar->GetMesh()->K2_SetWorldLocationAndRotation(HitResult.Location,
CeilingRotation, true, HitResult, true);
/*CeilingTimeLine();*/
OwnerComp.GetBlackboardComponent()
->SetValueAsBool(FName("OnTheCeiling"), true);
UE_LOG(LogTemp, Warning, TEXT("HAVE CEILING"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("FAIL"));
return EBTNodeResult::Failed;
}
UE_LOG(LogTemp, Warning, TEXT("Success"));
return EBTNodeResult::Succeeded;
}
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "Task_GoToCeiling.generated.h"
/**
*
*/
UCLASS()
class FIRSTGAME_API UTask_GoToCeiling : public UBTTaskNode
{
GENERATED_BODY()
private:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp,
uint8* NodeMemory) override;
public:
FHitResult HitResult;
class ULineTrace* LineTrace;
class AZombieEnemyCPP* Zombie;
ACharacter* ZombieActorChar;
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void CeilingTimeLine();
};