• A "catch-all" hook for when an entity collides with something?
    6 replies, posted
I'm looking for a hook that will run whenever an entity (more specifically, a vehicle) collides with something. I thought PhysicsCollide would work, but it seems like it does not. Essentially, I'm trying to make a car damage script. If anyone has any ideas for the hook that I should use, that would be great.
This has been wanted for a long time but hasn't been added yet.
[QUOTE=ralle105;22610112]This has been wanted for a long time but hasn't been added yet.[/QUOTE] Bummer :( Haven't you seen that mod, where if your vehicle is going at a certain speed, and you collide with something, you get flung out the window? How would that mod work?
[QUOTE=dvondrake;22610442]PhysicsCollide is for SENTs only. You could try hooking onto Think and just detect sudden massive drops in velocity--that might work. There's also the [url=http://wiki.garrysmod.com/?title=Gamemode.ShouldCollide]ShouldCollide[/url] hook, but I'm not too sure how it works exactly.[/QUOTE] ShouldCollide is periodically called, like Think, it's not called when two entities collide. If you want to make car damage, you might want to have a look into EntityTakeDamage. You can either detect whenever the car itself takes physics damage, or the driver takes DMG_VEHICLE damage.
Ah, what you two said does help. The actual hook isn't very sensitive, but it seems good enough. Thank you both, this has me on the right path! And just for the reference of everyone else, the first ent parameter is usually the player within the car, and the inflicter is the actual car.
Sorry, you need to Log In to post a reply to this thread.