[C++] SpawnDecalAtLocation doesn't work

Hello guys.

I’m trying to spawn a decal at location through UGameplayStatics::SpawnDecalAtLocation
The problem is that the decal doesn’t spawn in the world, why?

The BulletHoleMaterial is a material that I set via Blueprints:

71753-2.png

And this is the material:

Why doesn’t that show up?

Thanks!

Is it a problem of the material or of the function?

You can check if this is the problem of the material, simply drag decal actor on the scene and replace its material with yours.

But In my opinion your code is wrong:

DecalLocation should be something in World Location, not normal vector;)

DecalLocation = HitResult.ImpactPoint;

DecalRotation = (-HitResult.ImpactNormal).Rotation();//inverted normal because you probably want to project decal onto hit actor.

@Pierdek

Thanks for the answer.

I did as you suggested but now the Bullet, instead of being invisible, it’s barely visible:

![alt text][1]

Increase its size to 50/50/50 and add
DrawDebugPoint(GetWorld(), DecalLocation , 20.f, FColor::Red, true);
to check if it is at desired location.

![alt text][1]

The position seems to be good, but the material is almost transparent O.o

Also,

In that position seems to work, but in other locations it’s just transparent.

Also, notice the stretched decal in the top of the box. Why?

Ok I resolved the strech decal by decreasing the Z value of the DecalSize FVector.

But still I can’t understand why the decal is transparent in some parts of the map…

I’ve had issues with my decals being semi transparent in the past before too and would like to know the answer to this question. Maybe try connecting a constant value of 1 into the opacity pin in the decal material? They might default to being slightly see-through