Hot answers tagged

39

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 ...


19

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 ...


6

"Manager" classes can be problematic for various reasons. The two key reasons tend to be: the name is unclear (what actually does "management" entail, and is it always the same for every type of thing being managed?) they tend towards being buckets of functionality that violate the single responsibility principle (that is, that a type should do one thing) ...


5

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 ...


5

When you read the blog post you linked to in the comments, then you will see that "being a Manager if by another name" is exactly what it wants you do to. It's general consensus in software development that global variables are evil, and the only alternative is that any data is held by other data. The problem with a class named FoobarManager is that the ...


4

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 ...


2

Why not use colliders and tags. When an enemy trigger/collider detects a player trigger/collider tagged say "Player kick" (child game object of the player) then that enemy executes his reaction with OnTriggerEnter(2D)/OnCollisionEnter(2D). Player just needs to enable and then disable its kick game object when kick is pressed. The most important thing is ...


1

One approach to a multilayered map would be an array (or 2-dimensional array) of linked lists or vectors holding tile objects. So your tile struct would either hold a pointer to the next tile above it, or you would have "stacks" of tiles of varying heights spread across the grid. Essentially that creates a 3D array. A nice, albeit old article on ...


1

This link looks interesting and provides almost that what I need, maybe it can help somebody too http://forum.unity3d.com/threads/animfollow-active-ragdoll-is-now-free-to-download.220812/



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