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

Horizontal Velocity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chrissy
Member
Join Date: May 2013
Old 11-13-2019 , 17:06   Horizontal Velocity
Reply With Quote #1

I have a system that is supposed to prevent players from entering a trigger's bounds. Do this with:

Code:
float vVec[3];
GetEntPropVector(iClient, Prop_Data, "m_vecAbsVelocity", vVec);
NormalizeVector(vVec, vVec);
ScaleVector(vVec, 300.0);
NegateVector(vVec);
							
TeleportEntity(iClient, NULL_VECTOR, NULL_VECTOR, vVec);
However, I've found a flaw so that if a player enters from an acute angles and hits a ceiling they're pushed into the trigger. My thinking was that I need to set the x,z axis differently so that if the angle is acute they are always going to be pushed horizontally backwards 300 units.

I made a little picture to help visualise:


A thousand thanks.
Chrissy is offline
Balimbanana
Member
Join Date: Jan 2017
Old 11-13-2019 , 21:54   Re: Horizontal Velocity
Reply With Quote #2

Could potentially just ignore Z velocity all together:
Code:
float vVec[3];
GetEntPropVector(iClient, Prop_Data, "m_vecAbsVelocity", vVec);
vVec[2] = 0.0;
NormalizeVector(vVec, vVec);
ScaleVector(vVec, 300.0);
NegateVector(vVec);
							
TeleportEntity(iClient, NULL_VECTOR, NULL_VECTOR, vVec);
Or check if vVec[2] is negative (falling).

Or if you want the full negative pushback, maybe set a cap on negative vVec[2]

Last edited by Balimbanana; 11-13-2019 at 21:56.
Balimbanana is offline
Chrissy
Member
Join Date: May 2013
Old 11-14-2019 , 16:26   Re: Horizontal Velocity
Reply With Quote #3

Quote:
Originally Posted by Balimbanana View Post
Could potentially just ignore Z velocity all together:
Code:
float vVec[3];
GetEntPropVector(iClient, Prop_Data, "m_vecAbsVelocity", vVec);
vVec[2] = 0.0;
NormalizeVector(vVec, vVec);
ScaleVector(vVec, 300.0);
NegateVector(vVec);
							
TeleportEntity(iClient, NULL_VECTOR, NULL_VECTOR, vVec);
Or check if vVec[2] is negative (falling).

Or if you want the full negative pushback, maybe set a cap on negative vVec[2]
Thanks for the reply. I tried these but they Im sorry to say they don't resolve the issue. For some reason I can figure out, if the players jumps into it (falling) and is then pushing on the W key, they seems to squeeze past the bounds.

Perhaps someone has another method of preventing a player from entering a bounds that doesn't involve "repelling" the player.

Thanks
Chrissy is offline
Balimbanana
Member
Join Date: Jan 2017
Old 11-14-2019 , 20:55   Re: Horizontal Velocity
Reply With Quote #4

If you are looking to make it solid, you could potentially just use a brush:
Code:
int brush = CreateEntityByName("func_brush");
if (brush != -1)
{
	DispatchKeyValue(brush,"rendermode","10");
	//Toggleable
	DispatchKeyValue(brush,"solidity","0");
	DispatchKeyValue(brush,"solidbsp","1");
	DispatchKeyValue(brush,"startdisabled","0");
	//If you have the m_ModelName of the volume you wish to block, then you can set it here and skip the SetEntityModel and vMins and vMaxs.
	//DispatchKeyValue(brush,"model",ModelName);
	//If it is just slightly too small, then you will need to get the min maxs and ScaleVector(1.05,vMins) and vMaxs and set it below.
	float targetpos[3];
	float targetangs[3];
	//Here you could set a static position, or get the position of the volume you want to block.
	TeleportEntity(brush,targetpos,targetangs,NULL_VECTOR);
	DispatchSpawn(brush);
	ActivateEntity(brush);
	//The model in particular doesn't really matter, it is just to set the bounds configuration.
	//It would be good to note, while the bounds of this model doesn't affect the player clip, it will affect NPCs and some props by the bounds of the specified model.
	if (!IsModelPrecached("models/somemodel.mdl")) PrecacheModel("models/somemodel.mdl",true);
	SetEntityModel(brush,"models/somemodel.mdl");
	int effect = GetEntProp(brush,Prop_Send,"m_fEffects");
	effect |= 32;
	SetEntProp(brush,Prop_Send,"m_fEffects",effect);
	float vMins[3];
	float vMaxs[3];
	//You can either set a static value here,
	//or get the min max of the volume you are trying to block.
	//There is also a potential that if you are blocking entering a map based trigger volume, then you can get its model and set it then skip the minmaxs.
	if (HasEntProp(brush,Prop_Send,"m_vecMins")) SetEntPropVector(brush,Prop_Send,"m_vecMins",vMins);
	if (HasEntProp(brush,Prop_Send,"m_vecMaxs")) SetEntPropVector(brush,Prop_Send,"m_vecMaxs",vMaxs);
}

Last edited by Balimbanana; 11-14-2019 at 21:03.
Balimbanana 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 22:27.


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