View Single Post
AdRiAnIlloO
Member
Join Date: Jul 2015
Location: Spain
Old 10-11-2021 , 16:52   Re: [HL2DM] Sprite re-parenting offset issue
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
You are doing all in same frame.
Try request next frame after teleport, then parent or something. My wild guess.
Thanks!

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()
{
	Entity_ClearParent(gKingSprite);
	float origin[3], angles[3] = {0.0, 0.0, 0.0};
	GetClientAbsOrigin(gTopScorer, origin);
	origin[2] += KING_SPRITE_Z_OFFSET;
	TeleportEntity(gKingSprite, origin, angles, NULL_VECTOR);
	RequestFrame(OnKingSpriteTeleported);
	SetKingSpriteVisibility(true);
}

void OnKingSpriteTeleported()
{
	if (gKingSprite != INVALID_ENT_REFERENCE)
	{
		Entity_SetParent(gKingSprite, gTopScorer);
	}
}
I need to play enough more on my server to confirm how it goes out. The problem is, by the obvious nature of this approach (1 frame delay), the resulting effect might already imply there will still be an offset, variable with client's movement/velocity as well, but which might be smaller at least.

Last edited by AdRiAnIlloO; 10-11-2021 at 16:55.
AdRiAnIlloO is offline