[HL2DM] Sprite re-parenting offset issue
1 Attachment(s)
Hi people,
I have an overall working feature which puts sprites above a single client's head (among all connected players). To save performance / be efficient, when a different client is designated to have the sprite and it was already created, I simply teleport and re-parent it to the new owner (so instead of e.g. killing & re-creating the sprite). For context, this is for a match server. Sometimes, there is the issue where the re-parented sprite becomes shifted (horizontally only) from the relative head point where it should be (must be horizontally centered to the player model, and some units above head), possibly when the new player was moving and/or jumping right before the sprite is re-parented to them. This problematic offset is either randomly small and unimportant or too big and therefore annoying for the gameplay, as the sprite is visible to owner and others. Here's the function that gets called for re-parenting the sprite: Code:
void ResetKingSprite() Would there be a master way to ensure the sprite is always correctly placed without having any offset? If possible, I'd like to hear from anyone who might dealed with the same concept (not exclusively, ofc). Any help appreciated. Thanks. |
Re: [HL2DM] Sprite re-parenting offset issue
You are doing all in same frame.
Try request next frame after teleport, then parent or something. My wild guess. |
Re: [HL2DM] Sprite re-parenting offset issue
Quote:
Casually, I had thought the same and already had switched to that approach before posting the thread, but I wanted to expose the original intended code state. Code:
void ResetKingSprite() |
Re: [HL2DM] Sprite re-parenting offset issue
I don't have idea, how accurate are coordinates with client and sprite in same code sequence...
And perhaps 1 frame delay could be too short to fix it, next you could try create timer with 0.1 seconds. Recommend in Valve Wiki dev site in some documents. |
Re: [HL2DM] Sprite re-parenting offset issue
This approach seems to be working flawlessly for now:
Code:
void StartResetKingSprite() |
All times are GMT -4. The time now is 08:41. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.