Esempio n. 1
0
void AMeteorProjectile::OnHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)
{
	UE_LOG(LogTemp, Display, TEXT("METEOR HIT"));

	TArray<FOverlapResult> res;

	if (GetWorld()->OverlapMultiByChannel(res, GetActorLocation(), FQuat::Identity, ECollisionChannel::ECC_Visibility, FCollisionShape::MakeSphere(300)))
	{
		for (auto a : res)
		{
			if (a.Actor.IsValid() && Cast<ABaseGamer>(a.Actor.Get()))
			{
				a.Actor->TakeDamage(FMath::FRandRange(6000, 16000), FDamageEvent(), GetInstigator() ? GetInstigator()->GetController() : nullptr, this);
			}
		}
	}

	//DrawDebugSphere(GetWorld(), GetActorLocation(), 300, 16, FColor::Red, false, 1);

	Destroy();
}
Esempio n. 2
0
bool UPawnAction::PushChildAction(UPawnAction& Action)
{
	bool bResult = false;
	
	if (OwnerComponent != NULL)
	{
		UE_CVLOG( ChildAction != NULL
			, GetPawn(), LogPawnAction, Log, TEXT("%s> Pushing child action %s while already having ChildAction set to %s")
			, *GetName(), *Action.GetName(), *ChildAction->GetName());
		
		// copy runtime data
		// note that priority and instigator will get assigned as part of PushAction.

		bResult = OwnerComponent->PushAction(Action, GetPriority(), Instigator);

		// adding a check to make sure important data has been set 
		ensure(Action.GetPriority() == GetPriority() && Action.GetInstigator() == GetInstigator());
	}

	return bResult;
}
Esempio n. 3
0
void ALeapMotionHandActor::CreateBones(const TSubclassOf<class ALeapMotionBoneActor>& BoneBlueprint)
{
	FActorSpawnParameters SpawnParams;
	SpawnParams.Owner = GetOwner();
	SpawnParams.Instigator = GetInstigator();

	float CombinedScale = GetCombinedScale();

	FLeapMotionDevice* Device = FLeapMotionControllerPlugin::GetLeapDeviceSafe();
	if (Device && Device->IsConnected())
	{
		for (ELeapBone LeapBone = bShowArm ? ELeapBone::Forearm : ELeapBone::Palm; LeapBone <= ELeapBone::Finger4Tip; ((int8&)LeapBone)++)
		{
			FVector Position;
			FRotator Orientation;
			float Width;
			float Length;

			bool Success = Device->GetBonePostionAndOrientation(HandId, LeapBone, Position, Orientation);
			Success &= Device->GetBoneWidthAndLength(HandId, LeapBone, Width, Length);
			if (Success)
			{
				FQuat RefQuat = GetRootComponent()->GetComponentRotation().Quaternion();
				Position = RefQuat * Position * CombinedScale + GetRootComponent()->GetComponentLocation();
				Orientation = (RefQuat * Orientation.Quaternion()).Rotator();

				ALeapMotionBoneActor* BoneActor = GWorld->SpawnActor<ALeapMotionBoneActor>(BoneBlueprint ? BoneBlueprint : ALeapMotionBoneActor::StaticClass(), Position, Orientation, SpawnParams);
				if (BoneActor) 
				{
					BoneActors.Add(BoneActor);
#					if WITH_EDITOR
						BoneActor->SetActorLabel(*FString::Printf(TEXT("LeapBone:%s"), ANSI_TO_TCHAR(LEAP_GET_BONE_NAME(LeapBone))));
#					endif
					BoneActor->AttachRootComponentToActor(this, NAME_None, EAttachLocation::KeepWorldPosition, true);
					BoneActor->Init(LeapBone, CombinedScale, Width, Length, bShowCollider, bShowMesh);
				}
			}
		}
	}
}