Shooting a bullet. Need help!

Hi guys :smile:
I’m making a TPS.

I’m at the point where i need to shoot a bullet.
I tried with lots of methods:

Rigidbody driven by physics - this is the actual thing i’m using. The problem is that’s hit and miss because physics at high velocities glitches.

Rigidbody kinematic - does not work, because OnCollisionEnter glitches when using kinematic rigidbodies.

Raycast prediction with bullet moving along the trajectory of raycast - works bad also, the calculation isn’t perfect, sometimes the bullets stop halfway and things like that.

Now, i need advice on how do i achieve a good looking bullet shoot. I need to have a gameobject since i have a “slow motion” part.

Any help? :smile:

Thanks,
Akabane

Don’t use a gameobject until you enter slow motion. You won’t see a bullet in real time, so you can just use a little physics to calculate where the bullet would be at the point you actually slow things down. Once time speeds up again, get rid of the gameobject. That way, you should only need to pre-calculate where and when the bullet would strike whenever you shoot.

Yes, thought of that…the problem i had thinking of implementing this technique would be the fact that i actually have make uhm…false calculations based on nothing on when and where the bullet should be when i slow down things. Could be easily done if i just enter slomo and shoot once. But even the second time there would be some panic. And i would actually need again know when the bullet collides (go) since i’ll need to instance the, say, bullethole or any other hit-event based on that…I don’t see how i could achieve that without using a completely not-elegant and whackytricky procedure.

Thanks for the reply still :smile: but i’d like a slightly more straightforward approach if it’s possible.

Nothing more straightforward than basic physics. No false calculations at all. Simple math. I do it with a orbital simulation I am building. Given a point in time, I calculate exactly where a planet will be in its orbit.

Given a point in time (at the time of firing, .0002 seconds after, 2 seconds after, …), you can calculate 1) exactly when and where the bullet will collide, and 2)where precisley the bullet will be positioned. Heck, if you wanted the bullet to rotate (as bullets do), you could even precisely calcualte where, in its rotation, it would be.

Uhm, that sounds great. :smile:
Would you mind elaborate a bit on the math needed to do those calculations?
Because this sounds like what i’m after…
Thanks again,
Akabane

EDIT: And sorry for misunderstanding your advice because of my ignorance in the subject :smile: