Hi, I am pretty new to UE4 and am struggling with some basic things. So I simply want to create a pawn and move it around a bit. So I copy pasted some code from the twin stick shooter template and used it in my new Pawn class. So here is the Tick() function:
const float ForwardValue = 1;
const float RightValue = 0;
const FVector MoveDirection = FVector(ForwardValue, RightValue, 0.f).GetClampedToMaxSize(1.0f);
const FVector Movement = MoveDirection * DeltaSeconds;
if (Movement.SizeSquared() > 0.0f)
{
const FRotator NewRotation = Movement.Rotation();
FHitResult Hit(1.f);
RootComponent->MoveComponent(Movement, NewRotation, true, &Hit);
}
The last line causes my Unreal Editor to crash and I can’t see why. I didn’t change anything beside the first 2 lines. RootComponent is defined in the constructor with:
static ConstructorHelpers::FObjectFinder<UStaticMesh> EnemyMesh(TEXT("/Game/StarterContent/Shapes/Shape_Sphere"));
EnemyMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("EnemyMesh"));
RootComponent = EnemyMeshComponent;
EnemyMeshComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);
EnemyMeshComponent->SetStaticMesh(EnemyMesh.Object);
The EnemyMeshComponent ist defined in the .h file:
UPROPERTY(Category = Mesh, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UStaticMeshComponent* EnemyMeshComponent;
This is everything I inserted in my EnemyPawn class and I can’t see why this wouldn’t work. I can move the pawn with NewLocation but that causes the collision with other actors not to work. And all useful tutorials I can find are only for blueprints.