Tag Info

New answers tagged

0

I have a couple of suggestions Avoid Allocations and Copies A lot of your code has unnecessary allocations and copies. Instead of filling a vector with push_back, try pre-allocating the vector and setting the data there. You have a fixed maximum number of intersection points, so pre-allocate a vector of that size. Do a Simple Broadphase Before you do ...


2

Sprite Sheets with a Uniform Grid The easiest form of sprite sheets, are sheets that use a uniform grid to lay out the individual sprites of your object. Your sheet is essentially a grid with a certain number of rows and columns of cells. Each cell contains a single sprite. Using a uniform grid, means that all cells have the exact same dimensions. ...


1

Using an atlas: You can pack the left and right versions into a single texture for each sprite, and only swap UV's based on the player's direction. Although you may put only left/right images into the textures, will your modders? A few descriptors to think about: bool AutoFlip; //Swap UV's based on L/R? bool ReverseTextures; //Reverse standard ...


0

From my experience recently in doing a few 3D animations, I found it very simple to just split up the animation into 3 separate clips. That way I felt that it was quite intuitive and easy when creating transitions between each animation clip in each stage of the overall animation. You also have a great deal more control over the animation transitions using ...


1

Sounds to me like what you need is to define a box in the middle of the screen, and only if the car moves outside of that box then the camera will move. That way the car has a bit of freedom to move without the camera moving, but as soon as it gets too far away from the center of the screen the camera does follow it. This is similar to the technique used in ...


1

There are lots of ways to do this, though MoveTowards seems reasonable for your purposes. Essentially, you'll want to determine some speed you want the camera to follow the car. Let's say that's float cameraFollowSpeed; Then you need to adjust that to be framerate independent with Time.deltaTime So now FollowCar's Update() your code is something like ...


3

First its good to note the difference between Colliders and Triggers Colliders - generally are intended to represent physics interactions, so objects "colliding with them" should not pass through one another. As opposed to... *Triggers* - as the name implies, "fire" off an event but don't carry the typical physics body interactions Triggers and colliders ...


2

Rather than rotating a sprite, I would suggest you try multiplying the sprite's x scale by -1. This will flip the sprite without having to rotate anything.


0

Hold a reference to your Camera, then set its localEurlerAngles to Vector3.zero. Camera yourCamera; void Start() { yourCamera = GetComponentInChildren<Camera>(); } void Movement () { anim.SetFloat ("moveSpeed", Mathf.Abs (Input.GetAxisRaw ("Horizontal"))); if (Input.GetAxisRaw ("Horizontal") > 0) { transform.Translate ...


2

Using a 2D tile array for your world/level generation and representation will definitely simplify things. For example you could internally represent your world in a grid of tiles and take it from there : using System; using System.Collections.Generic; using System.Text; namespace Tiles { public class Vector2 { public int x; public int y; ...


3

If you're using a grid, you shouldn't be using Unity's physics for collision detection - use the grid. Get your position on the grid then do something like this: public bool GridCast (Coordinate Position, Coordinate Direction, int Length) { for (int i = 0; i < Length; i++) { Coordinate Check = Position + Direction * Length; if ...


3

Haven't come across anything like that yet. But you could check GitHub for games that use Tiled. Then you can download their Tiled files and images. Here's one such repository: https://github.com/bjorn/tiled/tree/master/examples Additionally, you can also do Google searches by filetype and look for .tmx files. You might have to do a lot of searching through ...


0

By speculation - this is what it looks like to me. The arrows seem to, as others say, have an extra variable to determine their height. It looks like an X and Y velocity of the dart might be determined by the direction and power of the power bar, with a predetermined height. I'm not sure if the darts are shot at an upward angle. If not then the flight time ...


0

3D models for something that uses minimalist art is completely overkill. The arrows' effects are most likely produced by 2D art and some math. First, the arrows are given a rotation based on the angle that the player makes with the mouse, upon release of the left mouse button. Then, based upon how long the mouse button was held, the arrows are given a ...


4

I've made projectiles like this in a game and they are most likely 2D for all purposes besides selecting the correct sprite. Then a third Height variable is maintained and some simplified physics is applied. This variable might even be "time in air". So they are likely represented in 2D (x,y) and animated using a third tertiary variable


2

Let me rename the vars (for clarity): Vector3 pos3d = new Vector3 (1f, 2f, 3f); Vector2 pos2d = new Vector2 (1f, 2f); Answer It is because of the section pos3d + pos2d of the line. This part is really ambiguous while the += is not. Let me clarify why one and why the other. Analysis 1 In this line transform.position = pos3d + pos2d; the compiler ...


6

Full issue message: error CS0121: The call is ambiguous between the following methods or properties: UnityEngine.Vector2.operator +(UnityEngine.Vector2, UnityEngine.Vector2)' andUnityEngine.Vector3.operator +(UnityEngine.Vector3, UnityEngine.Vector3)' Unity provided a way to implicitly convert a Vector3 to a Vector2 and vice-versa. This causes an ...


6

How blend states/ blend modes work A blend state defines how newly rendered fragments should combine with existing pixel data. They define how to mix two values: The Source Color - the color you are trying to render. In your case, this is a grayscale value ranging from white (in the center of the disc) to black (at the border of the disc). The ...


0

Great work that you are doing here :D. The thing about advanced collision detection or any technical aspect of programming is getting it done right. To do so, you must separate the mechanic you want, then make it in a separate environment, then test it then port it into your game. in this case, you want to make a separate SAT collision demo first then ...


0

How I would do it: Step 1: define rectangles for the bounds of each room and hallway. Now imagine these rectangles as safe areas where the player can be. "Out of bounds" would be declared as any position in which the player is not fully contained in any of the rooms or hallways. Here's a picture as a demonstration: Now, before we go further, you must ...


1

You don't want to actually resize the sprite. What you want to do is resize the texture this sprite is being rendered on. Once you get the texture you can call Texture2D.Resize(Screen.width * 0.2f, Screen.width * 0.2f) If you're not sure which texture you are using, you can call Sprite.texture to get the texture used. If you wanted to, you could even do ...


1

Please consider this first-party library; it is from MS, so if it is not-third-party enough for you, it will make your life considerably easier. It provides an interface to DX11 that is very similar to XNA. Specifically, SpriteBatch, SpriteFont, etc.. Rastertek and Reimer's are generally helpful. For Rastertek, I linked directly to their DX11 2D tutorial, ...


0

There's a couple ways to do this. One way would be to store a dynamic number of previous positions instead of 100, and only throw old points away when the are beyond the length you want to show. A better way to do this though would probably be to store the last 100 evenly spaced positions where each position is totalDistance / 100 units apart. Basically, ...


0

Upon closer inspection of the bloomComponent's draw method, I realised that when it gets called it re-renders the initial render target so stops the bloom from being applied. SO all I do is now call the draw method of the bloomcomponent to stop it. It seems to run very slow, but that is a different issue all together :-(


6

An AABB is an axis-aligned bounding box. It is a box whose sides are aligned with the axes of the world, and which has extents along each axis. By "AABBvsAABB" your instructor is trying to tell you to make an intersection test between (versus) two AABBs, finding whether they intersect, how they intersect, etc. There are algorithms to find intersections for ...


0

I got the same problem, try this instead of using public GUIText scoreText; Put using UnityEngine.UI; at the top of your .cs file and after that change the variable type from GUIText to just Text like this: public Text scoreText; Complete code for better example: using UnityEngine; using UnityEngine.UI; using System.Collections; public class ...


0

Well, I found how to fix. You have to recreate the project, and then before put all the sprites together, you have to unmark Generate MipMaps and change filter mode to point. Do this without creating a new project(inside of the project already done) didn't worked. Then after replacing all the slices, you put the material with Sprites/Diffuse.


0

if you use function pointers that are set outside of draw loop, you can use 0 if statements to act on functions for each level. make a function that does what you need, and a pointer to that function, and swap out the function by a pointer based on what level you are on. Pointerarray levelaction[10] for 10 levels using different functionality in draw loop ...


1

You can create a Cell and fill that with a tile from the TileMapTileSet, then set that cell at (x, y) coordinates in a particular Layer. For example, the following code sets the tile at (32, 64) in a layer to tile 42 from tile set tileset_name; TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("some_layer_name"); Cell cell = new Cell(); ...


1

You can manually scale it by setting the size to be a percentage of the screen width/height. Make a variable(if you want) that is a value from 0.0 to 1.0 and multiply it by Screen.height(or .width). That is your new width/height. You should make the position relative also. Nevermind that part, you said the anchor works.


0

(Two ideas here. See bottom for the "simpler" one.) Answering exact question: (Instantiate each time the player reaches right/left edge) Assuming your stages are of similar complexity to those in the video you linked, you can simply give unique GameObject tags to each of the dynamic (can be destroyed/deleted) children in the prefab. Then have a global ...


2

You can load the "next" level with: Application.LoadLevel(Application.loadedLevel + 1); You will need to either: Setup the last level as a non-gameplay "You Win!" scene with a different exit condition or; Manually check you don't exceed Application.levelCount. And you can count the number of objects with a given tag with: int campFireCount = ...



Top 50 recent answers are included