diff --git a/Content/Blueprints/Player/BP_ExoPlayerController.uasset b/Content/Blueprints/Player/BP_ExoPlayerController.uasset index 2eff983..8f8b2b7 100644 Binary files a/Content/Blueprints/Player/BP_ExoPlayerController.uasset and b/Content/Blueprints/Player/BP_ExoPlayerController.uasset differ diff --git a/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset b/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset index 38e02d4..c1aa112 100644 Binary files a/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset and b/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset differ diff --git a/Content/Blueprints/Player/Inputs/Inputs/AI_Interact.uasset b/Content/Blueprints/Player/Inputs/Inputs/AI_Interact.uasset new file mode 100644 index 0000000..881ecc8 Binary files /dev/null and b/Content/Blueprints/Player/Inputs/Inputs/AI_Interact.uasset differ diff --git a/Content/Blueprints/Player/Inputs/Inputs/AI_Interaction.uasset b/Content/Blueprints/Player/Inputs/Inputs/AI_Interaction.uasset deleted file mode 100644 index cfe4698..0000000 Binary files a/Content/Blueprints/Player/Inputs/Inputs/AI_Interaction.uasset and /dev/null differ diff --git a/Exo.uproject b/Exo.uproject index b28ec77..43682e8 100644 --- a/Exo.uproject +++ b/Exo.uproject @@ -20,6 +20,14 @@ "TargetAllowList": [ "Editor" ] + }, + { + "Name": "Omniverse", + "Enabled": false + }, + { + "Name": "MDL", + "Enabled": false } ] } \ No newline at end of file diff --git a/Source/Exo/Private/Player/ExoPlayerController.cpp b/Source/Exo/Private/Player/ExoPlayerController.cpp index e8a157a..21ec5d8 100644 --- a/Source/Exo/Private/Player/ExoPlayerController.cpp +++ b/Source/Exo/Private/Player/ExoPlayerController.cpp @@ -24,6 +24,8 @@ void AExoPlayerController::BeginPlay() } PlayerCharacter = GetPawn(); + + InteractionComponent = PlayerCharacter->FindComponentByClass(); } void AExoPlayerController::PlayerTick(float DeltaTime) @@ -39,6 +41,7 @@ void AExoPlayerController::SetupInputComponent() EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Move); EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Look); + EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Interact); } void AExoPlayerController::Move(const FInputActionValue& InputActionValue) @@ -64,3 +67,10 @@ void AExoPlayerController::Look(const FInputActionValue& InputActionValue) AddYawInput(InputAxisVector.X); AddPitchInput(InputAxisVector.Y); } + + +void AExoPlayerController::Interact(const FInputActionValue& InputActionValue) +{ + if (InteractionComponent->InteractedActor) + IInteractable::Execute_Interact(InteractionComponent->InteractedActor); +} diff --git a/Source/Exo/Private/Player/InteractionComponent.cpp b/Source/Exo/Private/Player/InteractionComponent.cpp index d154705..2344ce4 100644 --- a/Source/Exo/Private/Player/InteractionComponent.cpp +++ b/Source/Exo/Private/Player/InteractionComponent.cpp @@ -26,12 +26,13 @@ void UInteractionComponent::CheckForInteractable() bool bHit = GetWorld()->LineTraceSingleByChannel(HitResult, LineStart, LineEnd, ECC_Visibility, QueryParams); - if (bHit && HitResult.GetActor()) + if (bHit && HitResult.GetActor() && HitResult.GetActor()->Implements()) { - if (HitResult.GetActor()->Implements()) - { - IInteractable::Execute_Interact(HitResult.GetActor()); - } + InteractedActor = HitResult.GetActor(); + } + else + { + InteractedActor = nullptr; } if (bShowDebugLine) diff --git a/Source/Exo/Public/Player/ExoPlayerController.h b/Source/Exo/Public/Player/ExoPlayerController.h index 71e8d84..6085b1e 100644 --- a/Source/Exo/Public/Player/ExoPlayerController.h +++ b/Source/Exo/Public/Player/ExoPlayerController.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "GameFramework/PlayerController.h" +#include #include "ExoPlayerController.generated.h" class UInputMappingContext; @@ -31,6 +32,9 @@ protected: UFUNCTION(BlueprintCallable, Category = "Input") void Look(const FInputActionValue& InputActionValue); + UFUNCTION(BlueprintCallable, Category = "Input") + void Interact(const FInputActionValue& InputActionValue); + protected: UPROPERTY(EditAnywhere, Category = "Input") TObjectPtr InputContext; @@ -41,6 +45,12 @@ protected: UPROPERTY(EditAnywhere, Category = "Input") TObjectPtr LookAction; + UPROPERTY(EditAnywhere, Category = "Input") + TObjectPtr InteractAction; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character") TObjectPtr PlayerCharacter; + +private: + UInteractionComponent* InteractionComponent; }; diff --git a/Source/Exo/Public/Player/InteractionComponent.h b/Source/Exo/Public/Player/InteractionComponent.h index 06c8ec2..a8b7a07 100644 --- a/Source/Exo/Public/Player/InteractionComponent.h +++ b/Source/Exo/Public/Player/InteractionComponent.h @@ -21,6 +21,8 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Debug") bool bShowDebugLine = false; + AActor *InteractedActor = nullptr; + protected: // Called when the game starts virtual void BeginPlay() override;