Hot answers tagged

3

Sounds like you haven't installed build support for Linux binaries in Unity. The way to do this in Unity can be found here: Open the Hub. Select Installs. Find the Editor you want to add the components to. Click the three dots to the right of the version label, then select Add Modules. (NOTE: If you didn’t install the Editor via the Hub, you will not see ...


2

Let's assume that although it takes time to change our momentum, we're allowed to change our acceleration vector instantaneously. (If we have to model gradually changing acceleration over time, computing the optimal intercept trajectory gets much harder, so I'd argue it's not worth it - the trajectory we'll get this way still has \$C_1\$ continuity, so it ...


2

Awake() and Start() are called only once per object for reasons unrelated to Singletons. The single instance part of the singleton is fine, and its possible to make it thread safe and control how many things its keeping in memory because it never dies. It's the global accessibility that a lot of design pattern people dislike. Having a singleton in your code ...


2

When you have a data-structure which fits your design workflow but is bad for runtime, then you always have the option to convert it into a more runtime-appropriate data structure at game startup. Your current architecture seems to allow you to quickly see which rank unlocks what content. But you might also require the reverse: On which rank is a specific ...


2

Run this from an Editor script to copy your AudioSource to the prefab: UnityEditorInternal.ComponentUtility.CopyComponent(source.GetComponent<AudioSource>()); UnityEditorInternal.ComponentUtility.PasteComponentAsNew(source.ebullet); This does not work at runtime, but you can update your prefabs in the Editor and then they'll be good to go at runtime....


1

Well I got a few tips for you to try to get it working : I'm not really sure what the exact issue is. I think it might might actually be a bug in Unity. Anyways, it deals with the SpriteRenderer and the order in which it is applied to the gameobject (relative to the Particle System).Try to remove the SpriteRenderer, and then add it (or just create a whole ...


1

Click on the image asset in your "Project" tab and check its import settings in the "Inspector" tab. For pixel art you usually want the following settings: Texture Type: Sprite (2D and UI) Filter Mode: Point Compression: None


1

Click on your texture, the texture import settings appear in the inspector window.... look for Filter Mode... bilinear, trilinear, point. Try changing it to Point(no filter) and that should eliminate any distortion. And what do you exactly mean by distortion? It seemed fine for me when I imported with point filter mode. Anyway let me know if it worked.


1

An elegant solution popped into my head: The core of it is this code that should run each frame: Vector3 desiredVector = (destination - transform.position).normalized; Vector3 currentVector = body.velocity.normalized; accelerationVector = desiredVector - currentVector; This code picks an acceleration vector that will counteract momentum that is moving us ...


1

This type of thing is often implemented using some form of the Singleton pattern. Here's one version, fairly similar to what you're doing now, just without the redundant double-search for the object, then the component, when all you really wanted was the component: public class Player: MonoBehaviour { static Player _instance; public static Player ...


1

For minimum loading times, you can have both the world map and the battleground in the same scene as two different gameObjects. One option would be to have both of them in the same space as two different gameObjects and just deactivate the one you are not currently playing on. You can also keep both active and use rendering layers to tell the camera which ...


1

The main advantage of Addressables is that they make it very easy for your game to acquire a certain asset by name at runtime. This used to be pretty annoying with asset bundles. First you had to know in which asset bundles that asset was hiding in. Then you had to find out if this asset bundles was already loaded, and when it wasn't you had to load it first....


1

some special prefabs or gameobjects need a certain parent object. for example any Unity UI object needs to be parented directly or indirectly with canvas object. NGUI is the same and any ui object needs to be parented with object with UIRoot Component with same layer. in new version of ngui its handled but in older versions Unity doesnt know what is the ...


1

After DMGregory's comment, I'm rethinking my answer. You are already on a right way, actually. Let's say some other script assign target (the player) to your NavMeshAgent (enemy). It can be done through public variable or through a method. As your target is assigned, you want to check, what is the distance left to it and if it is smaller than some threshold (...


1

It looks like you want to do something like this, using PlayerPrefs to store the state between runs of the game. (This is insecure, but so is using the local system time - if a player wants to cheat, they can just change their local clock anyway, so we might as well keep things simple) using System.Collections; using UnityEngine; using UnityEngine.UI; using ...


1

Your if-else block for constraining the position of the stick looks like this: if (currentPoint.y >= 2.7f){currentPoint.y = 2.7f;} if (currentPoint.x >= 2.5f){currentPoint.x = 2.5f;} if (currentPoint.y <= -2.7f){currentPoint.y = -2.7f;} if (currentPoint.x <= -2.5f){currentPoint.x = -2.5f;} This is going to lock the stick in a square region, not ...


1

You don't need to reset the mouse axes. The mouse axes (e.g. Input.GetAxis("Mouse X")) reflect mouse movement over the last frame. If you do not move the mouse, the value returned from this axis will be 0. You need to reset your fields horizontalRotation and verticalRotation in your OnTriggerEnter().


1

Following @DMGregory's excellent feedback, I wrote the following class to test: public class MaterialTextureTest : MonoBehaviour { public Material material = null; public List<string> textureNames = new List<string>(); public List<Texture2D> textures = new List<Texture2D>(); // Start is called before the first frame ...


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