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

collision between two entitys?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hayer
Junior Member
Join Date: Aug 2006
Old 07-23-2009 , 11:15   collision between two entitys?
Reply With Quote #1

Hi!

How do I detect if two entities collide?
Hayer is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-23-2009 , 11:18   Re: collision between two entitys?
Reply With Quote #2

Use register_touch() with the entities classname.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-23-2009 , 14:03   Re: collision between two entitys?
Reply With Quote #3

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;

__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-23-2009 , 14:16   Re: collision between two entitys?
Reply With Quote #4

But this function you would need to call very often, better to use register_touch and let the engine doing its job.
__________________
Arkshine is offline
Hayer
Junior Member
Join Date: Aug 2006
Old 07-23-2009 , 14:46   Re: collision between two entitys?
Reply With Quote #5

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?
Hayer is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 07-23-2009 , 15:25   Re: collision between two entitys?
Reply With Quote #6

either that use a var or w/e to check the amount of healing.
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
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 06:38.


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