Entity has collided?

Is there something similar to [ENT.Touch

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=ENT.Touch) but outside of entity’s code, searched for a global hook, couldn’t find it. This time I need this for a class “prop_vehicle*”

This time I need to simulate a collision damage to the vehicle and the vehicle doesn’t get velocity damage, player does tho, could transmit the damage from the player to the vehicle, but I need the vehicle to take velocity damage when with nil driver.

How am I suppose to run it “outside of entity’s code”?

I tried to do this once before, but could never figure it out either. :\

You could do **[Gamemode.ShouldCollide

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.ShouldCollide)** and check if the class is a “prop_vehicle*”.

ShouldCollide does not work for me, tried to add it via hook, fails.

ShouldCollide is not meant for this purpose, it’s only called (someone correct my if I’m wrong) once when the AABBs (Axis Aligned Bounding Box) of 2 object intersect (it will call again if they separate and then intersect again)

You will probably have to just make your own entity.

Cant recreate the entity’s so I guess this is somewhat impossible. That sucks.

You could make a small(1x1x1) Invisible entity that you place on the collision points of the vehicle, then if they collide with something that’s not the vehicle do your stuff. Might work, maybe, don’t know how many points you could make before lag though.

I’m actually doing something like this right now, but I want when people shoot the vehicle for it to do something. I have an idea, I’ll tell you if it works.

Thats abit too hacky for me.

[editline]25th February 2011[/editline]

Cant you just use this: **[Gamemode.EntityTakeDamage

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Gamemode.EntityTakeDamage)**?

Last I checked, vehicles were not sent into that.

All entity’s with physics are sent into it, some entity’s don’t receive physics damage tho. Works for any other damage type AFAIK.

I know, but vehicles don’t seem to be sent into it.

Yes they are… Have you even tried it?

Obviously I have tried it, or I wouldn’t be telling you it didn’t work. Maybe it was a bug that was fixed.

I’ve had a similar problem with my Prop Damage addon, for some reason the EntityTakeDamage Hook only get called for vehicles when certain parts of it are hit, like the airboat floor and seat, the jalopy seat and wall behind the seat, and the jeep is similar to the airboat. I believe most of the body is parented to those parts and parented things don’t have real physics, IIRC.

Just tested it with the jeep smashing right into a wall.

Here’s my function:
[lua]
function GM:EntityTakeDamage(Entity,Inflictor,Attacker,Amount,DamageInfo)
MsgAll(tostring(Entity))
if ValidEntity(Entity) && Entity:IsPlayer() then
if Entity:Team() == TEAM_UNDECIDED then
DamageInfo:SetDamage(0)
return
end
if ValidEntity(Attacker) then
if Attacker:IsPlayer() then
if Entity:Team() == Attacker:Team() then
DamageInfo:SetDamage(0)
return
else
umsg.Start(“sendHit”,Attacker)
umsg.End()
return
end
elseif Attacker:GetClass() == “prop_physics” then
DamageInfo:SetDamage(0)
return
end
end
end
end
[/lua]

Here’s what happened:



Player [1][Drew P. Richard]


It’s damaging the player, because that happens. But no vehicle is sent.

“some entity’s don’t receive physics damage tho”

Ofcourse it doesn’t work with the physics damage, why do you think I made this thread in the first place?.. I’m saying that it works with other damage types.

It registers for me, but extremely low amount of damage is registered, like if bullets damage to the vehicle is set to be 12 the hook returns 0.02, but only when hit in some areas of it.