mapbase-source / source-sdk-2013

This is Mapbase's public GitHub repo. It contains all of the code, but not the assets.
https://www.moddb.com/mods/mapbase
Other
225 stars 139 forks source link

[VISUAL] vgui_text_display will never show if it spawns in the player's view #235

Open 8BEATER-Il-S opened 1 year ago

8BEATER-Il-S commented 1 year ago

Hello. This issue will be largely copied from what I wrote down on the Discord server.

vgui_text_display will never show if you spawn it while in the player's view. This was done using a VScript built-in function of SpawnEntityFromTable() and also can be replicated using a point_template (with small difference, probably relating to my own VScript). Some particle effects like fire or explosions reveal an opaque frame at which the panel should have been located, signifying that it does exist in the world.


Steps to reproduce version 1: create point_template hosting vgui_text_display; spawn the entity; Settings: изображение изображение

Video demonstration: https://youtu.be/EdIZL3bsYHI


Steps to reproduce version 2:

My VScript:

baseEntityTable <- 
{
    alignment = 4,
    font = 17,
    resolution = 45,
    textSize = 64
}

function Precache() 
{
    PrecacheEntityFromTable("vgui_text_display", baseEntityTable)
}

function SpawnComboFloatingNumber(_victim, _score) // spawns on victim's death
{
    local myEntityTable = baseEntityTable

    local floatingTextPosition = Vector(_victim.GetOrigin().x, _victim.GetOrigin().y,     _victim.GetOrigin().z + _victim.GetBoundingMaxs().z + _victim.GetBoundingMaxs().z / 32) 
    // The taller the NPC, the more above their head the text appears

    local floatingTextAngles = VectorAngles(playerEnt.EyePosition() - floatingTextPosition);

    myEntityTable.origin <- floatingTextPosition;
    myEntityTable.angles <- -1 * floatingTextAngles;
    myEntityTable.message <- _score.tostring();

    local myTextEntity = SpawnEntityFromTable("vgui_text_display", myEntityTable);
}

As you can see, this version creates a new problem, as text can be spawned only from south or north of the map, not east or west, in addition to being opposite of the player's view.

Video demonstration: https://youtu.be/Y7F09jDyYgE

8BEATER-Il-S commented 1 year ago

Update: I tried another way with spawning the entity outside the player's view and then putting it back into place after some time, and it shows up, however the biggest problem is that attempting to modify this entity after it shows up on the player's screen is impossible, so you can't change the origin, angles or the message.

8BEATER-Il-S commented 1 year ago

Update: I managed to circumvent the issue using a primitive entity pooling system. My script has all text entities already spawned on the map from the very start in a closed-off room, and they get teleported into the area and back when needed.