• Entity has collided?
    19 replies, posted
Is there something similar to [URL="http://wiki.garrysmod.com/?title=ENT.Touch"]ENT.Touch [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL] 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.
[url]http://wiki.garrysmod.com/?title=ENT.PhysicsCollide[/url]
[QUOTE=Feihc;28258298][url]http://wiki.garrysmod.com/?title=ENT.PhysicsCollide[/url][/QUOTE]How am I suppose to run it [i]"outside of entity's code"[/i]?
I tried to do this once before, but could never figure it out either. :\
You could do [b][url=wiki.garrysmod.com/?title=Gamemode.ShouldCollide]Gamemode.ShouldCollide [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] and check if the class is a "prop_vehicle*".
[QUOTE=zzaacckk;28272814]You could do [b][url=wiki.garrysmod.com/?title=Gamemode.ShouldCollide]Gamemode.ShouldCollide [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b] and check if the class is a "prop_vehicle*".[/QUOTE]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.
[QUOTE=freemmaann;28278777]Cant recreate the entity's so I guess this is somewhat impossible. That sucks.[/QUOTE] 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.
[QUOTE=Fantym420;28278973]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.[/QUOTE]Thats abit too hacky for me. [editline]25th February 2011[/editline] [QUOTE=Drew P. Richard;28278987]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.[/QUOTE]Cant you just use this: [B][URL="http://wiki.garrysmod.com/?title=Gamemode.EntityTakeDamage"]Gamemode.EntityTakeDamage [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B]?
Last I checked, vehicles were not sent into that.
[QUOTE=Drew P. Richard;28280292]Last I checked, vehicles were not sent into that.[/QUOTE]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.
[QUOTE=Drew P. Richard;28281129]I know, but vehicles don't seem to be sent into it.[/QUOTE]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.
[QUOTE=Drew P. Richard;28281373]Obviously I have tried it, or I wouldn't be telling you it didn't work. Maybe it was a bug that was fixed.[/QUOTE] 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: [code] Player [1][Drew P. Richard] [/code] It's damaging the player, because that happens. But no vehicle is sent.
[I]"some entity's don't receive physics damage tho"[/I] 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. [QUOTE=Fantym420;28281495]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.[/QUOTE]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.
Sorry, you need to Log In to post a reply to this thread.