Hi,
I am trying to move the Pawn programatically. I have subclassed a SpectatorPawn like this:
And in the implementation file I have this:
Now regardless if I am using 'AddMovementImput' or just 'MoveForward' the Pawn is not moving.
What I am trying to achieve is the Pawn should accelerate constantly in forward direction unless he will hit some obstacle. This code should prove that I can move the pawn programatically but obviously it is not happening. Any help?
I am trying to move the Pawn programatically. I have subclassed a SpectatorPawn like this:
Code:
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #pragma once #include "GameFramework/SpectatorPawn.h" #include "CollapsePawn.generated.h" /** * */ UCLASS() class ACollapsePawn : public ASpectatorPawn { GENERATED_UCLASS_BODY() virtual void BeginPlay() OVERRIDE; };
Code:
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #include "Collapse.h" #include "CollapsePawn.h" ACollapsePawn::ACollapsePawn(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { } void ACollapsePawn::BeginPlay() { Super::BeginPlay(); if (GEngine) { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("We are using CollapsePawn!")); if (Controller != NULL) { // find out which way is forward FRotator Rotation = Controller->GetControlRotation(); const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X); AddMovementInput(Direction, 100.0f); //MoveForward(1.0f); } } }
What I am trying to achieve is the Pawn should accelerate constantly in forward direction unless he will hit some obstacle. This code should prove that I can move the pawn programatically but obviously it is not happening. Any help?
Comment