AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   collision between two entitys? (https://forums.alliedmods.net/showthread.php?t=98187)

Hayer 07-23-2009 11:15

collision between two entitys?
 
Hi!

How do I detect if two entities collide?

Arkshine 07-23-2009 11:18

Re: collision between two entitys?
 
Use register_touch() with the entities classname.

xPaw 07-23-2009 14:03

Re: collision between two entitys?
 
If you want simple function, you can use this

PHP Code:

stock IsCollidingiEntity1iEntity2 ) {
    new 
Float:AbsMin1], Float:AbsMin2], Float:AbsMax1], Float:AbsMax2];
    
    
peviEntity1pev_absminAbsMin1 );
    
peviEntity1pev_absmaxAbsMax1 );
    
peviEntity2pev_absminAbsMin2 );
    
peviEntity2pev_absmaxAbsMax2 );
    
    if( 
AbsMin1] > AbsMax2] ||
        
AbsMin1] > AbsMax2] ||
        
AbsMin1] > AbsMax2] ||
        
AbsMax1] < AbsMin2] ||
        
AbsMax1] < AbsMin2] ||
        
AbsMax1] < AbsMin2] )
        return 
0;
    
    return 
1;



Arkshine 07-23-2009 14:16

Re: collision between two entitys?
 
But this function you would need to call very often, better to use register_touch and let the engine doing its job.

Hayer 07-23-2009 14:46

Re: collision between two entitys?
 
what if I have two entities with the same classname? Should I change them or is it some other way to find out if the player touches Entity1 or Entity2?

Rightnow, both of them have their classname set to "medicpack" but Entity1 is supposed to heal more then Entity2 so guess I should rename them "medicpack_large","medicpack_small" etc?

SchlumPF* 07-23-2009 15:25

Re: collision between two entitys?
 
either that use a var or w/e to check the amount of healing.


All times are GMT -4. The time now is 18:21.

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