Tag Info

New answers tagged

0

Danie, Isometric map games are actually 2D and they use pre-rendered arts. I am doing the same with Apple’s SpriteKit and I strongly recommend you to give it a shot. I have simulated a spot light over my tiles in my iso map by a simple self-writing algorithm that computes the distance of the tile to the corners and blend the sprite with a specific color ...


0

pick your instantiated prefab, say GameObject go = GameObject.Instantiate(yourPrefab) as GameObject; and get for example a sprite Sprite yourSprite = Resources.Load("sprite" typeOf(Sprite)); and change the prite go.GetComponent<SpriteRenderer>().sprite = yourSprite;


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


0

First, you need to find which blocks should move move, given a particular clicked cell. You'll probably want to use a floodfill algorithm of some sort for that. Once you have your list of tiles, move them all one after the other before doing anything else. The way I would do that would be to change the move function so that it takes another parameter ...


2

You need to flip the texture, not the object. Sprite/Plane meshes are one-sided so if you flip the actual object, you are seeing the back of it, which is transparent. Edit: You could also make your mesh two-sided. But Unity doesn't provide a flat, 2-sided rectangle. You will have to make it, either in a modelling program or with code.


2

When the user presses the "orbit" button, store the vector between the ship and the planet. On every update, change the vector's angle leaving magnitude the same and then update the ships position by adding the planets position and the vector pointing at the ships new position. This will create the effect of the ship moving in a uniform circle around the ...


0

If you are going to just paint the grid, you can check out GridLayout provided by android UI. I have tried for 3X3 grid and used ImageView to set some images. To understand gridLayout , http://developer.android.com/reference/android/widget/GridLayout.html


0

For simple shadows you can create a material and select the shader as Sprite>Diffuse , this will enable shadows on the sprite. If you are looking for more than just shadows i.e. adding normal maps and other cool stuff, then check these two links give below :) Writing a SpriteLamp Shader in Unity Kencho's dev blog


0

For a grid system, I haven't yet implemented this code in anything other than an engine, but I'd imagine it would be similar. I implemented the Tetris clone in Unity 5, using this website: http://noobtuts.com/unity/2d-tetris-game The grid section of this webpage might be of some use to you. I will try my best to convert it into java code, and make it ...


0

You could try and check if the distance between two objects is increasing or decreasing or you can use an infinite raycast and check the object it hits.


7

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers... This is the solution: void SceneView::centerOn(const QPointF &pos) { if (mScene) { mScene->setX(int(-(pos.x() - width() / 2))); mScene->setY(int(-(pos.y() - ...


0

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy. Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as if (x2-x1)>=0 if (abs(x2-x1) < ...


0

I have faced this problem earlier.This is because the "Generate Mip Maps" option is on. You need to deselect that option and apply the changes to the sprites. Mip Maps 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 ...


0

I forgot to come back to this question when I arrived at an answer, but this has gotten a decent amount of views over time, so better late (even 2 years late) than never! First, prerequisites: Prerequisites: First, one has to be able to calculate the time of collision (TOC) of two circles. Step 3 of this question Small, High-Speed Object Collisions: ...


1

my approach will be almost similar but I will prefer to use a full sprite sheet of cards to avoid the extra naming problems. Before we get started here is the link to the sprite sheet. http://i.stack.imgur.com/gnv4Q.jpg We need to create one script named Card which can hold its value and type. It should look like this:- using UnityEngine; using ...


1

try using GameObject.FindGameObjectsWithTag or GameObject.FindWithTag or by name (or namepath) GameObject.Find bool playerexists = (GameObject.Find("player") != null)


1

In my opinion the best is start with a good AI layer that uses a state machine approach (here and here). Making it simple, the current state AI evaluate some inputs, make a decision and eventualy jumps to a new state. The movement and animation layer relay on actual AI state to do their stuff


1

I'm not sure I completely understand what you are asking, as it's hard to tell what you mean by your "game style", but I will say that a path-finding algorithm is not necessarily overkill, especially if you would like your NPC's to find specific routes around obstacles. From my own experience with AI navigation, there are a couple of very popular types of ...


1

I'm not experienced programmer, but as for me, I try to divide as much logical parts as I can into different scripts. For ex, for the character you can use something like MVC, model-view-controller pattern. The point is that one script processes user input and communicates with tho other parts which are responsible for animations and actual movement. In ...


-1

Never mind, I fixed it - var pizza : Rigidbody2D; function Start() { pizza = GameObject.Find("pizza-small").GetComponent.<Rigidbody2D>(); }


0

To detect the direction that your player is facing you can use transform.forward as a vector3 value .


1

To determine the cone you should create some variables like AttackLength, FieldOfViewAngke and get enemy component to determine enemy position lookDirection = enemyPosition - player.transform.position; lookDirection.y = 0; attackDirection = Vector3.zero; float angle = Vector3.Angle(lookDirection, transform.forward); if (Physics.Raycast(enemyPosition, ...


0

The easiest solution is to use any flood-type algorithm, for example as you mentioned Dijkstra's algorithm. The only difference is the stopping condition: if(Resources.Any(r => r == node)) { ...} instead of if(resource == node) { ...} you can improve its performance by excluding resources that cannot be possibly reached yet from the check (=found ...


1

Hey there are couple of things which you are missing out. 1) Even thought the motion is in 2d plane but the gameobject dimension is 3D, so use Vector3 instead of Vector2 2) When you calculate Vector3 Movetowards it returns a value which is calculated upon current position , target position and speed. This needs to be assigned to the transform of the AI. ...


0

Your targetX and targetY are being set as your current script's transform.position, rather than your target's position. Also, targetX and targetY are Transforms, when really it sounds like they should be floats, or perhaps even just simplified as a single var target : Transform;. You could also just have var me : Transform; as well. Your MoveTowards should ...


1

Make sure that "Is Kinematic" option for rigidbody in the inspector is off. Here is a very basic example for adding torque. var torque: float; var rigidBody: Rigidbody2D; function Start() { torque = 20; rigidBody = GetComponent.<Rigidbody2D>(); } function FixedUpdate() { rigidBody.AddTorque(Time.deltaTime*torque); } Time.delta time ...


1

As Vector2 is a type composed by two numbers which are x and y, then you should be able to get the position by asking both numbers: Vector2 YourVar; YourVar.x; YourVar.y; So you should use something like: SetPositionToMove(YourVar.x,YourVar.y); //if the functions expect x and y or: SetPositionToMove(Point2(YourVar.x,YourVar.y)); //if it expects a ...


0

I think you will have a very similar stuff, compared to this tutorial. You will instantiate prefabs in each tile position. I would create prefabs of tiles based on functionality: Ground Tile Prefab, WaterTile Prefab, etc. Each one with options to activate/deactivate game Objects, to change the looking, for example. You rather use something with a little bit ...


1

Its actually very similar to the way it is done in XNA , only a few changes in the syntax and loading approach. Here is the most basic way in which it can be done. You can build on top of it as per your needs. Before we start, we need to make some tile prefabs and store it inside the resources folder. Lets define some variables, and initialise them some ...


1

here you go, here is a implantation of the A* in Action script 3, i wrote this a few years ago, there are a few things such as grid, grid view and node classes that i'm using which really don't have anything to do with the A* algorithm itself, and are all used for the graphic and visual side of the work, still if you are interested i can put them here so you ...


1

modify a* considering goal as a set of points instead of a single point. If the euristic function is the distance, the each step of a* chose the path that minimize the closest point distance. Check also this


0

Another option may be using a quadtree structure or if you have many moving objects a spatial hashing aproach.


0

Okay so the answer was rather simple, should've thought about it earlier, in order to give a correct origin you'll need to get the world coordinates for it through your original view matrix's transformation. transform2 = Matrix.CreateTranslation(0, 0, 0) * (rotation * Matrix.CreateScale(new Vector3(1, 0.75f, 0)) * ...


0

I would do it with Scene2d. You can have your game with a normal game loop and a SpriteBatch to manually update and draw the game and additionally you can have a Scene2d Stage that you can use to display whatever UI components you wish above your game (or below, depends on the order of calling the draw methods). It's a very nice library, great I would say, ...


2

One way to apply light effects with the Context2D is to use the composite operation 'lighter' (globalCompositeOperation='ligther'), and adjust the alpha (globalAlpha= 0.0 to 1.0). Then you can either : • Draw the shape of the light with several geometric drawings that create a simple shade to get a cartoonish light effect. • Define gradients to get a ...


0

Take a look at this tutorial on Sprite Sorting Layers In short, you can use the Sprite Renderer component and modify the layer properties to achieve the effect you want.


4

I'm using Hooke's Law here as the definition of a spring. () Given the derivatives of position and velocity, are velocity and force respectively, we can construct a differential equation for the stretching of the spring. Which is just a damped harmonic oscillator, and since we already know that only the under-damped case need analysis, we can obtain a ...


1

i did something similar a while back, it's not that hard, one very easy and understandable way is : 1- rotate everything! means every line every object, so everything is simply flat! 2- calculate velocity, gravity, friction and ... anything you like ! just the way you always do in a flat and without rotation world 3- rotate everything back the way it was ! ...


1

You could re-order your std::vector<Object> by creating a function that sort it by Y position of your objects void SortObjects() { std::sort(Object.begin(), Object.end(), CompareYAxis); } bool CompareYAxis(const Object first, const Object second) { //Do the comparison here } I think this would work.


0

Disclaimer: Coded in 3D, converted to 2D You could use IEnumerator. Like this: public const float stepDuration = 0.5f; private Coroutine playerMovement; private void Update() { if (playerMovement == null) { if (Input.GetKey(KeyCode.W)) //In general not a good idea to use Input.GetKey; use Input.GetButton instead ...


0

Simulating the whole world in real time on a single PC is unlikely to be possible. What you could do, however, is split your world in several chunks (I mean chunks, not shards). You'd have to adapt your world for an agent (AI) to be able to exist in a single chunk at any given time. For instance, you could have one big island per chunk. And then you ...


1

No. Not at least from what you're describing. An AI that's unique to one animal that takes into account all of the variables of such a complex environment would be taxing to simulate just on it's own. Plant life would be easier, but the cost to simulate all the plants would add up fast. A continuous simulation of the entire ecosystem would be virtually ...


0

Maybe i dont understand what you are trying to do, but the standard way to do this is to have a spot light as your flash light. In your case you would disable all lighting sources in the scene and set global ambient lighting to 0. This will make the scene pitch black where only the spot light attached to the player visible. For 2d you will need to add ...


2

You could draw this using a multiply blendstate. BlendState multiplyblend = new BlendState(); multiplyblend.ColorBlendFunction = BlendFunction.Add; multiplyblend.ColorSourceBlend = Blend.DestinationColor; multiplyblend.ColorDestinationBlend = Blend.Zero; Create a bitmap of a white circle in a black background (mask). The white is the part of the shield ...


0

If you're starting with a tileset with regular dimensions and layout (as in your example), and your goal is to create tile maps in Tiled, there is no need to use third-party tools. Tiled supports these natively and easily. There are a few tutorials on using Tiled like this one, but it's very simple: Create a new map, choose its dimensions and tile size ...


0

Go to piskelapp.com , then choose 'Create new Piskel'. Click the menu on the right, and choose import your own image; select it, then put the number of size of each tile. After you are done editing, choose Export in separate images. Done!


3

You can do this via masking on the cpu if you prefer to not use shaders yet. You'll need these resources: Spaceship texture (no shield visible, left) Shield texture (only the shield visible, needs to fit the ship, middle) Empty editable Texture (pixmap) that you can draw onto (same size as shield texture, right) Point of impact You can draw your ship ...


0

To expand @Alexandre Vaillancourt answer, I would even consider using a collection that keeps your data sorted, instead of re-sorting it every frame. struct Drawable_compare { bool operator() (const IDrawable& d1, const IDrawable& d2) const{ return d1.y < d2.y; } }; class Renderer { private: std::multiset<IDrawable*, ...


1

I would forget right away the option to create the sprites in order based on their y coordinate as it will create a hell for you because it's not a flexible design. You look like you need a common way to handle the drawing process. You can achieve this using polymorphism. I would probably create a IDrawable interface, which requires children to have ...


0

Note the following important identity for augmented isometric affine matrices: where the isometric condition is recognized from: and is the translation in world coordinates of your original transformation. In vector terms, if you think of your original transformation as being then the inverse transformation, to return to World Coordinates is ...



Top 50 recent answers are included