I created an entity that follows the player. I want to add an offset so it stay above of player's head. According to the "movement follow" code, all I would need to do is add the offset to the entity's v_angle, but it's not working.
Code:
// Just copy angles and origin of parent
void SV_Physics_Follow(edict_t *ent)
{
// regular thinking
if (!SV_RunThink(ent))
return;
edict_t *parent = ent->v.aiment;
if (!ent->v.aiment)
{
Con_DPrintf("%s movetype FOLLOW with NULL aiment\n", &pr_strings[ent->v.classname]);
ent->v.movetype = MOVETYPE_NONE;
return;
}
VectorAdd(parent->v.origin, ent->v.v_angle, ent->v.origin);
VectorCopy(parent->v.angles, ent->v.angles);
SV_LinkEdict(ent, TRUE);
}
Here's my code
Code:
new g_voiceicon[MAX_PLAYERS+1];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
RegisterHamPlayer(Ham_Spawn, "Player_Spawn_Post", 1);
}
public plugin_precache()
{
precache_model("sprites/voiceicon.spr");
}
public client_disconnected(id)
{
if (is_valid_ent(g_voiceicon[id]))
remove_entity(g_voiceicon[id]);
}
public Player_Spawn_Post(id)
{
if (!is_user_alive(id) || !(1 <= get_user_team(id) <= 2))
return;
if (is_valid_ent(g_voiceicon[id]))
return;
new ent = create_entity("env_sprite");
entity_set_model(ent, "sprites/voiceicon.spr");
entity_set_int(ent, EV_INT_renderfx, kRenderFxNoDissipation);
entity_set_int(ent, EV_INT_rendermode, kRenderTransAdd);
entity_set_float(ent, EV_FL_renderamt, 255.0);
set_pev(ent, pev_v_angle, Float:{75.0, 75.0, 75.0});
entity_set_int(ent, EV_INT_movetype, MOVETYPE_FOLLOW);
entity_set_edict(ent, EV_ENT_aiment, id);
//entity_set_float(ent, EV_FL_scale, 0.2);
g_voiceicon[id] = ent;
}
__________________