// Called when the game starts or when spawned
void AMyPlayer::BeginPlay()
{
    Super::BeginPlay();
    //FRotator ActorRotation = GetActorRotation();


    SetActorLocation(startLocation);

}
Exemple #2
0
void ARockSpell::StartBehavior(const APlayerCharacter& player)
{
	this->SetActorHiddenInGame(false);
	this->SetActorEnableCollision(true);
	RockMesh->Activate(true);
	SetActorLocation(player.GetActorLocation() + player.GetActorForwardVector() * 100,false,(FHitResult*)nullptr,ETeleportType::TeleportPhysics);
	movementComponent->InitializeAndStart(MaxRockDistance, chargedTime, player.GetActorForwardVector());

}
Exemple #3
0
// Called every frame
void AItem::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	FVector NewLocation = GetActorLocation();
	float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
	NewLocation.Z += DeltaHeight * Magnitude;
	RunningTime += DeltaTime;
	SetActorLocation(NewLocation);
}
Exemple #4
0
// Called every frame
void ALoadingFile::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	FVector NewLocation = GetActorLocation();
	float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
	NewLocation.Z += DeltaHeight * 20.0f;
	RunningTime += DeltaTime;
	SetActorLocation(NewLocation);
}
//Moves the spawner to a point within a hemisphere of its starting location.
void AAsteroidSpawner::CalculateNextPosition()
{
    FVector NewLocation = DefaultLocation;

    NewLocation.X += SpawnRange * FMath::Cos(FMath::RandRange(0, 360)) * FMath::Cos(FMath::RandRange(0, 360));
    NewLocation.Y += SpawnRange * FMath::Cos(FMath::RandRange(0, 360)) * FMath::Sin(FMath::RandRange(0, 360));
    NewLocation.Z += std::max(SpawnRange * FMath::Sin(FMath::RandRange(0, 360)), DefaultLocation.Z);

    SetActorLocation(NewLocation);
}
// Called every frame
void ABaseCharacter::Tick( float DeltaTime )
{
    Super::Tick( DeltaTime );

    if(_cooldown > 0.0f) _cooldown -= DeltaTime;

    FVector loc = GetActorLocation();
    loc.Y = 0.0f;
    SetActorLocation(loc);
}
void APlayerOvi::OnMobilePlatform(AMobilePlatform *mp, FVector movement){
  if (!m_isJumping){
    FVector loc = GetActorLocation();
    SetActorLocation(loc + movement);
    m_isOnMobilePlatform = true;
  }
  else{
    m_isOnMobilePlatform = false;
  }
}
// Called every frame
void AEnemy::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	//Make Actor Float in Air
	FVector Enemy_Location = GetActorLocation();
	float Delta_Z = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
	Enemy_Location.Z += Delta_Z*10.0f;
	RunningTime += DeltaTime;
	SetActorLocation(Enemy_Location);
}
// Called every frame
void AFloating_Platform::Tick( float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	DeltaSeconds = *fTimeSpeed;
	FVector NewLocation = GetActorLocation();
	FRotator NewRotation = GetActorRotation();
	float DeltaHeight = (FMath::Sin(*RunningTime_ + DeltaSeconds) - FMath::Sin(*RunningTime_));
	NewLocation.Z += DeltaHeight * (*fFlyingZ);
	*RunningTime_ += DeltaSeconds;
	SetActorLocation(NewLocation);
}
// Called every frame
void APawnWithCamera::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	//Rotate our actor's yaw, which will turn our camera because we're attached to it
	{
		FRotator NewRotation = OurCameraBase->GetComponentRotation();
		NewRotation.Yaw += -CameraInput.X;
		OurCameraBase->SetWorldRotation(NewRotation);
	}

	//Rotate our camera's pitch, but limit it so we're always looking downward
	{
		FRotator NewRotation = OurCameraBase->GetComponentRotation();
		NewRotation.Pitch = FMath::Clamp(NewRotation.Pitch - CameraInput.Y, -80.0f, 80.0f);
		OurCameraBase->SetWorldRotation(NewRotation);
	}

	//Handle movement based on our "MoveX" and "MoveY" axes
	{
		if (!MovementInput.IsZero())
		{
			//Scale our movement input axis values by 100 units per second
			MovementInput = MovementInput.SafeNormal() * 100.0f;
			FVector NewLocation = GetActorLocation();
			NewLocation += GetActorForwardVector() * MovementInput.X * DeltaTime;
			NewLocation += GetActorRightVector() * MovementInput.Y * DeltaTime;
			SetActorLocation(NewLocation);
		}
	}




	FVector LeftEyePosition = LeftEyePos->GetComponentLocation() - OurCamera->GetComponentLocation();
	LeftEyePosition.Normalize();

	FVector RightEyePosition = RightEyePos->GetComponentLocation() - OurCamera->GetComponentLocation();
	RightEyePosition.Normalize();

	FVector4 LeftEyeWeight;
	FVector4 RightEyeWeight;

	for (int i = 0; i < 4; i++)
	{
		LeftEyeWeight[i] = FVector::DotProduct((LeftEyePosition - FishEyePos[i]), dir[i]) / length[i];
		RightEyeWeight[i] = FVector::DotProduct((RightEyePosition - FishEyePos[i]), dir[i]) / length[i];
	}

	RV_MatInst->SetVectorParameterValue(FName("LeftEyePos"), LeftEyePosition);
	RV_MatInst->SetVectorParameterValue(FName("RightEyePos"), RightEyePosition);
	RV_MatInst->SetVectorParameterValue(FName("RightWeight"), LeftEyePosition);
	RV_MatInst->SetVectorParameterValue(FName("LeftWeight"), RightEyePosition);
}
Exemple #11
0
// Called every frame
void AFlatEarth::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	FVector Position = GetActorLocation();
	Position.Y -= 10;
	if (Position.Y == SwapPosition)
	{
		Position.Y = StartPosition;
	}
	SetActorLocation(Position);
	
}
void AInertiaCamera::Tick(float Delta) {
	if (FollowComponent == NULL) {
		return;
	}

	FVector Location = GetActorLocation();
	FRotator Rotation = GetActorRotation();

	FVector CompLocation = FollowComponent->GetComponentLocation();
	FRotator CompRotation = FollowComponent->GetComponentRotation();

	Location = Location * 0.7 + CompLocation * 0.3;
	Rotation = Rotation * 0.7 + CompRotation * 0.3;

	LocationError = (CompLocation - Location) * 0.05 + LocationError * 0.95;
	RotationError = (CompRotation - Rotation) * 0.05 + RotationError * 0.95;

	//Location = FMath::VInterpTo(Location, CompLocation, Delta, 10);
	//Rotation = FMath::RInterpTo(Rotation, CompRotation, Delta, 10);

	SetActorRotation(Rotation + RotationError);
	SetActorLocation(Location + LocationError);

/*
	CurrentLocation = 0.5 * CurrentLocation + 0.5 * FollowComponent->GetComponentLocation();

	FTransform Transform = FollowComponent->ComponentToWorld;
	FTransform CurrentTransform = GetTransform();
	Transform.Rotat

	FTransform ThisTransform = UKismetMathLibrary::TInterpTo(GetTransform(), Transform, Delta, 10);

	SetActorTransform(ThisTransform);*/

	//SetActorLocation(CurrentLocation);
	//FVector MyLocation = GetActorLocation();
	//FVector CurrentLocation = FollowComponent->GetComponentLocation();
	//SetActorLocation(CurrentLocation, false);
	//SetActorRotation(FollowComponent->GetComponentRotation());

	//SetActorLocation(FollowActor->GetActorLocation() + FollowComponent->RelativeLocation);
	//SetActorTransform(FollowComponent->GetRelativeTransform() * FollowActor->GetTransform());
	//SetActorLocation(FollowActor->GetActorLocation() + FVector(0, 0, 1000));

	//FTransform Trans = FollowComponent->ComponentToWorld;

	//FVector LocationComp = CurrentLocation;
	//FVector LocationAct = FollowActor->GetActorLocation();
	//FVector MyLoc = GetActorLocation();
	//SetActorLocation(LocationComp);
	//SetActorRotation(FollowComponent->GetComponentRotation());
}
Exemple #13
0
//========================================================================
void C_DudeDrop::Start()
{
	auto companion = m_Dude.GetCompanion();
	if (!companion)
	{
		return;
	}

	companion->DetachRootComponentFromParent(false);
	companion->SetActorLocation(m_Dude.GetActorLocation());
	companion->OnDrop();
	m_Dude.SetCompanion(nullptr);
}
Exemple #14
0
void AProjectile::DeactivateProjectile()
{ 
	bIsActive = false;
	SetActorHiddenInGame(true);

	//set the projectile in a hidden position outside game
	SetActorLocation(FVector(0, 1000, 3000)); 
	
	//deactive collisions and movement
	CollisionComp->Deactivate();
	MovementComp->Deactivate();
	
}
void AMobilePlatform::RestoreInitialState() {
  SetActorLocation(m_initialPosition);
  MobilePlatformMaterial->SetVectorParameterValue("Color", m_initialColor);
  Enabled = m_enabledInitial;
  m_state = INITIAL_DELAY;
  m_totalDistance = RightDistance;
  m_actions = 0;
  m_isPlayerOn = false;
  intermitedOn = true;
  m_elapsedIntermitence = 0.0f;
  m_movement = FVector(0);
  m_currentDistance = 0;
}
void ALevelBlockConstructor::BeginPlay()
{
	Super::BeginPlay();

	// Get pointer to The Game Mode
	if (GetWorld() && GetWorld()->GetAuthGameMode() && GetWorld()->GetAuthGameMode<ARadeGameMode>())
	{
		GetWorld()->GetAuthGameMode<ARadeGameMode>()->TheLevelBlockConstructor = this;
	}

	// Set to root of world
	SetActorLocation(FVector(0, 0, 0));
}
void ACapTheBrainCharacter::LooseBrain()
{
	GotHit = false;
	FellDown = false;
	FVector newBrainPosition = this->GetActorLocation();
	SetActorLocation(startPosition);
	SetActorRotation(startRotation);
	gameState->brain->DetachFromHead(this, newBrainPosition);
	for (int i = 0; i < gameState->characters.Num(); i++)
	{
		gameState->arrows[gameState->characters[i]->id]->ChangeMaterial(false, false, true);
	}
}
void AAnchovieCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (PatrolPath != NULL)
	{
		if (LightOn == true)
		
		{
			if (PatrolPath->GetSplineLength() <= DistanceOnSpline)
			{
				DistanceOnSpline = 0;
			}
			else
			{
				DistanceOnSpline += AnchovySpeed * DeltaTime;
			}
			SetActorRotation(PatrolPath->GetRotationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World));
			SetActorLocation(PatrolPath->GetLocationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World));
		}
		else
		{
			if (DistanceOnSpline <= 0)
			{
				DistanceOnSpline = PatrolPath->GetSplineLength();
			}
			else
			{
				DistanceOnSpline -= AnchovySpeed * DeltaTime;
			}
			rotationTarget = PatrolPath->GetRotationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World);
			rotationTarget.Yaw += 180;
			SetActorRotation(rotationTarget);
			SetActorLocation(PatrolPath->GetLocationAtDistanceAlongSpline(DistanceOnSpline, ESplineCoordinateSpace::World));
		}
	}


}
// Called every frame
void AFollowingActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (bFollowing && (nullptr != TargetActor))
	{
		const float InterpSpeed = 1.0f;
		const FVector CurrentLocation = GetActorLocation();
		const FVector InterpLocation = FMath::VInterpTo(CurrentLocation, TargetActor->GetActorLocation(), DeltaTime, InterpSpeed);
		const bool bSweep = false; // Do NOT perform collision detection (this is the default)

		SetActorLocation(InterpLocation, bSweep);
	}
}
void AMyPlayer::MoveRight(float Value)
{

    if ((Controller != NULL) && (Value != 0.0f) && this->GetActorLocation().X < 1950 && this->GetActorLocation().X > -150)
    {
        FTransform newLocation;

        newLocation.SetLocation(FVector(this->GetActorLocation().X + Value * speed, this->GetActorLocation().Y, this->GetActorLocation().Z));
        newLocation.SetRotation(FQuat(FRotator(0, 0, 0)));
        SetActorTransform(newLocation);
    }
    else if (this->GetActorLocation().X >= 1950)
    {
        SetActorLocation(FVector(1949, this->GetActorLocation().Y, this->GetActorLocation().Z));
    }
    else if (this->GetActorLocation().X <= -150)
    {
        SetActorLocation(FVector(-149, this->GetActorLocation().Y, this->GetActorLocation().Z));

    }


}
// Called every frame
void APaperPawn::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	//Get Actor Vector
	FVector CurrentVector = GetActorLocation();

	//Vector.x Value ++
	CurrentVector.X += ConstLocationValue;

	//Set Actor Vector
	SetActorLocation(CurrentVector);

}
void APlayerOvi::CalculateGravity(float DeltaSeconds){
  FVector up = GetActorUpVector();
  FVector location = GetActorLocation();

  if (m_enabledGravity && !m_hasLanded && !m_isOnMobilePlatform) {
    if (m_actualJumpSpeed < FallSpeed)
      m_actualJumpSpeed += AccelerationFall * DeltaSeconds;
    else{
      m_actualJumpSpeed = FallSpeed;
    }
    location -= m_actualJumpSpeed * DeltaSeconds * up;
    SetActorLocation(location);
  }
}
Exemple #23
0
// Called every frame
void AFournoidKeeper::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	
	auto NewLocation = GetActorLocation();
	auto DeltaHeight = FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime);
	NewLocation.Z += DeltaHeight * KeeperHoverFalloff;
	SetActorLocation(NewLocation);
	
	RunningTime += DeltaTime;
	
	//FollowMaster(DeltaTime);

}
// Called every frame
void APawnWithCamera::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	//zooming in and out code
	if (bZoomingIn)
	{
		ZoomFactor += DeltaTime / 0.5f;		//zoom in over half a second
	}
	else
	{
		ZoomFactor -= DeltaTime / 0.25f; // zoom out over a quarter of a second
	}
	ZoomFactor = FMath::Clamp<float>(ZoomFactor, 0.0f, 1.0f);
	//blend our camera's FOV and our springArms length based on zoomfactor
	OurCamera->FieldOfView = FMath::Lerp<float>(90.0f, 60.0f, ZoomFactor);
	OurCameraSpringArm->TargetArmLength = FMath::Lerp<float>(400.0f, 300.0f, ZoomFactor);

	//camera control code
	{
		//rotate our actor's yaw which will turn our camera because we're attached to it
		FRotator newRot = GetActorRotation();
		newRot.Yaw += CameraInput.X;
		SetActorRotation(newRot);
		//rotate the camera's pitch, but limit it so we're always looking downward
		FRotator newRot2 = OurCameraSpringArm->GetComponentRotation();
		newRot2.Pitch = FMath::Clamp(newRot2.Pitch + CameraInput.Y, -80.0f, -15.0f);
		OurCameraSpringArm->SetWorldRotation(newRot2);

		FRotator newRot3 = OurCamera->GetComponentRotation();
		newRot3.Roll = FMath::Lerp<float>(newRot.Roll, 120.0f * MovementInput.Y, DeltaTime);
		OurCamera->SetWorldRotation(newRot3);
	}

	//handle movememnt based on out movex and movey axes
	if (!MovementInput.IsZero())
	{
		//scale our moevement input axis values by 100 units per second
		MovementInput = MovementInput.GetSafeNormal();
		FVector newLoc = GetActorLocation();
		newLoc += GetActorForwardVector() * MovementInput.X * DeltaTime * ForwardSpeed;
		newLoc += GetActorRightVector() * MovementInput.Y * DeltaTime * StrafeSpeed;
		SetActorLocation(newLoc);

		//also slightly roll the camera when the player strafes
		FRotator newRot = FRotator(GetActorRotation().Pitch, GetActorRotation().Yaw, 0.0f);
		newRot.Roll += MovementInput.Y * DeltaTime * StrafeSpeed;
	}
}
Exemple #25
0
// Called every frame
void ADKBarrel::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	if (RotMovement)
		RotMovement->RotationRate = RotationRate;
	FVector DeltaMovement = FVector::ZeroVector;
	
	FHitResult hit;
	if (GetFloor(hit) && !bMovingOnLadder)
	{
		if (bMoveDirection)
		{
			DeltaMovement.Y = FMath::Abs<float>(Move) * -1;// FVector(0, -400, 0);
			TraceStartDistance = FMath::Abs<float>(40);
			RotationRate = FRotator(0, 0, -180);
		}
		else
		{
			DeltaMovement.Y = FMath::Abs<float>(Move);// FVector(0, 400, 0);;
			TraceStartDistance = FMath::Abs<float>(40) * -1;;
			RotationRate = FRotator(0, 0, 180);
		}
		bChangeDirection = true;

		FVector CurrentLocation = GetActorLocation();
		float DesiredLocationZ = hit.Location.Z + 40;
		CurrentLocation.Z = DesiredLocationZ;
		SetActorLocation(FMath::VInterpTo(GetActorLocation(), CurrentLocation, DeltaTime, 5));
	}
	else
	{
		DeltaMovement = FVector(0, 0, Falling);
		if (bChangeDirection)
		{
			if (bMoveDirection)
			{
				bMoveDirection = false;
			}
			else
			{
				bMoveDirection = true;
			}
		}
		bChangeDirection = false;
	}
	DeltaMovement = DeltaMovement * DeltaTime;
	AddActorWorldOffset(DeltaMovement);
}
Exemple #26
0
void AProjectile::ActivateProjectile(const FVector& location, const FRotator& rotator, ACharacter* initializer)
{
	bIsActive = true;
	
	//set the projectile at the start position, and rotates to the aim rotation
	SetActorLocation(location);
	SetActorRotation(rotator);
	Instigator = initializer;

	SetActorHiddenInGame(false);

	InitializeProjectile(initializer);
	CollisionComp->Activate(true);
	MovementComp->Activate(true);	

}
// Called every frame
void AMyDrone::Tick( float DeltaTime )
{
	Super::Tick(DeltaTime);

	FVector NewLocation;

	// we update position of the actor (with [m] to [cm] transform!)
	float x = 100 * curveX->Eval(RunningTime);
	float y = 100 * curveY->Eval(RunningTime);
	float z = 100 * curveZ->Eval(RunningTime);
	NewLocation.X = InitialLocation.X + x;
	NewLocation.Y = InitialLocation.Y + y;
	NewLocation.Z = InitialLocation.Z + z;
	SetActorLocation(NewLocation);

	// we update attitude of the actor
	// notice that the quaternion convention of UE is inverted!
	// in my favorite description: q = ( W -X -Y -Z )
	float q0 = curveQ0->Eval(RunningTime);
	float q1 = curveQ1->Eval(RunningTime);
	float q2 = curveQ2->Eval(RunningTime);
	float q3 = curveQ3->Eval(RunningTime);
	NewRotation.W = q0;
	NewRotation.X = -q1;
	NewRotation.Y = -q2;
	NewRotation.Z = q3;
	//float theta = 3.14159 / 4;
	//NewRotation.W = FMath::Cos(theta/2);
	//NewRotation.X = -FMath::Sin(theta/2)*0;
	//NewRotation.Y = -FMath::Sin(theta/2)*FMath::Cos(theta / 2);
	//NewRotation.Z = -FMath::Sin(theta/2)*FMath::Sin(theta / 2);
	SetActorRotation(NewRotation);

	// update elevon poses
	float d1 = curveD1->Eval(RunningTime);
	float d2 = curveD2->Eval(RunningTime);
	Elevon1Rotation.Pitch = -d1; // sign is opposite to model standards
	Elevon2Rotation.Pitch = -d2;
	elevon1Mesh->SetRelativeRotation(Elevon1Rotation);
	elevon2Mesh->SetRelativeRotation(Elevon2Rotation);

	// here we update running time of actor
	RunningTime += DeltaTime;

}
Exemple #28
0
// Called every frame
void AShip::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

    shootTimer += DeltaTime;
    if (direction != 0.0) {
        FVector newLocation = GetRootComponent()->GetComponentLocation();
        newLocation.Y += DeltaTime * speed * direction;
        newLocation.Y = FMath::Min(FMath::Max(newLocation.Y, -500.0f), 500.0f);
        SetActorLocation(newLocation);
    }
    if (isShooting && shootTimer >= shootCooldown) {
        FVector location = GetRootComponent()->GetComponentLocation();
        AActor *laser = GetWorld()->SpawnActor<ALaser>(location, FRotator(90, 0, 0));
        shootSound->Play();
        shootTimer = 0;
    }
}
Exemple #29
0
void ABrush::CopyPosRotScaleFrom( ABrush* Other )
{
	check(BrushComponent);
	check(Other);
	check(Other->BrushComponent);

	SetActorLocation(Other->GetActorLocation(), false);
	SetActorRotation(Other->GetActorRotation());
	if( GetRootComponent() != NULL )
	{
		SetPrePivot( Other->GetPrePivot() );
	}

	if(Brush)
	{
		Brush->BuildBound();
	}

	ReregisterAllComponents();
}
void APlayerOvi::AjustPosition() {
  FVector location = GetActorLocation();

  if (location.X > m_limit)
    location.X = m_limit;
  else if (location.X < -m_limit)
    location.X = -m_limit;

  if (location.Y > m_limit)
    location.Y = m_limit;
  else if (location.Y < -m_limit)
    location.Y = -m_limit;

  if (location.Z > m_limit)
    location.Z = m_limit;
  else if (location.Z < -m_limit)
    location.Z = -m_limit;

  SetActorLocation(location);
}