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

At first glance, I would say you're going to have a problem with splicing during the loop. Say you're at index 1 and you have a collision. You then remove that spot, and now everything moves up a space. But your loop counter still increments. So what used to be in the second index is in the first one, and you went from the first to the second, skipping it ...


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

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

You need to add a BoxCollider2D component to your GameObjects. http://docs.unity3d.com/ScriptReference/BoxCollider2D.html From the Unity docs for OnCollisionEnter2D Sent when an incoming collider makes contact with this object's collider A Rigidbody2D just tells a GameObject how to interact with the physics engine. It doesn't provide a collider for ...


2

You problem is in speed of checking for collisions. there are two possible solutions: Check several (n) times each frame (=move 1/n speed n times) Instead of point-rectangle intersection perform line segment - rectangle intersection the first solution is fast and easily implemented, on the other hand it doesnt really solve anything, if your bullets are ...


2

If your platforms are isolated use Tags. Each object and prefab in the Unity game world can be interacted with differently depending on the tag they have. For a wall of any kind simply tag it as "Wall" and code it with this is mind when making collision detection on your main character. For a platform, guess what, tag it as "Platform". You can then ...


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

Chapter 1: Movement Prediction for Beginners If you know the point of contact and especially the positions of the balls at contact, you can simply normalize the vector //pseudocode normalize ( blue.position - green.position ) Now for the collision prediction itself: In every update the gravity vector is applied to your current velocity. To get out ...


2

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


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

If I understand correctly, you have a bullet "object" of size 36x6 colliding with an enemy of size 56x69. Let's take a look at each step of the collision: bullets[a].x + 36 >= enemies[b].x This will test if the bullet right side is to the right of the enemy's left side. Right after, you have this: bullets[a].x <= enemy[b].x + 56 Here, you test ...


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

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


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

Well, Mike C already gave you a simple answer, I am going a bit deeper: First you need to a way to filter the results by proximity (this is to prevent lag when looping throught the objects) I advise using some sort of hashmap to sort the objects. Calculate them on a grid with their X and Y coordinates and then just Iterate between the near objects, if ...


1

You should use raycasting to check for visibility. Each raycast is expensive, so stagger the visibility checks for different enemies (they don't all have to see the player on the same frame)


1

You should write a method that checks the visibility. It follows the definition: http://en.wikipedia.org/wiki/Visibility_%28geometry%29 There are a lot of techniques to do that. Therefore, I reccomend you searching on the web which approach would fit best in your problem.


1

Android does not limit your options when it comes to collision detection. Here is a nice article about SAT collision detection: http://www.codeproject.com/Articles/15573/D-Polygon-Collision-Detection That implementation also has the nice feature of being tunneling free. That is, if two object with very high speed intersect each others paths in such a way ...


1

Instead of checking a single block for collision, you could keep a list of blocks and then iterate through the list and perform collision responses for each block in the list. Like this: public void checkYCollisions(block[] platforms) { if (position.Y >= 700) grounded = true; else grounded = false; float Xradius = Width / 2; ...


1

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



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