Rules FAQ Members List Search Register Login

 Raised This Month: \$ Target: \$400 0%

Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
 03-24-2020 , 18:22   Calculate velocity to point X #1 Hi, So I'm looking for a way to calculate how much velocity it would require to give to the entity, to reach point X (whereas point X is player aiming origin). I'm using velocity_by_aim and MOVETYPE_TOSS (MOVETYPE_TOSS so gravity can pull the entity down, making it more realistic). An example in real life: Calculating how much force it would require to throw a rock so the rock can fall on point X. __________________ No longer active, farewell, good times. • Elite Admin System (Most advanced admin system) • Visitor Counter (Track server visitors) • Reports System (Keep track of your players suggestions/reports) Last edited by edon1337; 03-24-2020 at 18:22.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
 03-25-2020 , 04:02   Re: Calculate velocity to point X #2 destOrigin - sourceOrigin + normalize + multiply by speed. P.S: force and velocity are 2 different things. __________________ Last edited by HamletEagle; 03-25-2020 at 04:04.
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
03-27-2020 , 11:57   Re: Calculate velocity to point X
#3

Quote:
 Originally Posted by HamletEagle force and velocity are 2 different things.
You apply force to an object, it's velocity changes, I'm aware, but in CS you can't apply force to objects, you can only change their velocity. Thanks for the answer, I'll try it.
__________________

Last edited by edon1337; 03-27-2020 at 11:57.
LostMind
New Member
Join Date: Mar 2020
04-05-2020 , 10:41   Re: Calculate velocity to point X
#4

Quote:
 Originally Posted by HamletEagle destOrigin - sourceOrigin + normalize + multiply by speed. P.S: force and velocity are 2 different things.
Hi, so i wanted to say that i requested doni to post this for me and maybe i would get some help.
But we didn't solve this problem.
Code:
```					new Float:fPlayerOrigin[3], iAimOrigin[3], Float:fAngle[ 3 ];
get_user_origin( id, iAimOrigin, 3 );

pev( id, pev_origin, fPlayerOrigin );
pev( id, pev_angles, fAngle );

new iEnt = create_entity( "info_target" );

entity_set_string( iEnt, EV_SZ_classname, "_entity" );
entity_set_model( iEnt, spit_model );
entity_set_size( iEnt, Float:{ -1.5, -1.5, -1.5 }, Float:{ 1.5, 1.5, 1.5 } );
entity_set_origin( iEnt, fPlayerOrigin );
entity_set_vector( iEnt, EV_VEC_angles, fAngle );
entity_set_int( iEnt, EV_INT_solid, 2 );
entity_set_int( iEnt, EV_INT_rendermode, 5 );
entity_set_float( iEnt, EV_FL_renderamt, 200.0 );
entity_set_float( iEnt, EV_FL_scale, 1.00 );
entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_TOSS );
entity_set_float(iEnt, EV_FL_gravity, 1.0)
entity_set_edict( iEnt, EV_ENT_owner, id );

iAimOrigin[ 0 ] -= fPlayerOrigin[ 0 ];
iAimOrigin[ 1 ] -= fPlayerOrigin[ 1 ];
iAimOrigin[ 2 ] -= fPlayerOrigin[ 2 ];

new Float:fNormalizedVec[ 3 ], Float:fFinalVec[ 3 ];
xs_vec_normalize( Float:iAimOrigin, fNormalizedVec );
xs_vec_mul_scalar( fNormalizedVec, float(pev( iEnt, pev_maxspeed )), fFinalVec )```
Here it is the code. If you have time. Can you see where is the problem? And also, the entity goes down only.

Last edited by LostMind; 04-05-2020 at 10:42.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
 04-06-2020 , 04:11   Re: Calculate velocity to point X #5 1.Convert iAimOrigin to float using IVecFVec. 2.float(pev(lev_maxspeed)) that's not the right way to retrieve floats using pev(). Pass the float variable as the 3rd param. __________________ Last edited by HamletEagle; 04-06-2020 at 04:12.
LostMind
New Member
Join Date: Mar 2020
04-13-2020 , 14:07   Re: Calculate velocity to point X
#6

Quote:
 Originally Posted by HamletEagle 1.Convert iAimOrigin to float using IVecFVec. 2.float(pev(lev_maxspeed)) that's not the right way to retrieve floats using pev(). Pass the float variable as the 3rd param.
I'm so sorry but i already tried everything i could and searched a lot. But the entity goes only down.
I don't know what's the matter.
Code:
``` 					new Float:fPlayerOrigin[3], Float:fAngle[3 ], iAimOrigin[3], Float:iAimOrigin1[3]
get_user_origin(id, iAimOrigin, 3)
IVecFVec(iAimOrigin, iAimOrigin1)

entity_get_vector(id, EV_VEC_origin , fPlayerOrigin)
entity_get_vector(id, EV_VEC_v_angle, fAngle)
new iEnt = create_entity( "info_target" );

entity_set_string( iEnt, EV_SZ_classname, "_entity" );
entity_set_model( iEnt, spit_model );
entity_set_size( iEnt, Float:{ -1.5, -1.5, -1.5 }, Float:{ 1.5, 1.5, 1.5 } );
entity_set_origin( iEnt, fPlayerOrigin );
entity_set_vector( iEnt, EV_VEC_angles, fAngle );
entity_set_int( iEnt, EV_INT_solid, 2 );
entity_set_int( iEnt, EV_INT_rendermode, 5 );
entity_set_float( iEnt, EV_FL_renderamt, 200.0 );
entity_set_float( iEnt, EV_FL_scale, 1.00 );
entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_TOSS );
entity_set_float(iEnt, EV_FL_gravity, 1.0)
entity_set_edict( iEnt, EV_ENT_owner, id );

iAimOrigin1[ 0 ] -= fPlayerOrigin[ 0 ];
iAimOrigin1[ 1 ] -= fPlayerOrigin[ 1 ];
iAimOrigin1[ 2 ] -= fPlayerOrigin[ 2 ];

new Float:fNormalizedVec[ 3 ], Float:fFinalVec[ 3 ]
xs_vec_normalize( iAimOrigin1, fNormalizedVec )
xs_vec_mul_scalar( fNormalizedVec, 10.0, fFinalVec )```

Last edited by LostMind; 04-13-2020 at 14:09.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 10:25.

 DMCA - Archive - Top