Tag Info

Hot answers tagged

15

I haven't looked at specific implementation of A* by Aaron but with a normal A* you could include the 'block tower' as passable terrain but update the heuristic so that the 'cost' is much higher than a normal tile (so that AI will evaluate whether it is easier to destroy the block and continue or simple go around via the path that is not blocked). Then you ...


3

You might consider something like Wang Tiles. The idea is that you have a predetermined set of edges for your tiles. You can randomly generate tiles, still, so long as the edges match. For example, you might have 4 possible sides: A: Low terrain B: Mid terrain C: High terrain D: Water You can generate the first tile by randomly choosing the 4 sides. ...


3

I have faced similar problem before. I am pretty sure that co routines won't help you reduce the lag. Multi threading will be a proper solution instead of co routines. But apparently I didn't use either of them. My game had finite predefined pool objects. So instead of instantiating them, in the editor I made a parent game object named Pool and made all the ...


3

You can attach the sprite to the child of the main game object which handles the collision detection logic. Whenever you want to flip the sprite just do it on the child object leaving the main object as it is. This way you can achieve your desired result :)


2

What your are looking for, is called scissor test in OpenGL/Direct3D vocabulary. But unfortunately you don't have direct access to that feature in unity. I've been looking for a solution to same problem a few weeks ago, and I came across people suggesting to use multiple cameras with different render area to simulate this behavior. Here are some articles ...


2

Try turning off backface culling. In your shader, put "Cull Off" in the "SubShader" section.


1

Reverted to UnityEngine.Animation. Works like a charm and has no performance hits.


1

Follow these steps Select the main camera Locate clear flag option in the inspector Change the value from "Skybox" to "Solid Color" Also Go to Window > lighting Scene tab Skybox > change from "Default-Skybox" to "None"


1

GUI is actually rendered according to the screen view port and not according to the camera. In other words it is camera independent. You can try having a 3D text view or sprite in order to achieve the desired functionality. There are lot of other options also . Try Unity 5 GUI system or check out the NGUI plugin for unity. If you still want to use the ...


1

Hey your ball's rigid body has isKinematic true , you need to uncheck it so that the rigidbody starts colliding with other colliders. If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore. The rigidbody will be under full control of animation or script control by changing transform.position. Kinematic bodies also ...


1

This can be due to Mip Maps as it blurs out the texture farther away from the camera. In 3D computer graphics, mipmaps are pre-calculated, optimized sequences of textures, each of which is a progressively lower resolution representation of the same image. They are intended to increase rendering speed and reduce aliasing artifacts. Try to switch off "Generte ...


1

If it's a 2D game and you want to clip to some rectangular area, why not just use an overlay with a cutout for the area you want exposed? There would be no runtime tests required. Just place all the tiles, then place your mask layer over top. This is the same sort of technique that is used for most HUDs. Eg. A border around the edge of the screen. The ...


1

You could disable the gravity on the Rigidbody and then just make gravity yourself by writing a script and using GetComponent<Rigidbody>().AddForce(-Vector3.up * Time.deltaTime * YOUR GRAVITY VALUE) and just change YOUR GRAVITY VALUE when ever you want the object to be slowed down.


1

The problem is that you are running your mouse coordinates through Camera.main.ScreenToWorldPoint twice. var v3 = Input.mousePosition; v3.z = 16.0f; v3 = Camera.main.ScreenToWorldPoint (v3); Vector3 worldMousePosition = Camera.main.ScreenToWorldPoint (v3); Deleting the 3rd line will help. When you also have the problem that you are ...


1

You need to create a vector pointing towards the mouse -> Subtract the position of your cannon from the position of your mouse. vector2 dir = mouse.position-cannon.position Then you get the angle from this vector by using this formula if y is up and x is right angle = arctan(dir.y/dir.x) // or use atan2(y,x) Now you have the total angle that you need ...


1

You can do some cool things if you allow the tiles to overlap a little and then interpolate bits that overlap. For the parts that overlap you need to calculate each tile's contribution (weight) to the overall height which I'll refer to as H(x,y). Then when you sample H(x,y) you find each tile that overlaps that point and sum the weighted local heights of ...


1

There are two options for you. 1) Keep the image component on the button with a sprite, then set the transparency/alpha on the color to 0. 2) Write a separate script that you attach to a gameobject (Or image/button) that implements the Unity event interface: IPointerClickHandler and inherits from UIBehaviour. IPointerClickHandler is the interface Buttons ...


1

If the sprites are in your Assets/Resources directory, you can load them programmatically as follows: Sprite[] spriteSheetSprites = Resources.LoadAll<Sprite>("spriteSheetName); This will yield a Sprite array containing all of the sprites from your spritesheet, indexed by their order on the sheet. A requirement to use this is that the image's ...


1

From here, this can be used to calculate the volume of an arbitrary 3D mesh. public float SignedVolumeOfTriangle(Vector3 p1, Vector3 p2, Vector3 p3) { float v321 = p3.x * p2.y * p1.z; float v231 = p2.x * p3.y * p1.z; float v312 = p3.x * p1.y * p2.z; float v132 = p1.x * p3.y * p2.z; float v213 = p2.x * p1.y * p3.z; float v123 = ...


1

You can do this if you use Sprite.Create You would typically use this along with a Sprite Atlas, as setting the Rect properly without one would be pretty tedious.


1

You may be interested in Nodal Pathfinding. The concept is similar to placing waypoints, except you generate these way points on top of your world. The waypoints are then used with an A* pathfinder, to determine the optimal path. Have a look at the blog here: http://www.jgallant.com/nodal-pathfinding-in-unity-2d-with-a-in-non-grid-based-games/ Another ...


1

Use waypoints in your map. The enemy AI in "patrol" state chose a random visible waypoint as target. Reached the waypoint repeat step 1. (eventualy excluding current waypoint) If you don't want to place manualy waypoints you can generate them at the corners via script : here follow an example: cons: the enemy will patrol in straight lines from ...



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