AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity collision size (https://forums.alliedmods.net/showthread.php?t=278492)

loko10 02-01-2016 18:45

Entity collision size
 
Hello. I've been having a problem that I can't solve... The entity's collision size with other entities is fine, but the collision with the world is not. I'll show two different images that will let you understand my problem.

The green line is the "good" collision size. The red line is the "bad" one, but it only happens with a corner of the entity as you can see. Players and other entities collide with the green size, while world and brushes with the red one. Sorry for my bad english, hope you can help me :).

PD: I've been giving velocity to the entity so it can move around, if that helps...



PHP Code:

CreateBottle( const Float:flOrigin] = { 0.00.00.0 }, const Float:flAngles] = { 0.00.00.0 } )
{
    static 
iEntiEnt create_entity"info_target" );
    
    if( !
iEnt ) return 0;
    
    
entity_set_stringiEntEV_SZ_classnameg_szBottleClassname );
    
entity_set_modeliEntg_szBottleModel );
    
    
entity_set_sizeiEntFloat:{-8.0,-8.0,0.0}, Float:{8.0,8.0,16.0} );
    
    
entity_set_intiEntEV_INT_movetypeMOVETYPE_PUSHSTEP );
    
entity_set_intiEntEV_INT_solidSOLID_BBOX );
    
    
entity_set_originiEntflOrigin );
    
    
entity_set_floatiEntEV_FL_takedamage1.0 );
    
entity_set_floatiEntEV_FL_health100.0 );
    
    
entity_set_vectoriEntEV_VEC_anglesflAngles );
    
    return 
iEnt;



georgik57 02-03-2016 11:38

Re: Entity collision size
 
Quote:

Originally Posted by loko10 (Post 2389209)
PHP Code:

    entity_set_sizeiEntFloat:{-8.0,-8.0,0.0}, Float:{8.0,8.0,16.0} ); 


That's probably why. Don't mess with size if you don't know what you're doing.

loko10 02-03-2016 13:33

Re: Entity collision size
 
Quote:

Originally Posted by georgik57 (Post 2389625)
That's probably why. Don't mess with size if you don't know what you're doing.

You aren't helping at all. The size is fine when other entities collide with it. Re-read the thread.

georgik57 02-03-2016 14:35

Re: Entity collision size
 
Quote:

Originally Posted by loko10 (Post 2389659)
You aren't helping at all. The size is fine when other entities collide with it. Re-read the thread.

Try without it.

loko10 02-03-2016 15:22

Re: Entity collision size
 
Quote:

Originally Posted by georgik57 (Post 2389685)
Try without it.

Without size, the entity would not collide with players nor with the world...

I guess you are not understanding. The player collides with the entity's real size ( the green one ) and the world collides with some strange size ( the red one ). I've been searching a lot but I can't find anything related to my problem.

I've tried changing the way I create the entity ( movetype or solid first, origin at the end, etc ) and it didn't work.

georgik57 02-04-2016 07:33

Re: Entity collision size
 
I think I've come across your problem before. Try setting the solid type before the model.
Also, the entity will collide with everything even without the size set as long as it's solid.

loko10 02-04-2016 16:26

Re: Entity collision size
 
Quote:

Originally Posted by georgik57 (Post 2389898)
I think I've come across your problem before. Try setting the solid type before the model.
Also, the entity will collide with everything even without the size set as long as it's solid.

Well, without size it actually collides but only the center of the entity. And I did set the solid type before the model without results :/ Any other idea?

I'll give more examples. I'll draw the size of the entity with a function, and print it's information.

PHP Code:

DrawBox( const iEnt, const iDelay )
{
    static 
Float:flOrigin], Float:flMins], Float:flMaxs];
    
    
entity_get_vectoriEntEV_VEC_originflOrigin );
    
    
entity_get_vectoriEntEV_VEC_minsflMins );
    
entity_get_vectoriEntEV_VEC_maxsflMaxs );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_BOX );
    
engfuncEngFunc_WriteCoordflOrigin] + flMins] );
    
engfuncEngFunc_WriteCoordflOrigin] + flMins] );
    
engfuncEngFunc_WriteCoordflOrigin] + flMins] );
    
engfuncEngFunc_WriteCoordflOrigin] + flMaxs] );
    
engfuncEngFunc_WriteCoordflOrigin] + flMaxs] );
    
engfuncEngFunc_WriteCoordflOrigin] + flMaxs] );
    
write_shortiDelay );
    
write_byte250 );
    
write_byte);
    
write_byte);
    
message_end( );


Results

Spoiler


As you can see, the entity should have fallen but it didn't.

georgik57 02-04-2016 19:21

Re: Entity collision size
 
Try other movetypes.
Quote:

#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision)
As far as I know, BSP model is brush(map) model. Your model is studio.

wickedd 02-04-2016 19:32

Re: Entity collision size
 
Quote:

Originally Posted by loko10 (Post 2390116)
As you can see, the entity should have fallen but it didn't.

drop_to_floor()

loko10 02-04-2016 19:39

Re: Entity collision size
 
Quote:

Originally Posted by georgik57 (Post 2390164)
Try other movetypes.

As far as I know, BSP model is brush(map) model. Your model is studio.

I've tried every movetype with gravity ( bounce, toss, etc ). I'll try them again but I guess it will give the same result :cry:

@wickedd: ? it should have fallen by gravity.

EDIT: No results, I tested with MOVETYPE_BOUNCE, MOVETYPE_TOSS, MOVETYPE_BOUNCEMISSILE, MOVETYPE_FLY, MOVETYPE_FLYMISSILE. I'm pretty sure server would crash with MOVETYPE_PUSH, and MOVETYPE_STEP makes the model disappear.

I've been using MOVETYPE_PUSHSTEP because its the one that gives me the best results :/

This is the code I actually have. If you see something wrong please tell me. Players collide with the "red box" in the last picture I uploaded, but for some reasons the size is a bit bigger when it collides with the world.

PHP Code:

CreateProp( const iPropFloat:flOrigin] = { 0.00.00.0 }, const Float:flAngles] = { 0.00.00.0 } )
{
    if( 
g_iTotalProps <= iProp ) return 0;
    
    static 
iEntFloat:flMaxs], Float:flMins];
    
    do
    {
        
iEnt create_entity"info_target" );
    }
    while ( !
is_valid_entiEnt ) );
    
    
entity_set_originiEntflOrigin );
    
    
entity_set_stringiEntEV_SZ_classnameg_szPropClassname );
    
    
entity_set_intiEntEV_INT_solidSOLID_BBOX );
    
entity_set_intiEntEV_INT_movetypeMOVETYPE_PUSHSTEP );
    
    
entity_set_modeliEntg_ePropsiProp ][ Prop_Model ] );
    
    
flMins] = g_ePropsiProp ][ Prop_Size ][ ],
    
flMins] = g_ePropsiProp ][ Prop_Size ][ ];
    
flMins] = g_ePropsiProp ][ Prop_Size ][ ];
    
flMaxs] = g_ePropsiProp ][ Prop_Size ][ ];
    
flMaxs] = g_ePropsiProp ][ Prop_Size ][ ];
    
flMaxs] = g_ePropsiProp ][ Prop_Size ][ ];
    
    
entity_set_sizeiEntflMinsflMaxs );
    
    
entity_set_vectoriEntEV_VEC_anglesflAngles );
    
    
drop_to_flooriEnt );
    
    return 
iEnt;




All times are GMT -4. The time now is 09:20.

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