[BUG?] Entity teleportation can only be activated once
Preface: Maybe This Is Not a Bug🥲
When the Alpha of CBaseModelEntity.Render Is Set to an Integer Between 1 and 255
The issue described in the title does not occur if the alpha value is set to an integer between 1 and 255.
Example (In CS2):
When Alpha Is Set to 0
The unexpected behavior mentioned in the title occurs when alpha is set to 0.
Note: The title might not be fully accurate (details explained below).
Why set alpha to 0?
I aimed to make the entity glow without rendering its model/texture, similar to the prop_dynamic_glow effect in CS:GO.
Example (In CS2):
Initially, I assumed the issue was caused by the entity not updating on the network when alpha=0. However, the m_lastNetworkChange property of the entity continuously increases, suggesting network updates are still occurring.
Key Observations
- After calling
DispatchSpawnon an entity withalpha=0, only the first teleport takes effect. Subsequent teleports do not update the entity’s glow position (the glow remains static). - The entity itself might still be teleporting (I dont know since it’s not rendered), but its glow does not follow.
- (Contradicts the title?) Printing the entity’s
AbsOriginafter teleporting withalpha=0confirms the coordinates match the target position. - Tested
CBaseModelEntity.RenderModevalues:kRenderTransColorkRenderTransTexturekRenderGlowkRenderTransAlphakRenderTransAlphaAddkRenderWorldGlow
All resulted in the same issue.
- Tested
CBaseModelEntity.RenderFXvalues:kRenderFxNonekRenderFxFadeSlowkRenderFxFadeIn
No changes observed.
- Tested entity types:
prop_dynamic_overrideprop_physics_overrideCBaseModelEntity
Issue persisted in all cases.
Encountered a strange phenomenon: even if the Alpha of CBaseModelEntity.Render is set to an integer between 1 and 255, the healthshot model/texture will not be rendered, but it can be teleported multiple times!
( actually this is what I expected 😅 )
Both the client and the server are Windows systems...
What do you think @KillStr3aK 😭
What if you set the follow entity input instead of teleporting around?
What if you set the follow entity input instead of teleporting around?
Nothing happened (the glow remains static)
mind sharing your glow code?
mind sharing your glow code?
var buffer = Utilities.CreateEntityByName<CBaseModelEntity>("basemodelentity");
buffer!.DispatchSpawn();
buffer!.Spawnflags = 256U;
buffer!.SetModel("xxx");
buffer!.Collision.CollisionGroup = 0;
buffer!.ShadowStrength = 0.0f;
buffer!.AnimTime = 0.0f;
buffer!.RenderMode = RenderMode_t.kRenderWorldGlow;
buffer!.RenderFX = RenderFx_t.kRenderFxFadeSlow;
buffer!.Render = Color.FromArgb(1, 255, 255, 255);
buffer!.FadeMinDist = 100.0f;
buffer!.Glow.GlowRange = 5000;
buffer!.Glow.GlowTeam = -1;
buffer!.Glow.GlowType = 3;
buffer!.Glow.GlowRangeMin = 3;
buffer!.Glow.GlowColorOverride = Color.FromArgb(255, rand.Next(256), rand.Next(256), rand.Next(256));
Utilities.SetStateChanged(buffer!, "CBaseEntity", "m_CBodyComponent");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderMode");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderFX");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_clrRender");
buffer!.Teleport(new Vector(player.PlayerPawn.Value!.AbsOrigin!.X, player.PlayerPawn.Value!.AbsOrigin!.Y, player.PlayerPawn.Value!.AbsOrigin!.Z + player.PlayerPawn.Value!.ViewOffset.As<Vector>().Z + 40), new QAngle(0, 0, 0), new Vector(0, 0, 0));
My code is similar to this, but it will include more complex checks to ensure the entity is valid.
mind sharing your glow code?
var buffer = Utilities.CreateEntityByName<CBaseModelEntity>("basemodelentity");
buffer!.DispatchSpawn(); buffer!.Spawnflags = 256U; buffer!.SetModel("xxx");
buffer!.Collision.CollisionGroup = 0; buffer!.ShadowStrength = 0.0f; buffer!.AnimTime = 0.0f;
buffer!.RenderMode = RenderMode_t.kRenderWorldGlow; buffer!.RenderFX = RenderFx_t.kRenderFxFadeSlow; buffer!.Render = Color.FromArgb(1, 255, 255, 255); buffer!.FadeMinDist = 100.0f; buffer!.Glow.GlowRange = 5000; buffer!.Glow.GlowTeam = -1; buffer!.Glow.GlowType = 3; buffer!.Glow.GlowRangeMin = 3; buffer!.Glow.GlowColorOverride = Color.FromArgb(255, rand.Next(256), rand.Next(256), rand.Next(256));
Utilities.SetStateChanged(buffer!, "CBaseEntity", "m_CBodyComponent"); Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderMode"); Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderFX"); Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_clrRender"); buffer!.Teleport(new Vector(player.PlayerPawn.Value!.AbsOrigin!.X, player.PlayerPawn.Value!.AbsOrigin!.Y, player.PlayerPawn.Value!.AbsOrigin!.Z + player.PlayerPawn.Value!.ViewOffset.As<Vector>().Z + 40), new QAngle(0, 0, 0), new Vector(0, 0, 0)); My code is similar to this, but it will include more complex checks to ensure the entity is valid.
This doesn't set the weapon as a parent or follow it, you need to try with either solutions as @KillStr3aK said 👍
mind sharing your glow code?
var buffer = Utilities.CreateEntityByName("basemodelentity"); buffer!.DispatchSpawn(); buffer!.Spawnflags = 256U; buffer!.SetModel("xxx"); buffer!.Collision.CollisionGroup = 0; buffer!.ShadowStrength = 0.0f; buffer!.AnimTime = 0.0f; buffer!.RenderMode = RenderMode_t.kRenderWorldGlow; buffer!.RenderFX = RenderFx_t.kRenderFxFadeSlow; buffer!.Render = Color.FromArgb(1, 255, 255, 255); buffer!.FadeMinDist = 100.0f; buffer!.Glow.GlowRange = 5000; buffer!.Glow.GlowTeam = -1; buffer!.Glow.GlowType = 3; buffer!.Glow.GlowRangeMin = 3; buffer!.Glow.GlowColorOverride = Color.FromArgb(255, rand.Next(256), rand.Next(256), rand.Next(256)); Utilities.SetStateChanged(buffer!, "CBaseEntity", "m_CBodyComponent"); Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderMode"); Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderFX"); Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_clrRender"); buffer!.Teleport(new Vector(player.PlayerPawn.Value!.AbsOrigin!.X, player.PlayerPawn.Value!.AbsOrigin!.Y, player.PlayerPawn.Value!.AbsOrigin!.Z + player.PlayerPawn.Value!.ViewOffset.As().Z + 40), new QAngle(0, 0, 0), new Vector(0, 0, 0)); My code is similar to this, but it will include more complex checks to ensure the entity is valid.
This doesn't set the weapon as a parent or follow it, you need to try with either solutions as @KillStr3aK said 👍
I actually tried the method he mentioned and the glow stayed where it teleported. (I removed it because setting the parent didn't solve the problem)
Try this, it works on pawn, it should work on a weapon (I didn't test it though)
public static void SetGlow(this CBaseEntity entity)
{
CBaseModelEntity? modelGlow = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic");
CBaseModelEntity? modelRelay = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic");
if (modelGlow == null || modelRelay == null)
return;
string modelName = entity.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName;
modelRelay.SetModel(modelName);
modelRelay.Spawnflags = 256u;
modelRelay.RenderMode = RenderMode_t.kRenderNone;
modelRelay.DispatchSpawn();
modelGlow.SetModel(modelName);
modelGlow.Spawnflags = 256u;
modelGlow.DispatchSpawn();
modelGlow.Glow.GlowColorOverride = Color.Magenta;
modelGlow.Glow.GlowRange = 5000;
modelGlow.Glow.GlowTeam = -1;
modelGlow.Glow.GlowType = 3;
modelGlow.Glow.GlowRangeMin = 100;
modelRelay.AcceptInput("FollowEntity", entity, modelRelay, "!activator");
modelGlow.AcceptInput("FollowEntity", modelRelay, modelGlow, "!activator");
}
Try this, it works on pawn, it should work on a weapon (I didn't test it though)
public static void SetGlow(this CBaseEntity entity) { CBaseModelEntity? modelGlow = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic"); CBaseModelEntity? modelRelay = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic"); if (modelGlow == null || modelRelay == null) return;
string modelName = entity.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName;
modelRelay.SetModel(modelName); modelRelay.Spawnflags = 256u; modelRelay.RenderMode = RenderMode_t.kRenderNone; modelRelay.DispatchSpawn();
modelGlow.SetModel(modelName); modelGlow.Spawnflags = 256u; modelGlow.DispatchSpawn();
modelGlow.Glow.GlowColorOverride = Color.Magenta; modelGlow.Glow.GlowRange = 5000; modelGlow.Glow.GlowTeam = -1; modelGlow.Glow.GlowType = 3; modelGlow.Glow.GlowRangeMin = 100;
modelRelay.AcceptInput("FollowEntity", entity, modelRelay, "!activator"); modelGlow.AcceptInput("FollowEntity", modelRelay, modelGlow, "!activator"); }
Actually, I have already solved the model glowing. The purpose of opening this issue is to understand why the teleportation only works the first time when alpha = 0. Or is there a way to hide the model's texture?