Tag Info

Hot answers tagged

4

You should consider using a plain 2d-array or alternatively an array of rooms, where each room is a 2d-array or a grid. A grid would looks something like this: The player is the yellow dot and the blocks are the green ones. if the player is the light gray square, you only need to check for blocks that around that square area. This saves you the time of ...


3

I did the following to achieve results: Added a Rigidbody2D to the player (deactivate Gravity). Added a 2D-Collider to the bomb. Added control and health script (basic stuff, just position updates). My health is just a public variable. Used the following code in playerPhysics.cs: void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.name == ...


3

The usual tricks with weapons are: Make your character's collider large enough that it contains your weapons, then simply ignore collisions between it and the weapon's raycasts. Make it appear not to go through by drawing it on top of other objects. This works for FPS type games: Put the weapon(s) on a new layer (for this example it will be named ...


3

First off, if you are that new to Unity, maybe you would benefit a lot from going through tutorials. Unity website has some pretty handy tutorials, plus some nice step-by-step complete projects. Nevertheless I´m going to give you a general answer to guide you with your question. For my answer I assume you are familiar with some basic Unity3D concepts, as ...


2

Check out colliders. You'd likely want to implement OnCollisionEnter in your character class. When something collides with the player, this method will be activated. Inside this method is where you'll deduct from the player's health. If the player can only collide with one thing (the sphere objects), you can make it pretty simple: function ...


2

For your collision I would merge adjacent colliding tiles together into one big collision box instead of iterating over every single tile and checking their individual collision. Also I think that a quadtree would work much better than your current approach with a HashMap as it splits your gameworld up in sections and make it easy to delete a section of ...


2

A possible solution is to use the Dot Product. Of course, you need two vectors and not two angles, but I guess you're using them (otherwise I wouldn't explain how you're having 3D angles). Quoting Van Verth & Bishop from the book Essential Mathematics for Games & Interactive Applications, page 30-31: A more common use of the dot product is to ...


2

Say the object is 10 meters above ground. Assume that our dt (delta t) is 1 second. The object goes to the height of 9 meters at the end of the first iteration Here lies your problem. It is true that the velocity at the end of the first iteration is 1 m.s¯¹. However during that time the object has not travelled 1 m. In fact, since the acceleration is ...


2

Lets put together some greedy algorithm. If we had two circles(circle centers), the solution is trivial, right? Just calculate the distance(pythagoras) between them and divide it by two. But what if we had more? As you might agree, at least good solution, if not optimal, is always draw the smallest possible circles such as its radius is maximal possible. ...


2

Add a flag to determine if the player has been stopped. At that point, stop setting the players position to the camera's, and instead some other input. public float speed; public test testing; bool stopped = false; // Use this for initialization void Start () { speed = 10f; testing = Camera.main.GetComponent<test>(); } // Update is called ...


1

Turning on convex mesh fixed the problem. I have done it by script, because after importing object from blender there is no check box allownig to do this.


1

Actually, the negative vector of the most recently added point will not always be a good search direction. I can understand if your intuition brought you to this conclusion, but it's wrong. Search directions are about finding support points that are furthest along a Voronoi region, away from the current simplex. Search directions are not only about ...


1

You then have the centers of the BB without having to know the size of it, if your game needs to know the centers more often than the top left then that is preferable. Storing the half vectors is to simplify retrieving the left/right and bottom/top vectors center-halfHeight provides the bottom and center+halfHeight provides the top. Granted all it does is ...


1

In the tilesheet, right click on a tile and then open its Tile Properties. If you see a property named "c", it means that that tile is "closed", and the player cannot enter that tile. If the tile lacks "c", then the player can enter it. Source: https://github.com/particlequest/ParticleQuest/wiki/How-to-create-a-map-using-tiled-map-editor


1

If you want, you can predict your movement with the Periodic Interference Test (PIT), which is fancy for "Place myself in the next position and if I collide with something, revert me to the last safe position". This is fast, easy, relativly safe and should be sufficient for your game as long as you don't move to fast (aka make two big jumps in a frame). ...


1

if the speed of the objects is constant (or you can predict it accurately) you can check if they are going to collide, if yes don't move object (or move them so they touch side to side) one other thing you can do is save previous location, calculate object's new location, if objects collide, move to previous location



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