As far as I know, all the functions listed on the wiki that behind with ENT: can only be used with scripted entities, but I was wondering if there’s any way to hook this function to a non-scripted entity, such as the hl2 jeep.
Now rate me dumb, but i think you might be able to hook it???
You can try to use the hook ShouldCollide and return nothing.
What Kialtia said.
For instance, if you wanted vehicles to not collide with each other in a racing gamemode you’d overwrite the ShouldCollide function in your gamemode to something like…
function GM:ShouldCollide( ent1, ent2 )
if( ent1:IsVehicle() && ent2:IsVehicle() ) then return false end return true
Yeah but i’m trying to get which 2 entities collided with each other so I can run them through some if statements. I tried using GM:OnTakeDamage or wherever it’s called, but I need it to work even when the entities collide without damaging each other.
That function I mentioned gets called just before any two entities collide and gives you both entities as it’s two arguments.
From there you can do whatever you like with them.
if you return true then the collision is allowed to go ahead, if you return false then it won’t.
Actually that works pretty well, thanks!
For some reason it seems to be getting called every frame, regardless of whether two entities are colliding or not? Any idea why?
No, but that might change when you post the code you’re using.
Is it so hard to understand that ShouldCollide just polls to to check if two entities should collide and is not called only when two props are going to collide?
So what should I use then?
Explain your problem more clearly. When do you want stuff to happen? Do you mean you want to detect when 2 entities do collide with one another at high speed and not when they’re at rest?
Basically I want to detect every time they touch, including direct hits, slight glances, and sexually suggestive rubs.
anything else I can use?
And you want to do what when they touch? Do you want to differentiate between direct hits, glances, and suggestive rubs? Do you want people to gain/lose points? From what I understand, that collision function is called every time two entities are about to collide. You can return true or false as you see fit, but you can also have that function do other things before returning a value.
It’s called every frame. I don’t need to differentiate between hits, I just need to have something which can give me the two entities which collided. What I do after is just a bunch of comparisons with the entites and some tables.
Can anyone help with this please?
Well, you could try to overload whatever the built in function was on those entities, I don’t remember off the top of my head. (This is a bad idea, btw)