Полезное

Мы Вконтакте

Discord канал

#
Аватара пользователя
Пользователь
Сообщения: 11
Персонаж не поворачивается с помощью мышки по оси pitch(горизонтально).С осью Yaw(вертикально) все нормально(код писал по книге "Изучение C++ создавая игры в UE4").Вот код Avatar.h -
Код:
#include "GameFramework/Character.h"
#include "Avatar.generated.h"

UCLASS()
class GOLDENEGG_API AAvatar : public ACharacter
{
   GENERATED_BODY()
   void MoveForward(float amount);
   void MoveRight(float amount);
   void Yaw(float amount);
   void Pitch(float amount);
   

public:
   // Sets default values for this character's properties
   AAvatar();

   // Called when the game starts or when spawned
   virtual void BeginPlay() override;
   
   // Called every frame
   virtual void Tick( float DeltaSeconds ) override;

   // Called to bind functionality to input
   virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

   
   
};


Код Avatar.cpp -
Код:
// Called every frame
void AAvatar::Tick( float DeltaTime )
{
   Super::Tick( DeltaTime );

}

// Called to bind functionality to input
void AAvatar::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
   Super::SetupPlayerInputComponent(InputComponent);
   check(InputComponent);
   InputComponent->BindAxis("Strafe", this, &AAvatar::MoveRight);
   InputComponent->BindAxis("Forward", this, &AAvatar::MoveForward);
   InputComponent->BindAxis("Yaw", this, &AAvatar::Yaw);
   InputComponent->BindAxis("Pitch", this, &AAvatar::Pitch);
}
void AAvatar::MoveForward(float amount)
{
   if (Controller && amount)
   {
      AddMovementInput(GetActorForwardVector(), amount);
   }
}
void AAvatar::MoveRight(float amount)
{
   if (Controller && amount)
   {
      AddMovementInput(GetActorRightVector(), amount);
   }
}
void AAvatar::Yaw(float amount)
{
   AddControllerYawInput(200.f* amount * GetWorld()->GetDeltaSeconds());
}
void AAvatar::Pitch(float amount)
{
   AddControllerPitchInput(200.f* amount * GetWorld()->GetDeltaSeconds());
}


Что мне делать???
Аватара пользователя
Пользователь
Сообщения: 195
так ты её вроде как и не повернёшь. персонаж всегда стоит вертикально, там вроде ось Pitch и Roll заблокированы. Если ты повернёшь, то персонаж будет по кривому ходить и двигаться.. Но если очень надо, то думаю повернуть можно. Попробуй капсулу повернуть или контроллеру вставить поворот руками SetControllerRotation
Аватара пользователя
Пользователь
Сообщения: 11
Я про поворот камеры.


Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 7

UEngine.ru © 2017
Все права защищены. При копировании материалов с сайта, ссылка на первоисточник обязательна.
Яндекс.Метрика
Главная страница