Paper2d sprite scale

What controls a paper 2d sprite size when generated by C++?

At the moment, in order to apply my own material, I’m duplicating a blueprint APaperSpriteActor. In the actor I’ve setup a sprite with my material.

	m_SpriteActor = smp_World->SpawnActorDeferred<APaperSpriteActor>(smp_Class, FVector::ZeroVector, FRotator(0.0f, 180.0f, -90.0f), smp_Owner);
	if (m_SpriteActor.IsValid())
	{
		FSpriteAssetInitParameters initParams;
		initParams.SetTextureAndFill(mp_Texture);
		UPaperSprite *pNewSprite = DuplicateObject<UPaperSprite>(m_SpriteActor->GetRenderComponent()->GetSprite(), m_SpriteActor.Get(), _T("DuplicatedSprite"));
		pNewSprite->InitializeSprite(initParams);
		m_SpriteActor->GetRenderComponent()->SetMobility(EComponentMobility::Movable);
		m_SpriteActor->GetRenderComponent()->SetSprite(pNewSprite);

This seems a bit convoluted but I couldn’t find a c++ interface to set my own material or change the sprite material to translucent. Once I resolve this I’m going to be rendering text and other shapes onto a texture for the sprite, which I’m mainly using as a method for rendering 2d at a depth in my scene.

I’m then using SetActorScale3D to scale the actor to fit a predefined 3d size. This works in essence but not practice as different textures have different resultant 3d sizes.

How is the sprite size calculated?

Looks like the pixels per unit is defaulting to 100. I can’t see how to set this in C++ however can create an extra scaling factor that when multiplied into my calculated actor scale gives me a sprite of the expected size.

		m_Scale.Set(100.0f / mp_Texture->GetSurfaceWidth(), 100.0f / mp_Texture->GetSurfaceHeight());

Voodoo? Yes. Functional? Yes. Shippable? Time will tell!

If you don’t mind me asking, what did time tell you about the shippability of this solution? :slight_smile: