Raised This Month: $ Target: $400
 0% 

movetype_follow offset


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-19-2019 , 10:34   movetype_follow offset
Reply With Quote #1

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; }
__________________









Last edited by CrazY.; 10-19-2019 at 10:34.
CrazY. is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode