Пример #1
0
void UVREditorMode::ToggleFlashlight( UVREditorInteractor* Interactor )
{
	UVREditorMotionControllerInteractor* MotionControllerInteractor = Cast<UVREditorMotionControllerInteractor>( Interactor );
	if ( MotionControllerInteractor )
	{
		if ( FlashlightComponent == nullptr )
		{
			FlashlightComponent = NewObject<USpotLightComponent>( AvatarActor );
			AvatarActor->AddOwnedComponent( FlashlightComponent );
			FlashlightComponent->RegisterComponent();
			FlashlightComponent->SetMobility( EComponentMobility::Movable );
			FlashlightComponent->SetCastShadows( false );
			FlashlightComponent->bUseInverseSquaredFalloff = false;
			//@todo vreditor tweak
			FlashlightComponent->SetLightFalloffExponent( 8.0f );
			FlashlightComponent->SetIntensity( 20.0f );
			FlashlightComponent->SetOuterConeAngle( 25.0f );
			FlashlightComponent->SetInnerConeAngle( 25.0f );

		}

		const FAttachmentTransformRules AttachmentTransformRules = FAttachmentTransformRules( EAttachmentRule::KeepRelative, true );
		FlashlightComponent->AttachToComponent( MotionControllerInteractor->GetMotionControllerComponent(), AttachmentTransformRules );
		bIsFlashlightOn = !bIsFlashlightOn;
		FlashlightComponent->SetVisibility( bIsFlashlightOn );
	}
}
Пример #2
0
void AMech_RPGCharacter::SetUpWidgets() {
	if (widgetClass != nullptr) {
		floatingStats = CreateWidget<UFloatingStats_BP>(GetWorld(), widgetClass);
		floatingStats->SetOwner(this);
		stats->SetWidget(floatingStats);

		FTransform trans;
		trans.SetLocation(FVector(0.0, 8.0, 130.0));
		trans.SetScale3D(FVector(0.25, 0.75, 1));
		stats->SetRelativeTransform(trans);
		stats->AttachToComponent(GetRootComponent(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false));
		stats->SetDrawSize(FVector2D(100, 50));

		//if (!isPlayer && !isAlly) {
		stats->SetVisibility(false, true);
		//}
	}

	if (inventory != nullptr) {
		int invSize = 20;
		inventory->SetMaxItemCount(invSize);
		/*inventory->AddItem(AItem::CreateItem(GetWorld(), this, "Item 1", 3, 0, 0, 5));
		inventory->AddItem(AItem::CreateItem(GetWorld(), this, "Item 1", 3, 0, 0, 5));
		inventory->AddItem(AItem::CreateItem(GetWorld(), this, "Item 2", 4, 0, 0, 2));
		inventory->AddItem(AItem::CreateItem(GetWorld(), this, "Item 3", 0, 0, 0, 2));
		inventory->AddItem(AItem::CreateItem(GetWorld(), this, "Item 4", 3, 0, 0, 1));*/
	}

	GetFloatingStats()->UpdateHealthBar();

	if (GetCharacterStats() != nullptr) {
		GetCharacterStats()->UpdateHealthBar();
	}
}
void UFlareSpacecraftNavigationSystem::ConfirmDock(AFlareSpacecraft* DockStation, int32 DockId)
{
	FLOGV("UFlareSpacecraftNavigationSystem::ConfirmDock : '%s' is now docked", *Spacecraft->GetParent()->GetImmatriculation().ToString());
	ClearCurrentCommand();

	// Set as docked
	DockStation->GetDockingSystem()->Dock(Spacecraft, DockId);
	SetStatus(EFlareShipStatus::SS_Docked);
	Data->DockedTo = DockStation->GetImmatriculation();
	Data->DockedAt = DockId;

	if(DockConstraint)
	{
		DockConstraint->BreakConstraint();
		DockConstraint->DestroyComponent();
		DockConstraint = NULL;
	}

	// Attach to station
	FConstraintInstance ConstraintInstance;
	ConstraintInstance.bDisableCollision = true;
	ConstraintInstance.AngularSwing1Motion = ACM_Locked;
	ConstraintInstance.AngularSwing2Motion = ACM_Locked;
	ConstraintInstance.AngularTwistMotion = ACM_Locked;
	ConstraintInstance.LinearXMotion = LCM_Locked;
	ConstraintInstance.LinearYMotion = LCM_Locked;
	ConstraintInstance.LinearZMotion = LCM_Locked;
	ConstraintInstance.AngularRotationOffset = FRotator::ZeroRotator;
	ConstraintInstance.bSwingLimitSoft = 0;
	ConstraintInstance.bTwistLimitSoft = 0;
	ConstraintInstance.bLinearLimitSoft = 0;
	ConstraintInstance.bLinearBreakable = 0;
	ConstraintInstance.bAngularBreakable = 0;


	DockConstraint = NewObject<UPhysicsConstraintComponent>(Spacecraft->Airframe);
	DockConstraint->ConstraintInstance = ConstraintInstance;
	DockConstraint->SetWorldLocation(Spacecraft->GetActorLocation());
	DockConstraint->AttachToComponent(Spacecraft->GetRootComponent(), FAttachmentTransformRules(EAttachmentRule::KeepWorld, false), NAME_None);

	DockConstraint->SetConstrainedComponents(Spacecraft->Airframe, NAME_None, DockStation->Airframe,NAME_None);

	// Cut engines
	TArray<UActorComponent*> Engines = Spacecraft->GetComponentsByClass(UFlareEngine::StaticClass());
	for (int32 EngineIndex = 0; EngineIndex < Engines.Num(); EngineIndex++)
	{
		UFlareEngine* Engine = Cast<UFlareEngine>(Engines[EngineIndex]);
		Engine->SetAlpha(0.0f);
	}


	Spacecraft->OnDocked(DockStation);
}
Пример #4
0
void AWeapon::SetItemOwner(AMech_RPGCharacter* inOwner) {
	Super::SetItemOwner(inOwner);

	if (inOwner != nullptr) {
		if (partclSystem != nullptr) {
			// TODO Attach to end of weapon
			partclSystem->AttachToComponent(inOwner->GetRootComponent(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false));
			partclSystem->SetActorParameter(FName(TEXT("BeamSource")), this);
		}

		inOwner->OnStopFiring.AddUniqueDynamic(this, &AWeapon::StopFire);
	}
}
void AFirstPersonCharacter::BeginPlay()
{
	// Call the base class  
	Super::BeginPlay();

	if (GunBlueprint == NULL) {
		UE_LOG(LogTemp, Warning, TEXT("Gun blueprint missing."));
		return;
	}
	Gun = GetWorld()->SpawnActor<AGun>(GunBlueprint);
	Gun->AttachToComponent(Mesh1P, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), TEXT("GripPoint")); //Attach gun mesh component to Skeleton, doing it here because the skelton is not yet created in the constructor
	Gun->AnimInstance = Mesh1P->GetAnimInstance();
	if (EnableTouchscreenMovement(InputComponent) == false)
	{
		InputComponent->BindAction("Fire", IE_Pressed, Gun, &AGun::OnFire);
	}
}
UObject* ULevelSequence::MakeSpawnableTemplateFromInstance(UObject& InSourceObject, FName ObjectName)
{
	UObject* NewInstance = NewObject<UObject>(MovieScene, InSourceObject.GetClass(), ObjectName);

	UEngine::FCopyPropertiesForUnrelatedObjectsParams CopyParams;
	CopyParams.bNotifyObjectReplacement = false;
	UEngine::CopyPropertiesForUnrelatedObjects(&InSourceObject, NewInstance, CopyParams);

	AActor* Actor = CastChecked<AActor>(NewInstance);
	if (Actor->GetAttachParentActor() != nullptr)
	{
		// We don't support spawnables and attachments right now
		// @todo: map to attach track?
		Actor->DetachFromActor(FDetachmentTransformRules(FAttachmentTransformRules(EAttachmentRule::KeepRelative, false), false));
	}

	return NewInstance;
}
Пример #7
0
AMech_RPGCharacter::AMech_RPGCharacter() :
	healthChangeModifier(1),
	inventory(NewObject<UInventory>(UInventory::StaticClass())),
	defenceModifier(0),
	speedModifier(1),
	startingRole(GroupEnums::DPS),
	health(2000),
	maxHealth(2000),
	channeling(false),
	team(TeamEnums::Paladins)
{
	static int32 ID = 0;
	SetID(ID++);
	SetActorTickEnabled(true);
	AIControllerClass = ABaseAIController::StaticClass();

	// Create a camera boom...
	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->AttachToComponent(RootComponent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
	CameraBoom->bAbsoluteRotation = true; // Don't want arm to rotate when character does
	CameraBoom->TargetArmLength = 1800.0f;
	CameraBoom->RelativeRotation = FRotator(-85.f, 0.f, 0.f);
	CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level

	// Create a camera...
	TopDownCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("TopDownCamera"));
	TopDownCameraComponent->AttachToComponent(CameraBoom, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false), USpringArmComponent::SocketName);
	TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm

	// Don't rotate character to camera direction
	bUseControllerRotationPitch = false;
	bUseControllerRotationYaw = false;
	bUseControllerRotationRoll = false;

	// Configure character movement
	GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction
	GetCharacterMovement()->RotationRate = FRotator(0.f, 640.f, 0.f);
	GetCharacterMovement()->bConstrainToPlane = true;
	GetCharacterMovement()->bSnapToPlaneAtStart = true;
	GetCharacterMovement()->bCanWalkOffLedges = false;
	GetCharacterMovement()->SetWalkableFloorAngle(90);
	GetCharacterMovement()->SetAvoidanceGroup(0);
	GetCharacterMovement()->SetGroupsToAvoid(0);
	//GetCharacterMovement()->SetGroupsToIgnore(0);

	speed = GetCharacterMovement()->MaxWalkSpeed;

	static ConstructorHelpers::FClassFinder<UFloatingStats_BP> statsWidget(TEXT("/Game/TopDown/Blueprints/UI/CharacterUI/FloatingStats"));

	if (statsWidget.Succeeded()) {
		widgetClass = statsWidget.Class;
		stats = CreateDefaultSubobject<UWidgetComponent>(TEXT("Floating Stats Component"));
		stats->AttachToComponent(GetRootComponent(), FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
	}

	static ConstructorHelpers::FClassFinder<UFloatingTextUI> floatingTextWidget(TEXT("/Game/TopDown/Blueprints/UI/CharacterUI/Floating_Text"));

	if (floatingTextWidget.Succeeded()) {
		floatingTextClass = floatingTextWidget.Class;
	}

	static ConstructorHelpers::FObjectFinder<USkeletalMesh> newMesh(TEXT("/Game/TopDown/Meshes/Mech/Mech.Mech"));

	if (newMesh.Succeeded()) {
		GetMesh()->SetSkeletalMesh(newMesh.Object);
		GetMesh()->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
		GetMesh()->SetCollisionObjectType(mCharacterCollision);
	}

	// Set size for player capsule
	GetCapsuleComponent()->InitCapsuleSize(60.0f, 140.0f);
	GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
	GetCapsuleComponent()->SetCollisionObjectType(mCharacterCollision);
	GetCapsuleComponent()->SetCollisionResponseToChannel(mItemCollision, ECollisionResponse::ECR_Ignore);
	//GetCapsuleComponent()->SetCollisionResponseToChannel(mCharacterCollision, ECollisionResponse::ECR_Ignore);

	//radiusDection = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
	//radiusDection->InitSphereRadius(1500.0f);
	//radiusDection->SetCollisionProfileName(TEXT("Pawn"));
	//radiusDection->AttachTo(this->RootComponent);
	//radiusDection->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
	characters.Add(this);
}