New answers tagged

1

Unfortunately - No. Unity only supports: UnityScript (JavaScript for Unity) and C#. Boo support dropped in Unity 5. But C# is very similar to Java, and I for myself started only with Java knowledge and it was no problem for me to learn C#.


0

No. As far as i know, Unity is only made to use JavaScript and C#.


-3

My suggestion is to start using a graphic engine such as Unity or Unreal Engine, mostly because they are the most famous and there are plenty of tutorials and already know issues/solutions. C# can be used as a scripting language in Unity. UE requires c++.


0

So. I figured out the best approach for this. What I ended up doing is drawing a grid image that represents the plane. The image is then mostly hidden behind a viewport that is much smaller. To simulate the draggable grid, the application allows the user to click-drag the image from within the viewport, which allows them to drag around the plane.


2

As it says on the SDL documentation, SDL_GetKeyboardState returns an array of the keyboard state, with SDL_SCANCODE values as indices. You can't use the SDLK_ values, they won't reference the right values. So change your code to use the SDL_SCANCODE values. There is a reference page here. Your if-statement should then look like if ...


2

When you have 2d sprites in a 3d environment, they work like two-dimensional planes. Think of them as cardboard-cutouts which are moving through the world. When you want to rotate these cardboard cutouts to always face the camera, then the search term you are looking for is "Billboarding". It can be implemented by attaching this MonoBehaviour to it: using ...


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.


0

This question on partial path-finding presents one solution - modify your path finding algorithm to remember the node visited that had the closest estimated distance to the target. Eventually, the path-finding will fail to get a route to the target (since it was unreachable), but you will have a path to the closest point encountered while it searched.


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


-2

You can use a coroutines for this task, you should call this coroutine in order to damage you player, so you can set a time of invencibility with the waitForSeconds(3f); function bool finishedCoroutine = true; void OnTriggerEnter2D (Collider2D other) { if (other.gameObject.tag == ("Damage")) { { if(finishedCoroutine){ ...


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


-2

Use a bool variable to make sure you only enter the if once, then reset it after you have left the trigger. Or dont reset it if it has to happen exactly once. void OnTriggerEnter2D (Collider2D other) { if (other.gameObject.tag == ("Damage")&&!isDamaged) { currentHealth = -5f; ...


-2

Create a collection and store a reference of the GameObject once it enters and remove the reference once it exits. For example, here I am utilizing HashSet. using System.Collections.Generic; private HashSet<GameObject> takenDamageFrom = new HashSet<GameObject>(); void OnTriggerEnter2D(Collider2D other) { // If damager and not yet damaged ...


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'm going to give you a rather stupid answer but what the heck. First of all hundreds of objects in a game is no problem. Secondly there is this guy called quil 18 that has great tutorials. Start with the Basics of 2d tile maps and then you can watch this gigantic series about a base building game here


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


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


0

Create a Ui Button at runtime, Working example without prefabs. public static UnityEngine.UI.Button UiTexturedButton(Sprite sprite, Vector2 size, GameObject canvas) { GameObject go = new GameObject("Textured button (" + sprite.name + ")"); Image image = go.AddComponent<Image>(); image.sprite = sprite; ...


0

Take a look at this overload of the SpriteBatch.Draw() method. What you want to do is have the origin argument be a Vector2 with its x-coordinate set to half the width of your final image (and whichever y-coordinate you feel is appropriate), and increase the scale argument from (0,1) to (1,1) over the course of time it takes to "unfold" the paper. Since ...


3

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


0

You can simply do GetComponent<SpriteRenderer>().flipX = true;


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


0

one good way of doing it, is creating a new gameObject where you want the anchor to be, and every frame checking if the player is farther than 1 unit from the anchor. When you want the anchor to stop it's effect, just create a script constantly moving the anchor to the player.


0

You might try adding the collider after the object is instantiated so the calculations are correct. So first remove the collider from the prefab and then : //After prefab is created prefabCloneName.AddComponent<BoxCollider2D>();


0

You can try this GameObject canon = Instantiate(prefab); canon.GetComponent<BoxCollider2d>().size=new Vector2(10f,10f); Increase your canon box collider size based on box collider visible on your scene window.


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


0

It slows down because your transformation is a linear interpolation of a non-normalized vector. That is: as the distance between where the object is now and its target gets shorter, the speed will slow down because you're only moving (say) 5% of that distance every frame. You get this: It's like taking 1 and multiplying by 0.95 20 times and expecting to ...


0

Firstly, if you want the player to hold the up arrow you should use Input.GetKey() instead of Input.GetKeyDown(). Then you can create an empty object and then make the sprite it's child and rotate it so that when ever this empty object is facing forward the sprite is visible. Then you just move the empty object forward by simply applying the force forward ...


0

You can try rendering objects in order of their Y position of the bottom of the sprite/object. Closer to the bottom of the screen = closer to the viewer and therefore obscures anything higher up than it. This isn't very flexible but it is simple.


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


0

Two other options you have are STP and sfml-tmxloader As for the first option I have not tried it. However I've used sfml-tmxloader and found it to be very simple to use, which is also the one I recommend.


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


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


0

Most simplistic way of handling simplified orbits. Define distance for each Celestial body. R=35000 km Integrate Theta Theta=Theta + 0.1 Plot Point by converting Polar to Rectangle X=Rcos(Theta) Y=Rsin(Theta) Want a more realistic process just ask.



Top 50 recent answers are included