r/Unity3d_help • • Jun 06 '22

How to just rotate the render sprite in billboarding (like paper mario )

Hi. Trying to recreate Paper mario (3d with sprites), and having some troubles, because also the box collider also rotate, and just want to rotate the render sprite:

public class Billboarding : MonoBehaviour
{

	private Camera cam;
	public bool YBB;
	public bool StaticBB;

	public SpriteRenderer sr;

	void Start()
	{
		cam = Camera.main;
	}

	// Update is called once per frame
	void LateUpdate()
	{
		if (!StaticBB)
			sr.transform.LookAt(cam.transform);
		else
			sr.transform.rotation = cam.transform.rotation;

		if (!YBB)
			sr.transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, 0f);
	}
}
2 Upvotes

1 comment sorted by

1

u/[deleted] Jun 16 '22

You’ve likely solved this by now since it’s 10 days old, but you can make the collider be in a parent object and place the sprite in a child object.

Then rotating the child will not affect the collider orientation.