Doo not Opening by the blueprint assigned angle , its opening by the c++ previous angle ?!

I’m trying to open the door by the assigned angle on blue print but it keep opens the door by the open angle on the c++ which i assigned it as 90 , whne im trying to change the angle on the blueprint Z: Value to for example -20 , I step on the pressure plate it opens the door with a 90 degree help please !!

here open_door.cpp

// Crying Bullet copyright 2017

#include “Grabber.h”
#include “Gameframework/Actor.h”

#define OUT

// Sets default values for this component’s properties
UGrabber::UGrabber()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don’t need them.
PrimaryComponentTick.bCanEverTick = true;

// ...

}

// Called when the game starts
void UGrabber::BeginPlay()
{
Super::BeginPlay();
FindPhysicsHandleComponent();
SetupInputComponent();
UE_LOG(LogTemp, Warning, TEXT(“Grabber Reporting for duty”));
}

/// look for attcahed physics handle
void UGrabber::FindPhysicsHandleComponent()
{
PhysicsHandle = GetOwner()->FindComponentByClass();
if (PhysicsHandle == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("%s missing Physics Handle component "), *GetOwner()->GetName())
}
}

/// look for attcahed inputComponent
void UGrabber::SetupInputComponent()
{
InputComponent = GetOwner()->FindComponentByClass();
if (InputComponent)
{
//Bind the Input action
InputComponent->BindAction(“Grab”, IE_Pressed, this, &UGrabber::Grab);
InputComponent->BindAction(“Grab”, IE_Released, this, &UGrabber::Release);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("missing Input Component "), *GetOwner()->GetName())
}
}

// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

if (! PhysicsHandle)
{
	return;
}
   //if the physics handle is attached
if (PhysicsHandle->GrabbedComponent)
{
	//move the object that we're holding
	PhysicsHandle->SetTargetLocation(GetReachLineEnd());  
}

}

void UGrabber::Grab()
{
/// LINE TRACE and see if we reach any actors with physics body collision channel set
auto HitResult = GetFirstPhysicsBodyInReach();
auto ComponentToGrab = HitResult.GetComponent();
auto ActorHit = HitResult.GetActor();
/// if we hit something then attach a physics handle
if (ActorHit)
{
if (!PhysicsHandle)
{
return;
}
PhysicsHandle->GrabComponent
(
ComponentToGrab,
NAME_None, //no-bones needed
ComponentToGrab->GetOwner()->GetActorLocation(),
true //allow rotation (allow to spin around)
);
}
}
void UGrabber::Release()
{
if (!PhysicsHandle)
{
return;
}
PhysicsHandle->ReleaseComponent();
}

const FHitResult UGrabber::GetFirstPhysicsBodyInReach()
{
///setup Query Parameters
///ray-cast out to reach distance
FCollisionQueryParams TraceParameters(FName(TEXT("")), false, GetOwner());
FHitResult HitResult;
GetWorld()->LineTraceSingleByObjectType
(
OUT HitResult,
GetReachLineStart(),
GetReachLineEnd(),
FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
TraceParameters
);
return HitResult;
}

FVector UGrabber::GetReachLineEnd()
{
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint
(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation
);

/// TODO logout for test

return PlayerViewPointLocation + (PlayerViewPointRotation.Vector()*Reach);

}

FVector UGrabber::GetReachLineStart()
{
	FVector PlayerViewPointLocation;
	FRotator PlayerViewPointRotation;
	GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint
	(
		OUT PlayerViewPointLocation,
		OUT PlayerViewPointRotation
	);
	return PlayerViewPointLocation;

}

and open_door.h

// Crying Bullet copyright 2017

#pragma once

#include “Engine.h”
#include “Components/ActorComponent.h”
#include “Open_Door.generated.h”

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnOpenRequest);

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class ESCAPE_THEROOM_API UOpen_Door : public UActorComponent
{
GENERATED_BODY()

public:
// Sets default values for this component’s properties
UOpen_Door();

UPROPERTY(BlueprintAssignable)
	FOnOpenRequest OnOpenRequest;

protected:
// Called when the game starts
virtual void BeginPlay() override;

void OpenDoor();
void CloseDoor();

public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

private:

UPROPERTY(EditAnywhere)
	float OpenAngle = 90.0f;
UPROPERTY(EditAnywhere)
	ATriggerVolume* PressurePlate; 
UPROPERTY(EditAnywhere)
	float DoorCloseDelay = 1.0f;
	float LastDoorOpenTime;
//returns total mass in KG 
float GetTotalMassOfActorOnPlate();
	AActor* Owner= nullptr;

};

its opening the door with the 60 degree angle not the -50 degree i assigned in the blueprint !! Help please

You posted your grabber.cpp file, not your open_door.cpp. If you still need help, try posting the correct file so someone can take a look!

hi. I’m having a different issue. when I try to declare the firs line after includes an error comes up that says: this declaration has no storage class or type specifier.
I have compiled the game but it didn’t work. and the GENERATED_BODY() is starting to crash.

Privacy & Terms