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

2D velocity vector and sloped surfaces


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-03-2016 , 22:41   2D velocity vector and sloped surfaces
Reply With Quote #1

Hey there,
Can someone tell me please, how to allow entity to sliding on the sloped surfaces?
Entity just stopped when collide with sloped surface and I can't fix this.

Quote:
solid: SOLID_BBOX
movietype: MOVETYPE_PUSHSTEP
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 07:33   Re: 2D velocity vector and sloped surfaces
Reply With Quote #2

Mhm, so you want to be able to push the entity down a ramp or up a ramp ?

Please tell me more details about what you are trying to do
__________________

Last edited by Depresie; 10-04-2016 at 07:36.
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 07:56   Re: 2D velocity vector and sloped surfaces
Reply With Quote #3

Up a ramp. No problem when entity is on ramp and sometimes entity can move to the ramp, but more often entity just stuck at ramp start.
Attached Thumbnails
Click image for larger version

Name:	2151581855218.png
Views:	73
Size:	2.3 KB
ID:	157714  
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 08:03.
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 08:25   Re: 2D velocity vector and sloped surfaces
Reply With Quote #4

Now this is a little tricky, is it pushed by a player? or is a self moving entity ?
__________________
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 08:32   Re: 2D velocity vector and sloped surfaces
Reply With Quote #5

Quote:
Originally Posted by Depresie View Post
Now this is a little tricky, is it pushed by a player? or is a self moving entity ?
Self moving (xy velocity vector);
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 08:34   Re: 2D velocity vector and sloped surfaces
Reply With Quote #6

Oh.. in this case, i need more info about the script to find a solution.. post here the script to take a look
__________________

Last edited by Depresie; 10-04-2016 at 08:35.
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 08:43   Re: 2D velocity vector and sloped surfaces
Reply With Quote #7

Depresie,
What info do you need? It's just spawned entity with velocity.

Spawn
PHP Code:
new ent engfunc(EngFunc_CreateNamedEntityg_allocClassname);
dllfunc(DLLFunc_Spawnent);
engfunc(EngFunc_SetSizeentFloat{16.016.032.0}, Float{-16.0, -16.00.0});
engfunc(EngFunc_SetOriginentfOrigin);

engfunc(EngFunc_DropToFloorent);

set_pev(entpev_solidSOLID_BBOX);
set_pev(entpev_movetypeMOVETYPE_PUSHSTEP);
set_pev(entpev_modelindexg_mdlTest); 
Move
PHP Code:
static Float:fOrigin1[3];
pev(entpev_originfOrigin);

static 
Float:fOrigin2[3];
pev(idpev_originfOrigin);

static 
Float:fDirection[3];
xs_vec_sub(fOrigin1fOrigin2fDirection);
fDirection[2] = 0.0;

xs_vec_mul_scalar(fDirection32.0fDirection);

set_pev(entpev_velocityfDirection); 
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 08:45.
Hedgehog Fog is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 08:56   Re: 2D velocity vector and sloped surfaces
Reply With Quote #8

Ok, for example:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <xs>

new g_testEnt;
new 
g_allocClassname;
new 
g_mdlTest;

public 
plugin_init()
{
    
register_plugin("""""");

    
register_clcmd("ent_spawn""clcmd_spawn");
    
register_clcmd("ent_move""clcmd_move");
    
    
g_allocClassname engfunc(EngFunc_AllocString"info_target");
}

public 
plugin_precache()
{
    
g_mdlTest precache_model("models/w_c4.mdl");
}

public 
clcmd_spawn(id)
{
    if (
g_testEnt 0) {
        
engfunc(EngFunc_RemoveEntityg_testEnt);
    }

    static 
Float:fTarget[3];
    
GetAimOrigin(idfTarget);
    
    
g_testEnt engfunc(EngFunc_CreateNamedEntityg_allocClassname);
    
dllfunc(DLLFunc_Spawng_testEnt);
    
    
engfunc(EngFunc_SetSizeg_testEntFloat:{-16.0, -16.00.0}, Float:{16.016.032.0});
    
engfunc(EngFunc_SetOriging_testEntfTarget);
    
    
set_pev(g_testEntpev_solidSOLID_BBOX);
    
set_pev(g_testEntpev_movetypeMOVETYPE_PUSHSTEP);
    
set_pev(g_testEntpev_modelindexg_mdlTest);
}

public 
clcmd_move(id)
{
    if (
g_testEnt <= 0) {
        return;
    }
    
    static 
Float:fTarget[3];
    
GetAimOrigin(idfTarget);
    
    static 
Float:fEntOrigin[3];
    
pev(g_testEntpev_originfEntOrigin);
    static 
Float:fDirection[3];
    
xs_vec_sub(fTargetfEntOriginfDirection);
    
xs_vec_normalize(fDirectionfDirection);
    
fDirection[2] = 0.0;
    
    
xs_vec_mul_scalar(fDirection128.0fDirection);
    
    static 
Float:fVelocity[3];
    
pev(g_testEntpev_velocityfVelocity);
    
fDirection[2] = fVelocity[2];
    
    
set_pev(g_testEntpev_velocityfDirection);
}

stock GetAimOrigin(idFloat:fOut[3], Float:fDistance 1024.0)
{
    static 
Float:fStart[3];    
    
pev(idpev_originfStart);
    
    static 
Float:view_ofs[3];
    
pev(idpev_view_ofsview_ofs);
    
    
xs_vec_add(fStartview_ofsfStart);

    static 
Float:fEnd[3];
    
pev(idpev_v_anglefEnd);
    
engfunc(EngFunc_MakeVectorsfEnd);
    
global_get(glb_v_forwardfEnd);
    
xs_vec_mul_scalar(fEndfDistancefEnd);
    
xs_vec_add(fStartfEndfEnd);

    
engfunc(EngFunc_TraceLinefStartfEnd0id0);
    
get_tr2(0TR_vecEndPosfOut);

__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 09:32.
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 09:15   Re: 2D velocity vector and sloped surfaces
Reply With Quote #9

Well, you gave me an example, so i will give you the solution on the example you gave me, to give you the right solution i need to know what triggers the moving of the entity and when, so as i doubt the command is the actual trigger it's better go give you an example solution

After the moving function is triggered, at the end, call another function to check if it moved by checking initial origin of the entity ( before moving ) with the new origin after moving, if the origins are equal it means it couldn't move

If it couldn't move, call again the moving function, but also add a little bit velocity on the z vector, so it can hop over the start of the ramp

Or you can just send directly a little bit velocity on the z vector, in the moving function, to avoid getting hanged on the start of the ramp, but this depends on what you really want to do, as i said i can't give you the right solution unless i know exactly how you want your entity to behave
__________________

Last edited by Depresie; 10-04-2016 at 09:20.
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 09:28   Re: 2D velocity vector and sloped surfaces
Reply With Quote #10

Example fixed.

Depresie
I can't change Z velocity and must set previous Z value all time, because it's reserved for a gravity.

Velocity sets during Think call, here is fast and bad solution:
Add 0.1 to Z velocity before think and substract 0.1 from Z velocity after.

But I have no way to use this solution, because I limited in the number of hooks.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 09:41.
Hedgehog Fog is offline
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 13:22.


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