Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================== MyPawn.cpp ===============================//
- // Fill out your copyright notice in the Description page of Project Settings.
- #include "Pawn/MyPawn.h"
- #include "Components/CapsuleComponent.h"
- #include "Components/SkeletalMeshComponent.h"
- #include "Components/InputComponent.h"
- #include "EnhancedInputSubsystems.h"
- #include "EnhancedInputComponent.h"
- // Sets default values
- AMyPawn::AMyPawn()
- {
- // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
- PrimaryActorTick.bCanEverTick = true;
- }
- // Called when the game starts or when spawned
- void AMyPawn::BeginPlay()
- {
- Super::BeginPlay();
- }
- void ABird::Move(const FInputActionValue& Value)
- {
- /*
- const float DirectionValue = Value.Get<float>();
- if (Controller && (DirectionValue != 0.f))
- {
- FVector Forward = GetActorForwardVector();
- AddMovementInput(Forward, DirectionValue);
- //UE_LOG(LogTemp, Warning, TEXT("Weapon.cpp: OtherActor Name: %s"), *BoxHit.GetActor()->GetName());
- ///UE_LOG(LogTemp, Warning, TEXT("IA_Move: %s"), *Forward.ToString());
- //UE_LOG(LogTemp, Warning, TEXT("IA_Move: %f"), DirectionValue);
- }
- */
- APawn* Pawn = GetPawn<APawn>();
- const AController* Controller = Pawn ? Pawn->GetController() : nullptr;
- if (Controller)
- {
- const FVector2D Value = InputActionValue.Get<FVector2D>();
- const FRotator MovementRotation(0.0f, Controller->GetControlRotation().Yaw, 0.0f);
- if (Value.X != 0.0f)
- {
- const FVector MovementDirection = MovementRotation.RotateVector(FVector::RightVector);
- Pawn->AddMovementInput(MovementDirection, Value.X);
- }
- if (Value.Y != 0.0f)
- {
- const FVector MovementDirection = MovementRotation.RotateVector(FVector::ForwardVector);
- Pawn->AddMovementInput(MovementDirection, Value.Y);
- }
- }
- }
- // Called every frame
- void AMyPawn::Tick(float DeltaTime)
- {
- Super::Tick(DeltaTime);
- }
- // Called to bind functionality to input
- void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
- {
- Super::SetupPlayerInputComponent(PlayerInputComponent);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement