A
A
Alexey Fobius2021-09-07 10:50:45
C++ / C#
Alexey Fobius, 2021-09-07 10:50:45

What is the best way to track bullets hitting a player?

When I was making the shooting script, I ran into a problem - hitting the player, let's say, "does not always regatta".

I shoot not with a raycast beam because I need bullet physics.

I'm assuming it's because of the speed of the bullet itself (it is equal to the real one, 880 m/s), how can I better calculate the collision between the player and the bullet?

(At the moment I'm using OnCollisionEnter() )

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2021-09-07
@phobious

because I need bullet physics.

Then throw out the unit physics and write your own or connect something more reliable. Unity is not deterministic and the result may be different on the same simulation.
And yes, the problem is that you have a high speed of the object - it flies the object completely per frame - i.e. there is no such collision. The solution method is to check each frame of the "before-after" state and raycast between these points. If there was a player - then here)

S
Sergey, 2014-08-15
@another_dream

$times = ['12:05', '14:05', '16:05', '18:05', '20:05'];
$now = new \DateTime();
$filteredTimes = array_filter($times, function ($time) use ($now) {
    $diff = (new \DateTime($time))->diff($now);
    // оставляем в массиве только время
    // которое наступит только через пол часа минимум.
    return $diff->invert && $diff->h * 60 + $diff->i > 30;
});

ideone.com/7f4jcN

I
Ivan Somov, 2014-08-15
@jsom

convert mktime to standard time and compare them, much clearer and more beautiful

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question