Hot answers tagged

3

Here: perlin.lerp(v, perlin.lerp(u, perlin.grad(self[AB + 2], x , y , z - 1), This should have AA + 2 instead.


3

According to the Unity documentation for OnTriggerEnter2D the trigger is "[s]ent when another object enters a trigger collider attached to this object (2D physics only)". The function should only be called once per entrance. You could gather further data by logging the number of calls to OnTriggerEnter2D and OnTriggerExit2D. Perhaps some funny business is ...


3

Unity remote sends a compressed stream from the editor to your phone and then sends back the inputs from the phone to the editor. there is nothing you can do about it being bad quality. How ever this does not represent the final quality of the build. Try making a real build for android and check how it looks then.


3

I guess what you're looking for is what's called "Worley's Noise". https://aftbit.com/cell-noise-2/ It's very similar to what you're already doing. But instead of placing the points at the corners of the grid and moving them around, you place one (or more) points within each cell at random. When you want to find the closest point to a point P, you find ...


3

first time here, have some time to kill so this is what I did. I'm assuming this is in a gui/2d game. This is what i did to get it to work. create a canvas and add 4 UI images. These act as the 4 points(vector3's) create a script and setup a way to draw lines so that you know that you are getting the right positions now you can move the images to make ...


2

Yes. For 2D sprite-based games, AWT can be used to handle the rendering to great effect. It can even be hardware accelerated, depending on the available hardware. Without any code or detailed profiling snippets, it's hard to say what the issue is. Best I can do is offer some basic tips for working with Java and AWT when building games. Working with the ...


2

Let s1 and s2 the segments, so you can calculate the angle of each using atan2(s.p1.y-s.p2.y,s.p1.x-s.p2.x) where p1 and p2 are the two points defining s; double theta1 = Math.atan2(s1.p1.y-s1.p2.y,s1.p1.x-s1.p2.x); double theta2 = Math.atan2(s2.p1.y-s2.p2.y,s2.p1.x-s2.p2.x); Taking the absolute value of the difference, you get the angle between the ...


1

I've been thinking about this problem for a long time and looked at some of the answers here and on other forums. I came up with the following idea: Suppose the circle has radius R. When looking at cases where the circle collides with the AABB , the center of the circle has to fall within a certain area around the AABB. The extreme cases are when the center ...


1

Modifying the velocity will interfere with your physics if you're not sure of what you're doing. Ideally, you'd move things around by adding forces. Using Rigidbody2D.AddForce is the least complicated way to move objects that have a RigidBody.


1

I would recommend you to place the 2d sprite not in the game world but instead place it on a UI canvas with "Screen Space - Overlay" mode. You can convert the game-world position of a GameObject to screen-coordinates using Camera.WorldToScreenPoint. Then you need to convert the screen coordinates to canvas coordinates and place your sprite there. Code ...


1

Ok, what you need is a quaternion. The rotation variable that you mentioned. So to correctly create a quaternion in the direction you want you need to create it using the eular method.So to create your object: Instantiate(Resources.Load("P1Bullet"), transform.position, Quaternion.Euler(-90f, 0f, 0f)); As I don't know the direction you want to face and ...


1

It isn't that clear what you mean with top and height, but let's say you have your character's x, y, width and height, and so you do for the wall (assuming the x and y values are on the top-left corner of the character/wall, and the y axis gets greater when going downward) if (character.y + character.height > wall.y && charcter.x + ...


1

If you want to accomplish something like this: You can do this pretty easily. If you create 3 different gameobjects, each with a SpriteRenderer: The Gameobject on the left, has a blank image with a pivot set to TopLeft. The Gameobject on the right, has the same image, however, the pivot is set to the TopRight. Re-position these gameobjects, so ...


1

Unity provides a helper method to deal with exactly this kind of situation: Vector3 followXonly = new Vector3( target_position.x, transform.position.y, transform.position.z); transform.position = Vector3.MoveTowards( transform.position, ...


1

Here are two extension methods that will help you: /// <summary> /// Returns the positive angle in degrees of given Vector2. This method assumes +X axis is 0 degrees. /// </summary> public static float Rotation(this Vector2 vector2) { return Mathf.Atan2(vector2.y, vector2.x) * Mathf.Rad2Deg; } /// <summary> /// Rotates the Vector2 ...


1

I found a paper from Epic Games on how they do their area lights - relevant info starting on page 16. Essentially, you find the shortest distance to the line segment that defines your light source, and use that as the source of a light - in their case, a point light, but you could easily use your spotlight instead. They also use a calculation for the ...



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