sbox-issues
sbox-issues copied to clipboard
`GetAttachment` wrong position at first frame
Describe the bug
Hi,
Since this commit, i guess cause i didn't have this issue before, Even if the recent garry's attempt fix hasn't worked
it looks like the GetAttachment
position is now incorrect during the first tick :
To Reproduce
- Create
GameObject
parented to thehead
bone :
var goHat = new GameObject();
goHat.SetParent( bodySkinnedModelRenderer.GetBoneObject( bodySkinnedModelRenderer.Model.Bones.AllBones.Where( x => x.Name.Equals( "head" ) ).FirstOrDefault() ));
goHat.Components.Create<MyAttachment>();
- Create
MyAttachment
Component:
public class MyAttachment : Component
{
[Property] public SkinnedModelRenderer SkinnedModelRenderer { get; set; }
public SkinnedModelRenderer GetPlayermodel()
{
return GameObject.Components.GetInAncestors<SkinnedModelRenderer>();
}
protected override void OnStart()
{
base.OnStart();
SkinnedModelRenderer ??= GameObject.Components.GetOrCreate<SkinnedModelRenderer>();
var model = Cloud.Model( "darg/santahatprop" );
SkinnedModelRenderer.Model = model;
Transform.Position = GetPlayermodel().GetAttachment( "hat" ).Value.Position;
Transform.Rotation = GetPlayermodel().GetAttachment( "hat" ).Value.Rotation;
}
protected override void OnUpdate()
{
base.OnUpdate();
// TOGGLE COMMENT / UNCOMMENT
//Transform.Position = GetPlayermodel().GetAttachment( "hat" ).Value.Position;
//Transform.Rotation = GetPlayermodel().GetAttachment( "hat" ).Value.Rotation;
}
}
- See bug
OnStart
:
https://github.com/Facepunch/sbox-issues/assets/5229571/f58d636b-9a6b-4205-8238-9625e87e2af6
Expected behavior
Always getting the correct position of the GetAttachment()
Media/Files
No response
Additional context
BuildId : 14327656