Raised This Month: $51 Target: $400
 12% 

movetype_follow offset


Post New Thread Reply   
 
Thread Tools Display Modes
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
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2019 , 11:22   Re: movetype_follow offset
Reply With Quote #2

have you tried giving it a size?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-20-2019 , 09:29   Re: movetype_follow offset
Reply With Quote #3

Yes, still not working.
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-20-2019 , 11:00   Re: movetype_follow offset
Reply With Quote #4

Then you need to change the movetype and achieve it through think

I'm not sure movetype_follow will work with sprites

Or try editing the sprite and give it height.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-23-2019 at 10:38.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 10-20-2019, 12:58
Smilex_Gamer
This message has been deleted by Smilex_Gamer. Reason: Nevermind
iNvectus
Member
Join Date: Sep 2014
Location: Bulgaria
Old 10-23-2019 , 02:44   Re: movetype_follow offset
Reply With Quote #5

It is not working, because you cannot change the Z origin of a movetype. You can spawn an info_target and set the model to the sprite, then set the origin to the origin +/- the difference with entity_set_model and entity_set_origin then set EV_INT_movetype to MOVETYPE_FOLLOW.

This way it will probably work, but if you just want to have a sprite above the player's head, instead I'd rather use TE_PLAYERATTACHMENT.

PHP Code:
write_byte(TE_PLAYERATTACHMENT)
write_byte(entity index of player)
write_coord(vertical offset) (attachment origin.player origin.vertical offset)
write_short(model index)
write_short(life 10 
https://www.amxmodx.org/api/message_const
iNvectus is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-23-2019 , 08:56   Re: movetype_follow offset
Reply With Quote #6

It doesn't work, I guess I've to do what natsheh said, give height to sprite.
That message would work but I need to scale the sprite, that's why I'm using entities.
__________________








CrazY. is offline
iNvectus
Member
Join Date: Sep 2014
Location: Bulgaria
Old 10-24-2019 , 01:19   Re: movetype_follow offset
Reply With Quote #7

I guess this is what you are looking for https://forums.alliedmods.net/showthread.php?t=181306

Here it is done this way:

PHP Code:
public create_rank_entityindex )
{
    
gi_PlayerRankindex ] = engfunc EngFunc_CreateNamedEntityengfunc EngFunc_AllocString"env_sprite" ) )
    
    if( 
pev_validgi_PlayerRankindex ] ) )
    {
        
set_pevgi_PlayerRankindex ], pev_solidSOLID_NOT )
        
set_pevgi_PlayerRankindex ], pev_iuser2index )
        
set_pevgi_PlayerRankindex ], pev_iuser1pevgi_PlayerRankindex ], pev_owner ) )
        
set_pevgi_PlayerRankindex ], pev_scale0.5 )
        
engfuncEngFunc_SetModelgi_PlayerRankindex ], ranks_model )
        
set_pevgi_PlayerRankindex ], pev_renderfxkRenderTransAlpha )
        
set_pevgi_PlayerRankindex ], pev_renderamt0.0 )
        
set_pevgi_PlayerRankindex ], pev_frame0.0 )
    }


Last edited by iNvectus; 10-24-2019 at 01:20.
iNvectus is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-24-2019 , 10:15   Re: movetype_follow offset
Reply With Quote #8

@iNvectus please read carefully what he requested, in post #5 what have you said clearly doesn't make any sense in the thread.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-24-2019 at 10:16.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



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 01:30.


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