Hot answers tagged

75

I can certainly see why you would think that it would be hard to simulate those, but there are enough constraints on bullets (all projectiles, really) to make them easier. They are generally simulated as a single point, instead of as something with volume. This makes collision detection significantly easier, as now I only need to do collisions against ...


42

Probably one of the most efficient ways to implement bullets is using what is known as hitscan. It is rather simple in its implementation - when you fire, you check to see what the gun is aiming at (possibly using a ray to find the closest entity/object/mesh), and then you 'hit' it, doing damage. If you want to make it seem more like an actual, fast moving ...


7

I'm by no means an expert, but to answer your question, yes, you would need many of those things you mention. For your 2D example, you could have a position and velocity for a bullet. (You might also need a lifetime or maximum distance, depending on how you implement your bullets.) That would usually involve 2 (x,y) values. If they were floats, that's 16 ...


6

Wouldn't it be hard on the processor to process thousands of these objects being instantiated, then destroyed (when on-hit effect is triggered)? RAM space? I think you're underestimating just how fast computers are. This was sometimes a problem on the systems of the 80s and 90s. It's partly why the original Space Invaders won't let you fire another bullet ...


4

Null Reference Exception A NullReferenceException is a runtime exception that happens when you haven't set a variable to an instance of an object, and then attempt to use that object. For example, the following could cause a NullReferenceException if TestObj isn't set using UnityEngine; public class NullTest : MonoBehaviour { public GameObject TestObj;...


4

Here are my tips for how to handle errors before release. Tip.1: If your game is trowing NullReferenceException's during runtime. Fix them. Fix all of them. Note your game will still do this because it is nay impossible to test everything before the users get their dirty little hands on the game. Tip.2 Wrap your Debug.anythings in if(Debug.isDebugBuild) ...


1

I'm far from an expert but I've been working on a multiplayer 2D shooter game in my spare time. My method There are varying bullet classes between the client and server (even when playing offline, a server instance is started on a separate process and connected to by the 'main' game). Every tick (60 per second) the client works out a bearing between the ...


1

These kinds of errors are exceptions which abort your functions in unintended ways. As such they can speed up or slow down the execution of your game (by skipping vital pieces of code), but the question about speed it the wrong question in this situation. Fix the code.


1

Disabling "multithreaded rendering" from Player Settings > Other settings might work (As these guys have pointed out) My own experience was some postprocess effect was horribly conflicting with the hardware I was developing on (though mine was PC). I found out the culprit by deactivating everything (gameobjects and components) in the scene one by one. (I ...



Only top voted, non community-wiki answers of a minimum length are eligible