Hi there!
I’ve trying to make a simple rounded bullet with a small scale (like: 0.1, 0.1, 0.1) using the same script of FPS tutorial.
But almost every bullet pass trough walls. If I increase the size of the bullet, for 1,1,1 it works fine.
Any ideas on how to fix that with small bullets?
I have this script on the bullets:
var explosion : GameObject;
function OnCollisionEnter( collision : Collision )
{
if (collision.relativeVelocity.magnitude > 2)
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
var instantiatedExplosion : GameObject = Instantiate(explosion, contact.point, rotation );
Destroy( gameObject );
}
I don’t believe there is a fix to this problem, I bet if you make them go slower more of them will hit the wall!
I’m trying here… I think that make it bigger (0.2) and slower (frameRate at 0.2) it’s the way to go.
But faster would be really nice…
Thanks!
Mateus
You probably can’t stop them passing through, but if you raytrace between a bullet’s old and new positions each frame you should be able to detect what the bullet should collide with. Which should be sufficient if you just want to damage the target and destroy the bullet on contact (and additionally will allow you to implement shooting through soft cover if desired).
I’m trying to avoid rays. The player moves fast, but I want the bullets like old school “Konami” shooters.
A lot of bugs, but here is the prototype:
http://laboratorio72.com/zog/zogv4.html
Now try to shot the trees to see some bullets missing the bushes.
Hehe it’s fun! Nice art. I wanted that machine gun though 
Down to business, I think killer’s right. I had a similar problem with my first game (llama racing), only it was with the jump input randomly not going through. When I asked some of the Unity guys at the Unite conference this year they suggested that it was slipping through the check that happens every x fractions of a second.
hehehe, me too! that is the most important weapon right now.
I’m trying to slowdown the bullets, crank up the fire rate to make a good rhythm. But I don’t want lose bullets… I’ll limit the ingame ammo.
Just a question, If I test this on a slow machine, the firing rate/FPS will be the same?
[ ]'s
Mateus
The FPS may change. Whether firing rate changes depends on how you’ve coded it. If you’re using Time.deltaTime or a coroutine using WaitForTimeSeconds() it is likely fine.
Try lowering your physics cycle time to 0.001 (1000 fps)
Project Settings > Time > Fixed Timestep
There’s two things I would try. First is making the collider object bigger. Just scale it up. It’s invisible anyway, so it shouldn’t affect much. Maybe make it long and skinny so the bullets still need to aim as accurately.
The second would be to make each bullet object composed of three objects that travel one in front of the other.
0------------0------------0 moving —> that way
each ‘0’ up there would be a collider. Better chance that one of them will hit the target without passing through.
Hmm, you could probably take it to the logical extreme and dynamically stretch the collider so that it is as long as the distance the bullet is moving each frame. Then it should always hit.
Thanks for helping us! We’ll test some of the good ideas this week. If we find a good solution, I’ll give you a reply.
[ ]'s
Mateus