Added teleportation feature in simple shooter unreal c++ game

bandicam 2020-11-16 21-48-25-858

By using RayCast the player can teleport to any location where the raycast hits added teleportation particle effect

void AShooterCharacter::Teleport()
{
	UGameplayStatics::SpawnEmitterAttached(TeleportEffect, GetMesh(), TEXT("Muzzle_01"));

	FVector Start = GetMesh()->GetSocketLocation(TEXT("Muzzle_01"));
	FRotator StartRotation = GetMesh()->GetSocketRotation(TEXT("Muzzle_01"));

	FVector End = Start + (StartRotation.Vector() * 2000.0f);


	DrawDebugLine(GetWorld(), Start, End, FColor::Blue, false, 1, 0, 1);

	FHitResult HR;
	
	FCollisionQueryParams params;

	params.AddIgnoredActor(this->GetOwner());


	bool DidHit = GetWorld()->LineTraceSingleByChannel(HR, Start, End, ECollisionChannel::ECC_Visibility, params);

	if (DidHit)
	{
		this->SetActorLocation(HR.Location);
	}

}


1 Like

Oh wow! Okay this is incredible! Have you added anything to it recently? I would love to read a blog or watch a series about how you created the teleportation feature.

Privacy & Terms