How do I get an Actor rotation to spawn where the wall is facing

I’m currently trying to make a gun and when it shoots something a bullet hole decal will spawn where the raycast hit. I managed to get the decal to spawn and all that but now I’m facing an issue where the decal is facing a weird way depending on the angle I shoot the wall. I’d ideally just like to have the decal face flat along the wall.

Here’s a video of what I’m talking about

I want the decals to look flat along the walls like this though:

oh and the sonic picture is just a placeholder for the bullet decal (havent found a good bullet decal yet)

here’s the code I have to spawn the decal

cpp:

void AFPS_Character::SpawnShell(FVector Loc, FRotator Rot)
{
	FActorSpawnParameters SpawnParams;
	AActor* SpawnActorRef = GetWorld()->SpawnActor<AActor>(ActorToSpawn, Loc, Rot, SpawnParams);
}


const FRotator Rot = Camera->GetComponentRotation();
SpawnShell(HitResult->Location, Rot);

header:

	UPROPERTY(EditDefaultsOnly, Category = "Spawning")
	TSubclassOf<AActor> ActorToSpawn;

use line trace’s hit normal for the decal rotation(now it’s camera rotation)

how would i write that? i’ve never heard of that

could you read blueprint?that thing is pretty easy at BP,but I don’t know CPP

I can but I’m trying to make my game mainly cpp as much as possible which is why i put the question in c++

1 Like

then you could translate it to C++.


1 Like

Ah I got it to work, this definitely helped.

I just wrote in the rotator value:

SpawnShell(HitResult->Location, HitResult->Normal.Rotation());

instead of:

const FRotator Rot = Camera->GetComponentRotation();
SpawnShell(HitResult->Location, Rot);
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.