Announcement

Collapse
No announcement yet.

Hitting players with vehicles in mutliplayer - need help thinking this though

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hitting players with vehicles in mutliplayer - need help thinking this though

    I'm having trouble coming up with a good solution for hitting players with vehicles. The major problem is that when a car physically hits a player, the car stops dead. I can't have that.

    So my first attempt was to put a collision box around the car and knock players out of the way. But the problem is the server doesn't check regularly enough to see if it hit a player. So more often than not, the car mesh has hit the player and physically stopped before the collision box collision has been detected.



    And even if it does check in time, needing to push the other player out of the way before the car can hit the player is a tricky and finicky situation that I don't think can be relied upon.


    So my second attempt was to disable physical collision for the mesh itself, detect overlap events and then knock the player out of the way. This worked but also players need to physically be able to jump on cars and run into them. So I had to conditionally enable/disable collision based on the speed of the car. But there's no good answer here for "what speed?". The player should be able to jump on a car if it's moving at low speeds. But the car should be able to push a player if it's running at that same low speed. So I started working with a system where I used a collision box to detect players in front of the car and knock them around if the car is moving at all. And then disable collision on the mesh if the speed is fast enough. But it's just .. such a mess.

    There has to be some better way to handle this. I've read through so many old (3+ years) posts about people with this issue. I'm really hoping a better solution has been found that I can't think of .. so I'm posting here in desperation.

    #2
    Instead of a collision box, have you considered having the car trace ahead of itself to detect players instead? The trace would extend along the car's forward vector a distance using current velocity and deltatime, to see if it would hit a player next tick. If so, you can go ahead and push the player. The faster the car moves, the further ahead it is tracing.

    Comment

    Working...
    X