Raised This Month: $32 Target: $400
 8% 

Dropping models to floor.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jay7
Senior Member
Join Date: Jun 2004
Old 05-23-2019 , 10:00   Dropping models to floor.
Reply With Quote #1

I have an issue with this code where the model will only drop to the floor if the player is grounded at death or at least near the ground. Otherwise the model will just stay stuck mid-air if the player dies in the air. Can anyone help?

Code:
set_flag_state(flag_ta, flag_state, owner = 0) 
{
	g_flag_state[flag_ta] = flag_state
	g_flag_owner[flag_ta] = owner
	new ent = g_flag_ent[flag_ta]

	switch (flag_state) 
	{
		case state_dropped: 
		{
			set_pev(ent, pev_solid, SOLID_TRIGGER)
			set_pev(ent, pev_movetype, MOVETYPE_TOSS)
			set_pev(ent, pev_sequence, SEQ_DROPPED)
			engfunc(EngFunc_DropToFloor, ent)
		}
	}
	set_pev(ent, pev_aiment, owner)
	set_pev(ent, pev_owner, owner)
}
jay7 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-23-2019 , 13:12   Re: Dropping models to floor.
Reply With Quote #2

Try getting the height that the player is, use fOrigin[2] -= distanceToGround and then set the new origin, may be a newbie way to fix it.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-23-2019 at 13:12.
EFFx is offline
Old 05-23-2019, 14:47
redivcram
This message has been deleted by redivcram. Reason: brainfart
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-23-2019 , 15:40   Re: Dropping models to floor.
Reply With Quote #3

Code:
#include <xs> ... new Float:origin[3], Float:endpos[3]; pev(id, pev_origin, origin); // Replace 10.0 for the distance from player to ground that you want xs_vec_sub(origin, Float:{0.0, 0.0, 10.0}, endpos); new tr = create_tr2(); engfunc(EngFunc_TraceLine, origin, endpos, IGNORE_MONSTERS, id, tr); new Float:fraction; get_tr2(tr, TR_flFraction, fraction); if (fraction == 1.0) {     // set_flag_state -> state_fly } else {     // set_flag_state -> state_dropped } free_tr2(tr); ... switch (flag_state) {     case state_dropped:     {         set_pev(ent, pev_solid, SOLID_TRIGGER)         set_pev(ent, pev_movetype, MOVETYPE_TOSS)         set_pev(ent, pev_sequence, SEQ_DROPPED)         engfunc(EngFunc_DropToFloor, ent)     }     case state_fly:     {         set_pev(ent, pev_solid, SOLID_TRIGGER)         set_pev(ent, pev_movetype, MOVETYPE_FLY)     } }
__________________









Last edited by CrazY.; 05-23-2019 at 15:41.
CrazY. is offline
jay7
Senior Member
Join Date: Jun 2004
Old 05-24-2019 , 06:20   Re: Dropping models to floor.
Reply With Quote #4

Thank you guys both for pointing that out and providing an example!
jay7 is offline
Reply


Thread Tools
Display Modes

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:09.


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