void AEnemy::Init()
{
	Super::Init();
	// Loading the PaperFlipbook animation
	for (int i = 0; i < AnimationState::MAX_ENUM_ANIMATION_STATE; ++i)
	{
		FString path = ENEMY_PATH_FOLDER ;
		path += GetTypeAsFString()+ GetAnimationNameAsFString(i);
		GetAnimationPaper()->Add(LoadFlipbook(*path));
	}
	_pawnSensing = (UPawnSensingComponent *)
		GetComponentByClass(UPawnSensingComponent::StaticClass());
	_receiverAttack = GetPlayer();
}
Esempio n. 2
0
// Called every frame
void AmyBallPawn::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	UStaticMeshComponent *static_mesh_component = ((UStaticMeshComponent*)GetComponentByClass(UStaticMeshComponent::StaticClass()));
	USceneComponent *RootComponent = GetRootComponent();

	if (static_mesh_component){

		//FVector CurrentVelocity = static_mesh_component->GetComponentVelocity();

		//速度ベクトルが動いているか?
		if (!CurrentVelocity.IsZero())
		{
			//移動させる
			//FVector NewLocation = GetActorLocation() + (CurrentVelocity * DeltaTime);
			static_mesh_component->BodyInstance.SetLinearVelocity(CurrentVelocity, true);

		}
		CurrentVelocity = FVector::ZeroVector;

		//カメラの位置を移動させるためRootComponentの位置を同じ位置に移動させる
		//RootComponent->SetWorldLocation(static_mesh_component->BodyInstance.GetCOMPosition());

		FVector velocity = static_mesh_component->GetComponentVelocity();

		//重力方向はつぶす
		velocity.Z = 0;

		//左右の速度を判定して一定の速度が出ている場合は上書きして速度を保つ
		if (velocity.Size() > 3000.0f){
			velocity.Normalize();
			velocity *= 3000.0f;
			static_mesh_component->BodyInstance.SetLinearVelocity(velocity, false);
		}
	}
}