Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GameObject.GetBounds() is incorrect when GameObject with ModelRenderer is scaled #7408

Open
NottyNoz opened this issue Jan 19, 2025 · 1 comment
Assignees

Comments

@NottyNoz
Copy link

Describe the bug

When a GameObject with the ModelRenderer is transformed in the editor to be scaled beyond 1, the BBox returned by GetBounds() is incorrect in different ways depending on when you run GetBounds().

When this box is scaled to 1, its bounding box is [mins -25,-25,-25, maxs 25,25,25] but when scaled to 5, its bounding box is [mins -625,-625,-625, maxs 625,625,625]
Image
Image

However, the bounding box for a GameObject with the BoxCollider is always a constant [mins -0.5,-0.5,-0.5, maxs 0.5,0.5,0.5] regardless of the transformation or by changing the BoxCollider's "size" parameters.
Image
Image

To Reproduce

Create a GameObject in a Scene and add a ModelRenderer or BoxCollider component to it along with this custom component.

using Sandbox;

public class BoxBug : Component
{
    protected override void OnEnabled(){
	Log.Info($"Incorrect: {this.GameObject.GetBounds()}");
    }

    protected override void OnFixedUpdate(){
        Log.Info($"Incorrect: {this.GameObject.GetBounds()}");
    }
}

Expected behavior

A [mins -25,-25,-25, maxs 25,25,25] box scaled by 5 should be [mins -125,-125,-125, maxs 125,125,125].

Media/Files

No response

Additional context

No response

@lolleko
Copy link

lolleko commented Jan 19, 2025

I've been meaning to look into this there are several things broken about GameObject.GerBounds(). But since people may rely on this broken behaviour I wanted to wait til after the tech jam.

@lolleko lolleko moved this from To triage to Ready in s&box tracker Jan 19, 2025
@lolleko lolleko self-assigned this Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

2 participants