Tag Info

New answers tagged

0

What you need to do is control the rocket using steering behavior. At every frame. You want to move the rocket towards its transform.forward, it might be transform.up in the case of 2d. Then you want to lerp the rockets rotation towards the target location transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(target), ...


0

You could make a coroutine and make it delay for some time and then activate the rotation function. The spawning position may be randomized using random.range


1

Do not use full screen quads for your light volumes. A simple way is to draw a sphere for each light, in the position that the light occupies and of the same radius. This way, only the fragments actually affected by the light will be affected and your fragment shader will not be executed for the entire screen surface.


0

The Unity documentation has a good example on how to achieve this with a useful example. http://docs.unity3d.com/ScriptReference/Vector3.Angle.html (example included below for illustration purposes) using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public Transform target; void Update() { Vector3 ...


0

Your orthographic camera size depends on the pixels per unit of your sprites. Orthographic camera size is equal to 1/2 of the vertical units (meters if you use built in physics) you will see on the screen. Say size 6 means that your screen height will be 12 units. The formula is: screen resolution / 2*orthographic size = pixels per unit on sprites


1

In the Enemy script Update //assuming a as half of your vision cone angle //pseudo code foreach target { if (Vector3.Angle(target.position-trasform.position,trasform.forward) < a){ //then target is inside vision cone //next you can check vision distance ... //next you can check obstacles with a raycast ...


1

Usually when a texture is hidden in a 2D game, it's because it goes "in the back" of the screen. When you do lookAt(target), you have to remember that a Vector2 is just a vector3 with z=0 (thus, if you have z=1 for your background for example, it might go behind).


0

Actually the 2D-Vector solved the problem, I don't know why, because I think it should do the same but this is my code now and it's working Vector2 target = Camera.main.ScreenToWorldPoint (new Vector2 (Input.mousePosition.x, Input.mousePosition.y)); Vector2 myPos = new Vector2 (transform.position.x, transform.position.y); Vector2 ...


0

I agree with mostly everything Alan Wolfe said except the following : Since dealing with pairs at a time isn't going to give a global solution in one pass (a resolution to one overlap may make another overlap worse), multiple iterations are done until either there are no overlaps, or the maximum number of iterations has been reached. The system I ...


0

Set your Pixel per Unit to 1 and try witch this: scale = Screen.height / nativeRes.y; pixelsToUnit *= scale; cam.orthographicSize = (Screen.height / 2.0f) / pixelsToUnit; Where nativeRes is your default resolution. Attach it to MainCamera and now your orto size should fit automatically.


1

at the base of some perlin noise implememntatio there's a perturbation array private static int[] p = {151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 88,237,149,56,87,174,20,125,136,171,168, ...


1

As Menno Gouw mentioned, you could use a noise function although you can actually use any PRNG. You will need to seed it every frame though, based off some predictable, relative value, such as the player position. If the player only moves horizontally, then this is simple. seed = player.x I don't suggest a noise algorithm in this case, since the ...


0

You need something like perlin or simplex noise. This will always generate the same noise based on position with a certain seed. Now you can add stars where the noise is a certain level. Simplex and perlin noise always create the same noise based on location and seed. So if you would create a noise ranging from 0 to 255 you could generate a stars at a ...


0

It depends on some points. If you have no problem with programming specially c# or javascript language you should choose unity. If you are a absolute beginner in making game you better choose Gamemaker. I think many game developers started with gamemaker. In the recent years Unity engine have been ahead of gamemaker and many other engines. Briefly if ...


0

There is something to correct, in my humble opinion.. When you do public GameObject[] targets,targetss; void Start () { targets = GameObject.FindGameObjectsWithTag ("right screen"); targetss = GameObject.FindGameObjectsWithTag ("left screen"); } parhaps you should do instead public GameObject targets,targetss; void ...


1

Stated that your examples clearest statement is "Some Code to be Performed" ... You must do some things: Not confuse classes with objects Search all objects ( istance not class) like this public GameObject[] targets; targets = GameObject.FindGameObjectsWithTag("tagName"); foreach (GameObject target in target) { // get collider of each object if ...


0

Your best bet is probably Thought 1: A simple tile map and sprites. Unless you're going full-blown OpenGL then doing things like texturing quads is a bit overkill since you're already using a graphics library. Also, you don't need to make a polygon for your hitboxes; a simple rectangle will do in most cases.


0

You do not have to drag drop animation controller to your script instead you can add component to game object using inspector. Add an Animator component first. On your required key press you have two possibilities as i see: Enable/disable the component as per your need. If you want to run two different states you can use states based animations. Steady ...


1

If you have the height of each corner you can easily find which tile to use. For example on the following drawing, the tile number 1 has hills on its top corner and left corner. The tile number 2 has a hill on its left corner. To know which tile to use you would write something like that : if (top_corner_height == LOW && bottom_corner_height == ...


1

Your point selection rules can be satisfied by a Poisson-Disk sampling distribution & can be solved in O(n) with Bridson's algorithm. Basically, the algorithm divides the output region into a grid of cells sized relative to the minimum allowable distance, such that only one point can appear in each cell. Then, when you consider adding a new point, you ...


0

The dimensions of the Stage (and the parent Group containing the Display Objects) is equal to the absolute value of the combined dimensions and positions of every Display Object in the Group, on the Stage, and in the World. Example: if you have a World that is 100 (width) x 100 (height) but bounded to -50, -50, 50, 50 such that 0,0 is in the center of the ...


2

I've recently been implemented something like this in the MonoGame.Extended library. Creating a letterbox / pillarbox viewport in MonoGame is actually kinda tricky. I'll do my best to provide a good answer here. There's basically 3 parts to it. The first is creating a scaling matrix to pass into the SpriteBatch.Begin call. The variables represent your ...


0

The idea for the rolling hills is as follows: you use the painters algorithm to draw your road; so basically it means you start at some distance in front of the the car and work your way back to the car. I'll try to explain the process with some ACII art :-) Consider this as a hill profile (seen from the side): __ ___ / \__/ 0123456789 The ...


0

Figured it out, here is the code that i made: float angle, speed; Vector2 newVelocity; //use sin and cos to work out x and y speed velocity.x = Mathf.Cos(angle) / speed; velocity.y = Mathf.Sin(angle) / speed; //apply the new velocity to the current object this.GetComponent<Rigidbody2D>().velocity = newVelocity;


1

The way that common physics engines work is that they deal with collision responses for each pair of colliding objects independently. In your case that means when the three circles are overlapping it would try to do something like push the circles apart in each colliding pair by just a little bit. Since dealing with pairs at a time isn't going to give a ...


0

The best way to handle this, is to divide your screen in 2 and check to see if someone is holding down a finger in that area. An easy way to do this, is to add two large Box Colliders on each side of your game scene, which will serve as a hit detection for Touches. Check if the Collider is pressed, and then simulate the corresponding paddle with that ...


4

Totally normal thing to do. You can also render your 3D to one render target and your 2D to a different render target and then draw those over each other in a later pass. That lets you do all sorts of fun tricks, like rendering the 3D in a lower and faster resolution while keeping your 2D in a higher and crisper resolution. This sort of thing is also ...


0

The Minimum Translation Vector is the collision normal most of the time. However, I believe that without velocity information it is impossible to get the collision normal correct all the time. Consider that you have 2 aabbs colliding. One aabb is stationary. In one case, the other aabb moves from the left and hits the first aabb. The correct collision ...


0

Not entirely sure what you are trying to accomplish based on your code. Possibly you are not familiar with the MonoBehaviour object type. Have you tried something like this: Vector2 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition); transform.position = new Vector2(transform.position.x, mousePos.y);


0

You may want to do something like this if you don't want to use prefabs. public void CreateButton(Transform panel ,Vector3 position, Vector2 size, UnityEngine.Events.UnityAction method) { GameObject button = new GameObject(); button.transform.parent = panel; button.AddComponent<RectTransform>(); button.AddComponent<Button>(); ...


1

Prefab your Canvas and a Button and add this script to the test_manager gameobject using UnityEngine; using System.Collections; using UnityEngine.UI; public class TestManagerScript : MonoBehaviour { public GameObject canvas; public GameObject button; void Start () { GameObject newButton = Instantiate(button) as GameObject; ...


1

You can create a script attached to the object you want to drag and adapt your code to work inside OnMouseDown() & OnMouseDrag()


0

You basically found out about transforms and spaces in 2D! If you enter this "new missile space" via translation followed by a rotation then you have to do the same thing in reverse, multiplied by -1. missile.rotate(-30 * TO_RADIANS); missile.translate(-30, -20); Now your missile is in "world space".


0

Since you already have a sorted list of things to render (front to back) do you really need to increment the Z index? Can't you use "less or equal" for the "checking function"? This way it would actually check if a specific pixel was already drawn or not.


1

Looks like you're mixing 3D & 2D physics. You're using OnCollisionEnter2D, which triggers when 2D colliders hit each other. But then you're using Physics.Raycast, which casts rays against 3D colliders - so it won't be able to detect the two colliders that triggered the event, or any similar colliders in your scene. Maybe you want Physics2D.Raycast?


0

To understand my proposal you will have to stop thinking in tiles for a while, even if your finished game needs to guarantee that all objects will be tile aligned. I suggest you to adopt the same design I'm following for my current project. Position your objects in 3D, they have x,y and z. In my case, x is positive to the right; y is positive upwards; z is ...


0

I read your question as can you use C++ to make 2D games in Unreal, to which the short answer is yes. Some key points to bear in mind: Everything you can do in blueprint, you can do in C++. So if you feel more comfortable in making your game in C++, it is fairly straight forward to follow blueprint tutorials and implement them in C++. A few bits and pieces ...


0

Blueprints are designer-friendly, so that you can introduce code-like behaviour from a friendly interface without actually writing code. Mind you, you can use C++ to achieve the same goal. When you write your C++ code, you can add some macros (UE tutorials show how) in your code to make it "visible" as blueprints. It's not an advertisement; it's a really ...


0

Take a Look at Texture2D.GetPixel You can find the contact point on the collider and then map that to the specific point on the texture.


1

Please take note that the question was unclear and changed meaning 3 times, hence the 3 answers in one How can I verify that a given size is a multiple of another? This is a very good case to use the Modulo operator. Let's say you have a texture tex with size (width, height). Now you want to render the texture with size (drawWidth, drawHeight) on the ...


0

Managed to fix this by using Viewports when drawing the Rectangles / Cameras GraphicsDevice.Viewport = new Viewport(_level); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, _camera.ViewMatrix); DrawLevelTiles(); spriteBatch.End(); GraphicsDevice.Viewport = ...


1

Having done both, I can say that using a single quad is best in circumstances where none of your larger objects take up more than one grid square and/or are square/cube-shaped. Otherwise, you will eventually run into Z-sorting issues. The multiple-quad solution was the best one that I found to deal with that particular situation. IE, if you had larger, ...


3

The default sprite size in Unity is 100 pixels per unit. This means that if you have a sprite that is 100 pixels wide, it would occupy "1" Unity unit. If you moved this sprite to the left by 1 unit, it would shift 100 pixels to the left. You can change this value by selecting your sprite, and changing its "Pixels per Unit" property. I typically set my ...



Top 50 recent answers are included