- Home /
Tank projectile speed
Hey, Need help with setting the velocity of objects.
I'm doing online tank game. I want the real tanks. For example, M1 Abrahams tank (USA) has a muzzle velocity 1600 m/s (M829A1 projectile). When this speed reaches with shoot script, projectiles passes terrain and other colliders objects. I have already installed the script 'DontGoThroughThings', but it does not help.
Any advice?
(Sorry for my bad english, I'm Czech)
Answer by Jeff-Kesselman · Nov 23, 2014 at 07:38 PM
Three pieces of advice.
(1) You are experiencing a frame miss. The projectile is moving so fast that it is on one side of the object in one frame and the other side in the next, never intersecting. You can fix this be setting the collision mode for the projectile to 'continuos" on its RigidBody http://docs.unity3d.com/ScriptReference/CollisionDetectionMode.html HOWEVER this is pretty expensive calculation wise.
(2) Do you really want your shells to go that fast? Unless there is a reason why you need military accurate simulation, like this is a military training sim, being more realistic often isnt more fun. You want cinematic, not realistic, for a game.
(3) if you really want it to move that fast, is it even visible? Maybe you should just do a line cast and do an instantaneous hit calculation.
Answer by sevensixtytwo · Nov 24, 2014 at 02:11 AM
I've done fast projectiles before and DontGoThroughThings helps a lot (yes, also with tank guns going 2000+m/s). Make sure your scaling things properly (1 unit = 1 meter). Wrong scaling can cause a crapton of problems with physics detections. Also, using large box colliders rather than small mesh colliders is a big help.
My only problem with DontGoThroughThings is it still relies on a collision between the projectile's collider and an obstacle. Through the vagaries of FixedUpdate, the projectile may actually collide with something before the raycast fires, causing a miss.
I have a bullet code with a modified DontGoThroughThings integrated that only uses Raycasts to detect collisions rather than a collider here:
Check the first answer and modify to your needs. Instead of setting the projectile's position to the collision point and causing a collision, it simply tells the bullet that it hit something and calls the "Destruct" function. Much faster and consistent since there is no chance the bullet will hit something behind the target before the raycast is fired.
Your answer
Follow this Question
Related Questions
How to control the speed of the projectile motion? 1 Answer
How do I accelerate particles in Shuriken? 1 Answer
Projectile Trajectory Velocity, with predefined Start and End Positions 0 Answers
Need some help with firing projectile at player using Rigidbody Velocity 1 Answer
Speed based on distance 1 Answer