2D procedural veins cumps of weighted ores rocks I'm evaluating methods for generating "clumps" or "veins" of rocks in a 2D top down procedural game. Obviously the most common suggestion is to use various types of noise, but I feel like noise (alone) won't achieve what I'm after. I've used a combination of voronoi and perlin noise because it's easier to generate "regions" of different noise. I can more easily turn these areas into "veins" of rocks or something than I could be using a "heightmap" alone heightmaps tend to be more swirly cloud like. With a high threshold and some rounding, I can turn this into a mask that works well for veins Changing the spacing and scale is as simple as toying with the math threshold. The difficulty lies with choosing which "rock" (or "ore") will fill each vein. Primarily, this is thanks to the fact that my rocks are weighted. Veins of rare rocks should not be common. I currently map the original voronoi cell value to a specific rock, which forces each vein to be a single type, but can't be weighted. As you can see in picture 1, there's a fairly even distribution of each shaded area. So either, I need a new way to choose a weighted random rock type for each vein, or I need a new way to place veins. Minecraft is a good well known example of what I need, except I work in 2D Regularly distributed ore veins Veins of common ores are found more often and are typically larger veins Veins of rare ores are harder to find, and are smaller in size Noise alone just can't seem to produce these values. What else can I try?


How can I add an IsTrigger propriety from code? Unity I made an gameobject in my script and i made it a rigidbody, and added it a boxcollider, but I dont know how to tell the program to make it a trigger. Here's my code until now multi new GameObject() multi.AddComponent lt Transform gt () multi.transform.position new Vector2(1f, 1f) multi.AddComponent lt Rigidbody2D gt () multi.AddComponent lt BoxCollider2D gt ()


Unity OnTrigger detection issue with Child of Prefab I'm trying to make a set of tiles on the floor of my 3d world visible only when the Player is nearby them. This will work as single tile prefabs. Just not if I set them within an empty parent gameobject... which is what I really need, ideally, for the sake of game performance. Once I put them inside the empty parent gameobject, OnTrigger stops working or even registering (debug.log doesn't show anything). Does anyone know the correct way to access and switch the MeshRenderer on off via OnTrigger (or OnCollision might be even better... I've tried and same issue) when I have a LevelManager that loads all my game objects at runtime? The Level Manager instantiates a prefab (clone), which has an empty gameobject that's holding the tiles as children? Code I've tried and that's not working so far public class CubeVis MonoBehaviour Use this for initialization void Start() Update is called once per frame void Update() private void OnTriggerEnter(Collider other) Debug.Log("hit") if (other.gameObject.CompareTag("Cube")) Debug.Log("hittt") other.gameObject.GetComponentInParent lt MeshRenderer gt ().enabled true other.gameObject.GetComponentInChildren lt MeshRenderer gt ().enabled true other.gameObject.GetComponent lt MeshRenderer gt ().enabled true Inspector Hierarchy info as requested


Unity 5 Place objects in game to closest gameobject I am making a puzzle game in unity3D 5 for school and one of the puzzles is this The player (third person) can pick up certain objects (4 objects) and has to place them inside holes in a wall in a specific order for a door to open. I have 4 empty gameobjects named as slot001, slot002, slot003 and slot004 at the right positions at the holes in the wall. When the player has an item held and a certain button is pressed I link the transform of the object to the transform of the empty gameobject. The problem is that the objects transform has to link to the transform of the closest gameobject. So when you stand in front of the slot002 gameobject the objects transform should link to the transform of slot002. The same goes for slot 001, 003 and 004 ofcourse. I am not sure how to do this. I put the 4 empty gameobjects (slots) in a list. I know of the Vector3.Distance() function and I tried using that to check for the closest distance with Mathf.Min() but I couldn't quite get it to work. Any help or a nudge in the right direction would be appreciated! Thanks.


How to organize the highlighting of a 3D object with which contact occurs? I want to repeat a certain "Select () Deselect () ", as shown in the screenshot. Prompt with advice how to implement it or what you need to read to implement this feature. I tried to found something similar to what I want to do. PlayerInteraction.cs from Farm Alarm game by Brackeys private void OnTriggerEnter2D(Collider2D col) if (target ! col.gameObject amp amp target ! null) Deselect() target col.gameObject SeedBarrel barrel target.GetComponent lt SeedBarrel gt () if (barrel ! null) barrel.Select() SpriteRenderer srs target.GetComponentsInChildren lt SpriteRenderer gt () foreach (SpriteRenderer sr in srs) sr.color new Color(1f, 1f, 1f, 0.9f) private void OnTriggerExit2D(Collider2D col) if (col.gameObject target) Deselect() target null void Deselect() SeedBarrel barrel target.GetComponent lt SeedBarrel gt () if (barrel ! null) barrel.DeSelect() SpriteRenderer srs target.GetComponentsInChildren lt SpriteRenderer gt () foreach (SpriteRenderer sr in srs) sr.color Color.white But if I understand right it's way for 2D. P.S. Screenshot from the game "Overcooked"


Execute native ios code in unity I want to execute native iOS code in unity. For this I have added two files in plugins ios. ViewController.h ViewController.m Code for each file represented as under. ViewController.h interface ViewController (void)sampleMethod end ViewController.m import "ViewController.h" implementation ViewController (void)sampleMethod NSLog( "Sample Method Execute") end For C file I have added following code DllImport(" Internal") private static extern void sampleMethod() and call to above method sampleMethod() When I am export project for iOS, xCode give me following error that I can't able to understand. I can't able to understand how to solve this problem? Please give some suggestion here. EDIT I have added extern keyword in my .m file after reading some suggestion. import "ViewController.h" implementation ViewController extern "C" (void)sampleMethod NSLog( "Sample Method Execute") end But in xCode now I am getting Expected Identifier or '(' at the line of extern keyword line. So what to do next?


Mouse Input Unexplained Behavior Unity3D Input.GetMouseButtonDown(0.....6) in documentation it says that you can pass, 0, 1, 2 as parameter. Input.GetMouseButtonDown. It doesn't accept negative numbers like 1 or numbers 7 . What does 3 4 5 6 do? What input are they calculating? Or can I use these numbers as default for None state? I couldn't find any information about this.


(Unity) Is there a way to automatically create a material for each texture and assign the texture to it? I have imported hundreds of textures in my Unity project, and I'd like to create a material for each of them. This would obviously take a lot of time, so how would I go about doing this automatically? These are just basic textures that I want to assign to albedo on the standard Unity 5 shader. No need for normal maps.


How to add ingame tutorial for first time? I want to know how to show tutorial when player playing for First time. Only once


Only 4 point lights display in unity When ever I have more than 4 point lights in my scene, only 4 show up. Why does it do that? Is there anything I can do to show more than 4 at a time?


Scale object based on another object's position Despite an hour or so of Googling I can't seem to figure out how to calculate the scale factor based on distance. Here's the illustration of my problem. I've tried manipulating the x values and such, but until now I still cannot figure it out. Here's the snippet Vector3 v3Scale frontWall.transform.localScale frontWall.transform.localScale new Vector3(v3Pos.x 2.0f , v3Scale.y , v3Scale.z) Any ideas? Thanks in advance! UPDATE if(getTarget.CompareTag("LeftRightWall") amp amp getTarget.transform.childCount 1) float translate getTarget.transform.position.x getTarget.transform.GetChild(0).gameObject.transform.position.x Debug.Log("value " translate) foreach (GameObject frontWall in GameObject.FindGameObjectsWithTag("FrontWall")) Vector3 v3Scale frontWall.transform.localScale float scaleFactor translate frontWall.transform.localScale.x frontWall.transform.localScale new Vector3(translate , v3Scale.y , v3Scale.z) v3Pos.z getTarget.transform.position.z v3Pos.y getTarget.transform.position.y getTarget.transform.position v3Pos getTarget.transform.GetChild(0).gameObject.transform.position new Vector3( v3Pos.x, v3Pos.y, v3Pos.z) The LeftRightWall is the ones that I drag on the picture, with another vertical line as its child. The FrontWall is the horizontal line that is stretched when the LeftRightWall is dragged. Hope its clear enough. Thanks UPDATE This is the closest one from what I'm trying to achieve... (( Here's the code float translate getTarget.transform.position.x getTarget.transform.GetChild(0).gameObject.transform.position.x Debug.Log("value " translate) foreach (GameObject frontWall in GameObject.FindGameObjectsWithTag("FrontWall")) Vector3 v3Scale frontWall.transform.localScale frontWall.transform.localScale new Vector3(translate v3Pos.x, v3Scale.y , v3Scale.z) UPDATE This is what I'm able to do so far, thanks to the answer below. However I still don't know why the other side of the panel is behaving like that. The scale of horizontal lines also shrinks when I click on the vertical line. This is the updated code ray mainCamera.ScreenPointToRay(Input.mousePosition) float dist plane.Raycast(ray, out dist) Vector3 v3Pos ray.GetPoint(dist) if(getTarget.CompareTag("LeftRightWall") amp amp getTarget.transform.childCount 1) float translate getTarget.transform.localPosition.x getTarget.transform.GetChild(0).gameObject.transform.position.x Debug.Log("value " getTarget.transform.GetChild(0).gameObject.transform.localPosition.x) foreach (GameObject frontWall in GameObject.FindGameObjectsWithTag("FrontWall")) Vector3 v3Scale frontWall.transform.localScale float scaleFactor (translate v3Scale.x) frontWall.transform.localScale new Vector3(v3Scale.x scaleFactor, v3Scale.y, v3Scale.z) v3Pos.z getTarget.transform.localPosition.z v3Pos.y getTarget.transform.localPosition.y getTarget.transform.localPosition v3Pos getTarget.transform.GetChild(0).gameObject.transform.position new Vector3( v3Pos.x, v3Pos.y, v3Pos.z)


Unity GL.Lines going over 3D models I'm drawing lines using GL.lines but they disregard the zbuffer and always appear over my model. I found this thread http answers.unity3d.com questions 434827 gllines over game objects.html and decided to give the answers a try, but it didn't seem to fix things. For now I'm using the shader found in that thread, here is the rest of the code void OnPostRender() GL.PushMatrix() testMaterial.SetPass(0) GL.Begin(GL.LINES) for (int i 0 i lt basicMesh.linePoints.Length i ) GL.Color(new Color(1,1,1,1)) GL.Vertex(basicMesh.linePoints i .point1) GL.Vertex(basicMesh.linePoints i .point2) GL.End() GL.PopMatrix() Any advise on how to make the lines not go over my 3D models?


Full Engine or Not C Programmer Trying to get into Game Development I'm a fairly experienced programmer, and I want to try out doing some game development. However, I am unsure of whether or not to use a full engine like Unity or just start with something like OpenGL. How much flexibility extensibility do you use going with Unity. I know it can be used with minimal coding, but if you can write your own code, will it constrain you later down the line? For my first project I want to just build a simple tile based rpg and build it up to something larger. Any advice is welcome.


In Unity, is there a difference between Vector3.down and Vector3.up? I've noticed numerous tutorials and examples using something like "transform.up 1" or " Vector3.up" instead of simply saying "transform.down" and "Vector3.down". Is there a good reason for this, or is it simply a style difference? I'm specifically thinking about downward raycasts, if that matters at all.


Find References In Scene of scriptable object unity asset shows incorrect results I'm trying to work out why my game is loading a large sprite atlas that I don't think it should be. The snapshot view of the profiler shows that the atlas is loaded. The references pane shows that it's loaded through a scriptable asset object. That object does indeed reference the sprites in the atlas but I don't think the object is referenced in the scene at the moment. The game boots to this scene, so the atlas should not be loaded. I've replicated this profiling on both the editor and on android, so it's not an editor only thing. When I right click on the scriptable object in the project view, while the game is running, and Find References In Scene, it shows a few game objects. None of these objects seem to reference the scriptable object. None even have monobehaviours with fields for this type of scriptable object. Some are new UI button objects, that have Canvas Renderer, Image and Button scripts only. None of which could be referencing this scriptable object. Has anyone seen this behaviour before? What's going on?


Player is instantly teleported back I built a teleporter that changes a players position and rotation. He is instantly teleported back. Why? I'm using the standard FPS Controller.


Can I develop a game for Kinect without a Kinect? I have to make a game in Unity3D using Kinect. The problem is I don't have the Kinect yet. I need to wait until they deliver it to me. Can I imitate Kinect's movement for debugging my app?


How do I keep a rigidbody from making unnecessary collisions on smooth surfaces in Unity3d? I have been having trouble with a custom character controller I am making. The root of the problem lies with collisions. I am trying to make movement code, but I have a problem with ground movement. Pay attention to this gif. It might be hard to notice due to the low frame rate, but the collider registers collisions with objects (in red) that do not point out of the ground. They share the same y position as the ground. I've printed the normals of the collisions, and there are a lot of normals that are perpendicular to the normal of the ground (which is causing the rigidbody to get stuck). The problem lies with collisions in unity. If I were to print the y position of the bottom of my collider, it would be just a tad lower than the y position of the ground. The collider actually rests below the ground by an almost negligible amount (which is why it doesn't always collide with these objects). Here is what I have tried I created a function that runs at the beginning of every FixedUpdate() that uses current collisions to change the y position of the rigidbody. It only runs on collisions that would ground the player (meaning that they are below the collider). The problem with this approach is that the same issue can occur with walls, meaning that the collider can get stuck on walls. I cannot create another function that would do the same for walls for various reasons. Here is what would fix the issue I need help figuring out how I can make collisions more discrete in unity. Colliders rest slightly below objects when ontop of them. They can also "sink" just a little into walls. In other words, colliders can rest into other colliders, and I need this to stop. Any help is appreciated. Thank you.


How do I import 2d character assets in unity? I recently downloaded a 2d platform assets that came with a player model. The character came in a lot of pieces like an image of eye, another for torso, etc. How do I go about making these images an actual character. The asset also came with a few animations like blinking, jumping, etc. How do I apply these? I'm new to unity and game development(started about a few days ago) so please help even if this may sound like a really dumb question. I use Unity BTW if it changes what the answer would be. Link to asset https assetstore.unity.com packages 2d environments free platform game assets 85838


How should I store trading cards? I'm working on a Magic esque TCG in Unity. Currently, the cards themselves are all prefabs I have a Satyr Archer prefab, a Candle Wisp prefab, etc. This works fine for now, since I only have a few cards, but by the time I get to several hundred, I feel that this may become unwieldy. Are prefabs a good way to store a large list of cards? Should I be making those prefabs using an XML document and a script?


Unity assembly files missing from "Temp bin Debug" I'm trying to use VS Code on a Mac with Unity and C . When I try to open a Unity project in VS Code, it can't load Assembly.dll files from few locations which are defined by default in .csproj files "Temp bin Debug ". When I check the Temp bin Debug paths, while Unity is running, they are empty they doe not contain the assembly files, where I assume they should. The files are in "Library ScriptAssemblies". Moving them is not an option, because I would have to do that manually every time I change sth. in any script file. Changing the path in the .csproj files is also not a good idea, because those files get rewritten every time you open a project in Unity. This issue causes lot of problems in the editor WARNING OmniSharp MSBuild Unable to resolve assembly ' ... Temp bin Debug Assembly CSharp firstpass.dll' INFORMATION OmniSharp MSBuild Update project Assembly CSharp Editor firstpass WARNING OmniSharp MSBuild Unable to resolve assembly ' ... Temp bin Debug Assembly CSharp firstpass.dll' INFORMATION OmniSharp MSBuild Update project Assembly CSharp Editor WARNING OmniSharp MSBuild Unable to resolve assembly ' ... Temp bin Debug Assembly CSharp Editor firstpass.dll' WARNING OmniSharp MSBuild Unable to resolve assembly ' ... Temp bin Debug Assembly CSharp firstpass.dll' All type references coming from my custom scripts and the UnityEngine namespace are missing, and highlighted as errors However, intellisense seems to be working fine for UnityEngine types I tried to reinstall MonoDevelop it a few times, including a brew and downloadable package. MonoDevelop seems to be installed properly mono version Mono JIT compiler version 4.6.2 (mono 4.6.0 branch ac9e222 Wed Dec 14 17 02 09 EST 2016) Copyright (C) 2002 2014 Novell, Inc, Xamarin Inc and Contributors. www.mono project.com emsp emsp TLS normal emsp emsp SIGSEGV altstack emsp emsp Notification kqueue emsp emsp Architecture x86 emsp emsp Disabled none emsp emsp Misc softdebug emsp emsp LLVM yes(3.6.0svn mono master 8b1520c) emsp emsp GC sgen .NET works as well dotnet version 1.0.0 preview2 1 003177 How do I fix this?


Instantiated object can't be parented I'm writing a script (in C ) which, on mouse down, will spawn a gun and parent it to a game object. But for some reason the gun is instantiated just fine, but it doesn't parent. I have an empty game object called "Hands" and I'm trying to have the gun become a child and be moved to the position of "Hands". To test what was going on I made two scripts, one which would parent the object upon pressing P, while the other script would just instantiate the item on mouse down. It worked, I first spawned the gun with mouse down, and then pressed P and it was parented. So my only guess is that you can't instantiate and parent in the same script all at the same time. I have absolutely no clue what's going on, so I really appreciate any help I can get. This is my code using System.Collections using System.Collections.Generic using UnityEngine public class GiveWeapon MonoBehaviour public GameObject Weapon public GameObject Hands void OnMouseDown () Instantiate(Weapon) Hands GameObject.Find ("Hands") Weapon.transform.parent Hands.transform Weapon.transform.position Hands.transform.position


How to return the scene view camera to the default view By the quot scene view camera quot I don't mean a GameObject with a Camera component, I mean the camera used to draw the Scene window in the Unity editor, controlled by this quot Scene Gizmo quot widget The default view shows an almost isometric perspective, where all three X Y Z axes are visible. But when I clicked the green Y cone, my view changed to look straight down the Y axis, and I can't seem to return to the 3 axis view. Clicking the other cones on this widget just switchest to look along the X or Z axis instead, and clicking the cube in the middle or the quot Top quot label just toggles between orthographic and perspective projection. How can I get back to the default 3 axis view?


How can I make an update patch for a Unity game on Windows? I ran into trouble making a PC game using Unity. If I try to update my game, I can't a update the C scripts (because AssetBundles don't include C scripts) So I think I'll need to use a server and patch all files. But I don't know how to do so... How can I make an update for my Windows game?


Rotate from Current Rotation to Another using Angular Velocity I am attempting to calculate an angular velocity that will get me from the current gameObject.transform.rotation to a given Quaternion rotation using angular velocity. I've tried several methods but all of them seem to cause oscillation (maybe due to the gimbal nature of Vector3 for angular velocity). Here are the pieces of code that I have tried Quaternion rotationDelta Quaternion.Inverse(gameObject.transform.rotation) remoteRotation return (rotationDelta.eulerAngles PlayerMovement.BROADCAST INTERVAL) Another attempt using toAngleAxis rotationDelta.ToAngleAxis(out angleInDegrees, out rotationAxis) Vector3 angularDisplacement rotationAxis angleInDegrees Mathf.Deg2Rad return angularDisplacement PlayerMovement.BROADCAST INTERVAL Using Eulers Vector3 difference new Vector3(Mathf.DeltaAngle(gameObject.transform.rotation.eulerAngles.x, remoteRotation.eulerAngles.x), Mathf.DeltaAngle(gameObject.transform.rotation.eulerAngles.y, remoteRotation.eulerAngles.y), Mathf.DeltaAngle(gameObject.transform.rotation.eulerAngles.z, remoteRotation.eulerAngles.z)) Vector3 differenceInRadians new Vector3(difference.x Mathf.Deg2Rad, difference.y Mathf.Deg2Rad, difference.z Mathf.Deg2Rad) return differenceInRadians PlayerMovement.BROADCAST INTERVAL


What's the better approach, running multiple server builds on one instance or running one server build and managing matches in different rooms? We are building a racing multiplayer game using Mirror and Unity and we've been able to successfully run the authoritative server on AWS Gamelift and Playfab so far. Both providers are with the flexibility of running multiple server builds and mapping with different ports. So I think running multiple server build for different matches on one instance is a bit expensive in terms of server usage as compared to running one server and managing multiple matches in different rooms. But overall it seems to be a safer option to go with since build crash and similar issues will only happen on one match and other matches (servers) will be running fine on the same machine and also it's a bit easier to handle and scale. What's your opinion on this? It might be useful if you share any blog or resource to look at for scaling and managing servers on gamelift playfab. thanks!


Unity3D Sprite tearing on Android Smartphone The game was running on Samsung Galaxy Trend 2. On other smaptphones and emulator it seems running properly without glitches. Sprites import settings are following Could someone explain why this happens?


How to continue firing when button is touched? How to continuos firing when user touch (and keep press) a button in Android iOs? Using onClick, i can fire only one shot. Is there an event like "keep touch" ? Thanks


How can I launch Visual Studio via a double click on a C script in Unity? This is my first time using Unity and I am following the tutorial for the 2D RogueLike Game. Everythings seems to be working properly, apart that I cant get Visual Studio to launch, if I'm double click my c scripts. What I have tried so far Checked my preferences, that External Script Editor says "Visual Studio 2017" Reinstalled Unity and Visual Studio. Unity Version 2019.3.0a2 Personal Hope somebody can help me. Additional information After double click, nothing seems to be happening, even my mouse doesnt show a load icon When I create a new project, the bug (dont know if bug, or my fault) is still there. I can open the .sln file from my project in Visual Studio. Visual Studio can even autocomplete unity based code then, before it was a "miscellaneous file" and didnt autocomplete code like for example "Transform" or "Rigidbody2D".


Can I run old projects after updating Unity? Today I decided to upgrade unity from 5.0.0 to 5.5.0. But before updating it, I wanted to know Can I run build my projects made in Unity 5.0.0 in Unity 5.5.0?


How unity works on Web How Unity can work on Web if the code is written in C ? I understand that you can compile the C code to a shared library and use it in Java (for Android) in ObjectiveC (for iOS) to enable Unity on multiple platforms, but you cant use shared library on JS. Does Unity do language to language translation from C to JS to enable Unity on Web? As I understand now starting from Unity 5.0 it even doesn't use Unity Web Player.


Instantly snap into specific directions? In my 2d setup, I want the player to constantly move in a specific direction at a set speed. It's similar to "Snake" in that you can only move in four directions and you can't stop your movement. Right now, the way I do this is by having a char variable "direction", which can either be u, d, l, r (take a guess what those stand for). Based on those letters, I use GetComponent().MovePosition and increase decrease the position on the x or y axis. Is there a better way to do this? I would prefer if I could just enter the degree (0, 90, 180, 270) to make the player move in the right direction. I tried AddForce but I couldn't get it to work. Side note it's important for me that I can set the direction without player input, as there are some objects that force the player into a different direction. Edit As the tag would suggest, I'm looking for a Unity specific answer, as I'm not sure which function would best suit my needs.


How to prepare a rigged character model to be imported as a humanoid in unity? I want to import a character as a humanoid to be able to use masks on animation system. I used proper human structure but unity gives some errors when I want to turn it from generic to humanoid and says some bones are not in the right place or have a wrong name. The questions is how should a rigged model be prepared in modeling program to be imported in unity as humanoid?


Dissolve object starting from the bottom I'm currently getting into using the new "Unity Shader Graph"s and have made an OK dissolve shader that looks like this My next goal is to move this effect so the object dissolves bottom up. This is where I'm stuck. I tried blending this effect with another effect that just fades the object from the bottom up but this does not create the effect I am looking for ( 1 is the fade effect, 2 is the two shaders blended together) The end effect should look something like this How can I achieve this effect? Answers do not have to be specific to Unity and a good answer should include the thought process to creating this effect, not just code or pictures of a shader graph.


Change Time.timeScale during an animation event Unity I have an animation. A few seconds after this animation starts I set an animation event that is correctly being triggered. This animation event calls a method where I am trying to modify Time.timeScaleand set it to 0.05f. This event is calling the following method public void Slowmotion() Time.timeScale 0.05f Time.fixedDeltaTime Time.timeScale 0.02f But this Slowmotion method is not working. Any ideas on what may be happening?


Screen record in unity3d How to do screen record in unity? I want to record my screen(gameplay) during my running game. That should be play stop , replay , save that recording on locally from device, open load from my device (which is already we recorded). In my game one camera which can capture native camera, and one 3d model. I wish to record that both and use my functionality whenever i want. Thank you in advance.


Causing Update loop with Coroutine Unity Total Noob Alert! lt 7 days with C and Unity My Win Game screen becomes SetActive and my Player is SetActive false when you are standing in a trigger and crouch. That all works fine except you cant see the crouch animation because he is IMMEDIATELY SetActive false. I tried to delay this by creating a coroutine. The problem with that is this is all happening in the Update function (or whatever it's called) because of the getkeydown for crouch. That gets called once per frame so my coroutine is trying to go off once per frame. I tried creating a bool called isCoroutineStarted and set it to false and then set it to true in the Coroutine to break the loop but that didn't work either. Don't know what to do so I reverted it back to before where it doesn't show my crouch animation. Here's my script (It's attached to a Game Object with the trigger) using System.Collections using System.Collections.Generic using UnityEngine public class xxxxxx MonoBehaviour public bool xxx false SerializeField private GameObject youWinUI SerializeField private GameObject player Determines whether or not the player is standing on the xxxxx void OnTriggerEnter2D (Collider2D other) xxx true void OnTriggerExit2D (Collider2D other) xxx false Turns on Win screen and makes player disappear when crouch on xxx void Update () if (Input.GetKeyDown (KeyCode.S) amp amp xxx true) youWinUI.SetActive (true) player.SetActive (false) P.S. ignore the x's no stealsies lol. Also this piece of script works as intended I just want a delay so you can see the crouch animation.


StartCoroutine from other MonoBehaviour is not working I am trying to replicate the model of Unity documentation about coroutines, but I want to partition it in another class I have these two public class A MonoBehaviour void Start() print("Starting " Time.time) B test new B() StartCoroutine(test.WaitAndPrint(2.0F)) print("Before WaitAndPrint Finishes " Time.time) public class B MonoBehaviour public IEnumerator WaitAndPrint(float waitTime) yield return new WaitForSeconds(waitTime) print("WaitAndPrint " Time.time) It prints, ignoring the coroutine Starting 0 Before WaitAndPrint Finishes 0 The two methods work well in the same class.


Help with NPC following the player in a sidescroller I'm a beginner with C and am having a bit of trouble coding an NPC that follows the player in a 2D sidescroller. The player has two speeds, a walk and a sprint. I have a very basic companion follow script but it's only set on one speed, and if I increase the speed so that the NPC will keep up when the player sprints, the NPC jitters when it follows the walking player, which makes sense. I'm just wondering if there's a way in which the NPC can dynamically follow the player in the exact same speed as the player so that this issue doesn't arise. I figure this would inquire an entirely new script, but that's fine. Again, I'm still new to all this, so any help would be greatly appreciated! Thanks! using System.Collections using System.Collections.Generic using UnityEngine public class CompanionFollow MonoBehaviour public float speed public float stoppingDistance private Transform target Start is called before the first frame update void Start() target GameObject.FindGameObjectWithTag("Player").GetComponent lt Transform gt () Update is called once per frame void Update() if(Vector2.Distance(transform.position, target.position) gt stoppingDistance) transform.position Vector2.MoveTowards(transform.position, target.position, speed Time.deltaTime)


How would I use an object from another animation in Unity? So I have two different .blend files with two different animations. Let's call my aiming with a gun animation animation A, and my other .blend file with idle, run, and jump animations animation B. If I wanted to play the aiming clip from animation A with the Animation B animator, it just looks like my character wants to shake hands, since the gun doesn't appear in the animation. The aiming animation works if I play animation A with animation A's animator. How would I use the gun object from animation A when playing animation A in animation B's animator? Here is an image of what the animation looks like in the import settings (what i want) and in the actual game (what is happening which I don't want.) The top image is what I want and the bottom image is what is happening. Thanks in advance.


Animator.SetBool am I supposed to call it only when its value changes? I've searched around the web for a while, but didn't manage to find anything about it. Despite using Animator in several projects so far, I've never been in this exact situation, so I'm unsure what to do. Does calling Animator.SetBool have any performance issue, so that I'd better call it only when its value has changed, or when its value doesn't change it's so quick that I can call it every frame? Keep in mind that, due to the nature of this question, I don't care if it's slow when I change its value, I only care if it's slow when it's false and I call it to set it to false again (same thing for true ofc).


Physics2D.Raycast not hitting any colliders I am making a topdown 2d game and want to get the x,y of mouse clicks so I can move the character to that location. I am writing a CharacterController script which performs the mouse click check and raycast in the Update function void Update () if (Input.GetMouseButtonDown (0)) RaycastHit2D hit Physics2D.Raycast(Input.mousePosition, Vector2.up) if (hit.collider ! null) Debug.Log (hit.point) This runs whenever I click the mouse, but the if(hit.collider ! null) condition is never met. I've looked around for other solutions, such as Unity Raycast not hitting to BoxCollider2D objects, but when I change my code to the one used in that answer RaycastHit2D hit Physics2D.Raycast( Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.back ) then the if(hit.collider ! null) block is always true, even if I click on empty space, and it always returns the same coordinate. To illustrate this, here is a video of me clicking the game view. The green area has a 2d box collider that is very closely mapped to its boundaries. You can see that the logged hit.point is always the same. video is here https i.imgur.com uhNp8wC.gifv screenshot


How To Create A Dynamic 2D Rope In Unity? I'm trying to create a 2D rope in Unity that is fixed at one end and other is moving up and down to pick up objects just like a crane. I've tried adding a cube and making more instances of it, adding a parent child relation and hinge joint between them when I press the Down arrow. It worked, but when I tried to move them sideways a big noise is generated. I then tried with a spring joint, but that didn't work.


Why do I get a "Value Cannot be Null" error on material.SetTexture? Probably a really noob question, but I'm following this tutorial here and, using the code in the tutorial, I'm getting an annoying error Here's the code in question, the error is referring to line 20 (highlighted in the comments) public class RayTracingMaster MonoBehaviour public ComputeShader RayTracingShader public Texture SkyboxTexture private RenderTexture target private Camera camera private void Awake() camera GetComponent lt Camera gt () private void SetShaderParameters() RayTracingShader.SetTexture(0, " SkyboxTexture", SkyboxTexture) lt Line 20 is here RayTracingShader.SetMatrix(" CameraToWorld", camera.cameraToWorldMatrix) RayTracingShader.SetMatrix(" CameraInverseProjection", camera.projectionMatrix.inverse) private void OnRenderImage(RenderTexture source, RenderTexture destination) Render(destination) SetShaderParameters() private void Render(RenderTexture destination) Make sure we have a current render target InitRenderTexture() Set the target and dispatch the compute shader RayTracingShader.SetTexture(0, "Result", target) int threadGroupsX Mathf.CeilToInt(Screen.width 8.0f) int threadGroupsY Mathf.CeilToInt(Screen.height 8.0f) RayTracingShader.Dispatch(0, threadGroupsX, threadGroupsY, 1) Blit the result texture to the screen Graphics.Blit( target, destination) private void InitRenderTexture() if ( target null target.width ! Screen.width target.height ! Screen.height) Release render texture if we already have one if ( target ! null) target.Release() Get a render target for Ray Tracing target new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear) target.enableRandomWrite true target.Create() I really can't see why it's telling me the value is null when I'm calling the name of an already defined Texture class. I have set the texture from the inspector. Any help would be appreciated.


Same dimension feel no matter what FOV Does anyone know a formula, way, ... to make a FPS player feel like an object has the same size on different FOVs (given that it's at the same distance of the player, of course)? I know that this can't be done perfectly, because of the distortion various FOVs cause and the position of the object (near the edges of the FOV more distortion). Let's ignore these distortions, and aim for a same size feel for objects that are directly in front of the player (so in the exact center of the FOV). To clarify things a bit further I want 1 object in my game to have the same scale feel on different FOVs, not my entire game world. I've tried giving it a percentage of the frustrum height, but that doesn't seem to give me consistent results. Note I'm using vertical field of view in my game.


How to change Texture2D type to Sprite during runtime (Unity) How can we convert the Texture2D type to "Sprite" using the script (not in Editor)? It seems that the Texture2D retrieved from file is by default Normal Map. I need to convert the TextureType to "Sprite". Texture2D texture LoadPNG("D download.jpg") testPlaneRenderer.material.SetTexture(" source",texture) LoadPNG method code public static Texture2D LoadPNG(string filePath) Texture2D tex null byte fileData if (File.Exists(filePath)) fileData File.ReadAllBytes(filePath) tex new Texture2D(2, 2) tex.LoadImage(fileData) ..this will auto resize the texture dimensions. Debug.Log("File Exists!") else Debug.LogError("File not exists!") return tex It seems that this texture is set as "Default" or "Normal" Type when imported from file and then assigned to Material dynamically. As the particular shader I'm using, works best if the Texture Type is set to Sprite (I tested it by manually placing the texture file in Project and then assigning the texture to Material). I need to change Type of Texture to Sprite before assigning it to the material. I've seen options like "AssetImporter" but it only works in Editor. The effect of the shader (which takes two texture types a) Inverted amp Blurred Texture b) GrayScale Texture And then returns a Sketch Effect to the object. I convert the original image to inverted amp blurred, grayscale texture using some image processing code (C , Unity working around with GetPixels and SetPixels)... Output with Defualt Texture Type Output with Sprite Texture Type


How can I get separate caches for different coroutines? (Unity) I want to fade out an image, so I have a coroutine FadeOut(). However, I want to have a separate image each time I call FadeOut. If I try to do something like this IEnumerator FadeOut(GameObject image) SpriteRenderer render image.GetComponent lt SpriteRenderer gt () yield return null Ignoring all the color changing code which I took out, how do I make it so that I can save a separate cache for each image I add? I don't want to run GetComponent() each frame, because I'm running on mobile and because I want to think of a clever way to stash the renderer. For example, if I declare the renderer at the top like this private SpriteRenderer render and want to cache it on the first frame of the coroutine, there's the chance that calling FadeOut() on another object will change the renderer to a new object and the first FadeOut() will cancel. Can I make the method static? Will that cache a private version of renderer?


Setting object position in screen space camera I'm trying to set an Image gameobject's transform.position. My canvas is "screen space camera" because I needed to use a line renderer. However, when I set the position, say to new Vector3( 320, 240) the object (in play mode) gets positioned at 16266.44, y 15360, way off screen. I've tried to reset the localPosition and such based on some other answers but it doesn't help. What else could be translating my pixel coords? var go Instantiate(HexTilePrefab, this.transform) go.transform.localPosition Vector3.zero go.transform.localRotation Quaternion.identity go.transform.localScale Vector3.one go.transform.position new Vector3(screenX, screenY)


DirectoryNotFoundException for an existing file path on Unity startup I'm not sure why this error appears in my console when I start up my Unity editor but it is stopping me from running any Unity projects by pressing the play button. I have tried re installing Unity, checking out the file at the specified file path destination and searched my local Unity folders for any relevant files that are calling for a file path search. I want to know which file is responsible for specifying assigning the file path causing the error. The error message is pasted below with a screenshot of the Unity editor (with the error message in its console) and a screenshot of the specified file in the file path Error message DirectoryNotFoundException Could not find a part of the path "F Computer Science Aston University Work Final Year (for real) Game Development Labs LabSeven Workspaces labSeven Home Vers Library PackageCache com.unity.analytics 3.2.2 Tests Editor Unity.Analytics.StandardEvents Unity.Analytics.StandardEvents.EditorTests.asmdef" System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at 0) System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) (at 0) (wrapper remoting invoke with check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool) System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) (at 0) System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) (at 0) System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) (at 0) System.IO.StreamReader..ctor (System.String path) (at 0) (wrapper remoting invoke with check) System.IO.StreamReader..ctor(string) System.IO.File.ReadAllText (System.String path) (at 0) UnityEditor.Scripting.ScriptCompilation.EditorCompilation.LoadCustomScriptAssemblyFromJson (System.String path) (at C buildslave unity build Editor Mono Scripting ScriptCompilation EditorCompilation.cs 463) UnityEditor.Scripting.ScriptCompilation.EditorCompilation.SetAllCustomScriptAssemblyJsons (System.String paths) (at C buildslave unity build Editor Mono Scripting ScriptCompilation EditorCompilation.cs 681) UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface SetAllCustomScriptAssemblyJsons(String ) Screen shots Many thanks in advance.


Using collision.contacts to determine if on a floor I'm trying to make my own first person character (because I get lost in the sea that is Unity's FP character script), and am trying to make it so it detects when it is standing on a floor. I tried using a playerController, but I've found rigidbody is just more malleable. Anyways, so I think how you'd do it is finding the direction of the contact, and if it isn't straight down, then to keep onGround as false. I'm just not entirely sure the scripting behind this, and several searches have turned up nothing. Several offered using mutliple colliders, but I would prefer to keep the number of objects, colliders or otherwise, at a minimum, considering there will be a large number of them in the scene as is. I also want something that's easily manipulable so that I can add extra features like climbing up a wall or the like, and I think that measuring the angle to the center is about as simple and easily manipulated as it gets.


Real time 3D Scene reconstruction into Physics Engine I am trying to create a game where the user scans the room using RGBD camera and reconstructs 3D scene. This scene would be integrated into physics engine, after an object recognition algorithm tells it what objects are there in the scene and of what shape and size. Finally, after being rendered in Physics Engine, user should be able to interact with the environment. I know how to do 3D scene reconstruction from images, I can figure out how to contruct objects and interact with them in Physics Engine. I know how to do object recognition, shape and size. However, I am not sure how to integrate the output of 3D scene reconstruction, Object Recognition as input to the physics engine. Any ideas would be helpful.


Hardcode per instance properties into the shader in unity I am using one of the packages from the asset store and using its Polyline feature for wire rendering. There are thousands of wires and its taking much fps Batch counts. The reason of the lack of support for static batching. Now there is a workaround suggested by the author of the package. if you don't use polylines for anything other than that, and all your shaders use the same properties, you could hardcode all per instance properties into the shader Due to a lack of shader knowledge(I am developing the knowledge currently and it will take time) I am unable to hard code the above properties I tried and here is the current scenario define int ScaleMode 1 define half4 Color (0,0,0,0) define float4 PointStart (0,0,0,0) define float4 PointEnd (0,0,0,0) define half Thickness 0.5 define int ThicknessSpace 1 define half DashSize 1 define half DashOffset 1 define int Alignment 1 HOw do i correctly hard code above values?


Model mesh overlapping while animating in Unity but not in Blender I made an FPS model in blender and created reload animation when I imported that model in Unity I saw that while the magazine ejecting from the rifle it overlapped some of the gun parts. Then I went back to the blender and changed some keyframes and positions in the blender but in Unity, it showed me the same problem. I tried many times it looks fine in the blender but in the Unity, it has the same problem.


Unity2D Child class inheriting onCollisionEnter() methods I may be an idiot for asking this but I can't seem to solve it myself, I have a GenericWeapon class which has a onCollisionEnter() method which I want applying to all child classes which inherit from it, here is the code public void onCollisionEnter(Collider target) Debug.Log("Collided with player!") if(target.GetComponent lt Player gt ()) bc2d.enabled false rb2d.Sleep() equip(target.GetComponent lt Player gt ()) My child class is the following using System.Collections using System.Collections.Generic using UnityEngine public class RangedWeapon GenericWeapon Start is called before the first frame update void Start() Update is called once per frame void Update() public void attack() and my in GameObject has the RangedWeapon class as a component however the GameObject does not seem to be picking up any collisions with the player. Could someone point out where I'm going wrong with this?


Download Progress bar from Firebase Storage Im trying to make a progress bar based on downloaded images from Firebase storage, now firebase does provide a snipper which works per image Create local filesystem URL string localUrl quot file local images island.jpg quot Start downloading a file Task task reference.GetFileAsync(localFile, new StorageProgress lt DownloadState gt (state gt called periodically during the download Debug.Log(String.Format( quot Progress 0 of 1 bytes transferred. quot , state.BytesTransferred, state.TotalByteCount )) ), CancellationToken.None) task.ContinueWithOnMainThread(resultTask gt if (!resultTask.IsFaulted amp amp !resultTask.IsCanceled) Debug.Log( quot Download finished. quot ) ) but i would like to make that appear on a UI text based on the percentage of the Bytes downloaded like starting from 0 to 100 .Now i have come to this function so far which does work in the sense of downloading from storage and i do get the percentage in the console but im not sure how to convert that to a percentage to show on UI. if (CheckConnectivity) if the device is connected to the internet, initiate download. Debug.Log( quot Initiating download of quot platform file) if (!File.Exists(localPath)) Task task storageRef.GetFileAsync(localPath, new StorageProgress lt DownloadState gt (state gt called periodically during the download Debug.Log(String.Format( quot Progress 0 of 1 bytes transferred. quot , state.BytesTransferred, state.TotalByteCount )) ), CancellationToken.None) await storageRef.Child( child).Child( file).GetFileAsync(localPath).ContinueWithOnMainThread(files gt if (!files.IsFaulted amp amp !files.IsCanceled) if download is successful. Debug.Log( quot file saved as quot localPath) else otherwise report error. Debug.Log(files.Exception.ToString()) ) else Debug.Log( quot files Exist quot ) else otherwise don't bother. Debug.Log( quot Cannot Download file due to lack of connectivity! quot ) in which case my debug is this Progress 1731 of 52804 bytes transferred. Which i would like to say 0 and counting up to 100! Thanks!


Why won't character stay at the x axis rotation I set In the inspector? Here is a snippet of my Update function, which contains everything regarding my rotations for the character Higher the Z float, the LESS of a rotation when moving Vector3 v3 new Vector3 (Input.GetAxis ("Horizontal"), 0.0f, 1.5f) A Quaternion variable named "quaternion" that's equal to LookRotation class that takes the "v3" variable Quaternion quaternion Quaternion.LookRotation (v3) The actual rotation is done using the Slerp class transform.rotation Quaternion.Slerp ( transform.rotation, quaternion, Rotspeed Time.deltaTime) When Countdown timer is done, then the animator is enabled adventureAnimator.enabled true When I put "357" on the X Axis tab of Rotation, why does it go back to 0 whenever the game starts? After some debugging I know it is because of my logic contained in my "transform.rotation Quaternion.Slerp" line of code. What do I need to change? If you need more information or need me to elaborate, please let me know.


How can I randomly generate objects inside of a Complex Area? In my game, I want to generate randomize enemies inside of this green area that I made with a custom editor tool.


How to Access a Field of an Unknown Class if the Field Exists It's a very poorly worded question because I'm not exactly sure how to put it into words that are of appropriate number for a title. Read on for a better explanation. (Using Unity API, C ) Basically, I have an AI class in a spaceship game. I can assign the AI a target GameObject, and the AI will look in the direction of and chase after it's target. I would like to make the AI be able to strafe in circles around the target. Since the AI always faces its target, I can simply TransformDirection(Vector2.left right) and it will orbit the target nicely, but if the target is moving it always breaks orbit. To combat this, I want to add the target's velocity to the strafe velocity of the AI. However, I have different classes for the player's ship and the AI ships whom also might be targeted by another AI. All of my ship classes have a field for the ship's velocity, but since they are different classes, I thought I may access the velocity field by doing a GetComponent() and passing some sort of predicate T has a Vector2 field named "velocity". Is there some way to achieve this?


Issues with spine animation alpha in iOS We are seeing a ton of artifacts and strangeness with alpha on iOS for our spine animation assets. You can see an example of one of these grid like artifacts here, but we're also seeing pixelation etc. Does anyone know why this is happening, whether we need to make adjustments or change certain settings to address this issue?


Fail to install ML Agents (python packages) I have been trying for hours to install pytorch and mlagents with cmd, however I am getting pretty much the same error for each package I'm trying to install ERROR Could not find a version that satisfies the requirement typing extensions (from torch 1.7.0) (from versions none) ERROR No matching distribution found for typing extensions (from torch 1.7.0) I'm using python version 3.7.9, attaching a screenshot of the cmd. Also, as you can probably notice I'm getting a repeating warning every time I'm using pip and I'm not sure of it's something to avoid WARNING Retrying (Retry(total 0, connect None, read None, redirect None, status None)) after connection broken by 'ReadTimeoutError( quot HTTPSConnectionPool(host 'pypi.org', port 443) Read timed out. (read timeout 15) quot )' simple torch


Unity Unsharp edges I have a Unity Project and somehow the edges of objects in my Scene (Scene view and game view) look like this I think I already had that problem once, but in my recent projects, this didnt happen anymore. Is there any solution to that?


How do I correct the turning effects on my car in order for it to turn properly? In my game, I'm currently working on a Physics based car driving game in Unity from scratch. My problem is that whenever I press the input controls used for turning, instead of turning, my car does barrel rolls in the air. I'm using a document written about Car Physics by Marco Monster to aid some of my calculations in this post. I've looked at my code and suspect that the problem lies within this segment of my code. Please provide any feedback as it would be greatly appreciated. This section relates to low speed cornering, not really useful for drifting This will determine the circle radius related to turning, in effect, calculating how much we turn R L Mathf.Sin(userRight) Here, we calculate the vehicle's angular velocity in radians per second Omega (fancy w) represents angular velocity v represents velocity rb.angularVelocity rb.velocity R This section covers high speed turning This relates to the car sideSlipAngle Vector3.Angle(carTransform.forward, rb.velocity) sideSlipAngle Mathf.Atan(rb.velocity.z rb.velocity.x) This relates to the wheels for(int i 0 i lt 4 i ) alpha represents the slip angle for each wheel alpha Vector3.Angle(wheels i .forward, rb.velocity) this equation is an approxiamtion of values below the peak shown in the graph lateralForce new Vector3(0f, 0f, corneringStiffness alpha) These values are supposed to represent the magnitudes of these velocities longVelocity Mathf.Cos(alpha) rb.velocity latVelocity Mathf.Sin(alpha) rb.velocity Remember that these forces are supposed to be acting upon the wheels themselves, so add rigidbodies accordingly The lateral velocity causes the cornering force to counteract it This relates to only the front wheels frontSlipAngle Mathf.Atan((latVelocity.magnitude (rb.angularVelocity.magnitude b)) longVelocity.magnitude) (userRight Mathf.Sign(longVelocity.magnitude)) for (i 0 i lt 2 i ) Calculates the lateral force of the wheels latFrontForce lateralForce.normalized (frontWeight.magnitude 2f) latFrontForce latFrontForce corneringForce latRearForce Mathf.Cos(userRight) latFrontForce lateralForce latFrontForce frontTorque Mathf.Cos(userRight) latFrontForce b rb wheels i .AddForce(lateralForce) centripedalForce corneringForce steeringRadius centripedalForce.magnitude (rb.mass Mathf.Pow(rb.velocity.magnitude, 2f)) This relates to only the rear wheels rearSlipAngle Mathf.Atan((latVelocity.magnitude (rb.angularVelocity.magnitude c)) longVelocity.magnitude) for (i 2 i lt 4 i ) Calculates the lateral force of the wheels latRearForce lateralForce.normalized (backWeight.magnitude 2f) latRearForce latRearForce lateralForce latRearForce rearTorque latRearForce c rb wheels i .AddForce(lateralForce) totalTorque frontTorque rearTorque rb.AddTorque(totalTorque)


Tilemap is sent to back disappears behind background when I go into play mode or save (video included) screencap of the problem here I'm sure this has a simple solution but I haven't found it answered yet. I have two tilemaps, one a BG and one a middle layer, and everything works when I paint on the middle layer. It shows up on top of the BG. But if I save the project or open play mode to test it, the middle layer disappears. Seems like it gets sent behind the BG tilemap but the order of the tilemaps hasn't changed. Also of note is that nothing changes even if I reorder the tilemaps, and the only way I can make the tilemap quot reappear quot is by ctrl z undoing my last action. At a loss, any takers? EDIT I just realized that my video capture didn't pick up my drop down menus, but I create a new tilemap at the bottom of the hierarchy, put some assets in it, then save the project (stuff disappears) and then undo (stuff reappears).


How to get which gameobject the mouse is over in Unity? So I'm working on a simple drag n drop based trading card game for my own amusement. There is a card inspector included. What I want to achieve is to change values in the inspector (which has its own Inspector.cs, so I would change the variables in it) based on which card I hover over with my mouse. Each card has its own Card.cs attached from which I want to read the values of the current card. If I try to do this from within the Inspector.cs by something like this Name.text gameobject.GetComponent lt Card gt ().Name , then obviously it won't work, because using gameobject in the current context is not valid. So solution No1 would be to properly reference the gameobject over which the mouse is, which I don't know how to do. When I try to do the same from within Card.cs, I cannot use an event trigger OnPointerEnter and run the code through that, because I have to have a reference to the gameobject that contains that function. ( And I cannot do that in a prefab, only in gameobject already existing in the level.) So could anyone tell me how I could achieve what I want, please?


Create a 2D trail in Unity? I would like to make a trail for a pixelated snake such as this one As you can see, the cross simply repeats itself to create the snake. In Unity I have messed around with Trail Renderer, tried everything to import the cross as a texture sprite, then created all sorts of materials for it, but it just won't work the same way. How can I achieve this effect please? Thanks!


Issues with importing bezier curve animation (curve does not distort?) Hi guys i'm pretty new to unity and having a frustrating issue I've created a spear gun with an animation using a bezier curve grouped to the main gun shaft and distorted using a bone (bone relative) in blender. It works fine in blender, however when I export it into unity 5, the bezier curve does not distort and simple moves forward and back. I imported the blender model as a blender file. I have tried pairing the model components in all the ways i can think of to see if that was the problem? I have attached the blender views and animations and what it looks like in Unity. Is it an issue with unity being unable to animate bezier curve animations or the type of bone pairing i used?? unity animation, see the besiel curve simple moves forward and back instead of bending distorting to look like a rubber fitted on a real gun!


Need help with physics 2D Unity I'm making a 2D game in Unity. Basically there's just a rocket that goes where ever the user touches. With the code that i have right now, the rocket instantly rotates towards the point and moves there straight. Vector3 dir targetPos transform.position float rotZ Mathf.Atan2(dir.x, dir.y) Mathf.Rad2Deg rb.MoveRotation( rotZ) thrust 10.0f rigidbody2d.AddForceAtPosition(transform.up Thrust, transform.up) This code is placed in the Update function. I want the rocket to start moving in which ever direction It's currently facing and slowly rotate towards the point as it goes there.


How to disable spring joint in unity 3d How can I disable Spring joint in unity 3d, since disabling feature only available in 2d mode, I am not able to find any way to disable it via script


Different implementation use case of component based approach Inspired by this question I made a small demo for an enemy that has a HP component. Basically there is a main enemy script and a HP script that considers you died on collision and lets the enemy script know on different ways. I could think of three different ways how to let the main script know that you died and included a basic implementation of each. The focus is more on how to let the main script know that you died. Broadcast public class EnemyBroadcast MonoBehaviour void HandleDeath() Debug.Log( quot Died via broadcast quot ) public class HPBroadcast MonoBehaviour private void OnCollisionEnter2D(Collision2D other) BroadcastMessage( quot HandleDeath quot ) Pro This seems to be the shortest code. Con IDE can't see the call and you need to know the broadcastevent Interface public interface IDeathHandler void HandleDeath() public class EnemyInterface MonoBehaviour, IDeathHandler public void HandleDeath() Debug.Log( quot Death via Interface quot ) public class HPInterface MonoBehaviour private void OnCollisionEnter2D(Collision2D other) GetComponent lt IDeathHandler gt ().HandleDeath() Pro Not possible to forget to implement methods Con Possible overhead of methods, reusibility Delegate public class EnemyDelegate MonoBehaviour void Start() GetComponent lt HPDelegate gt ().handleDeathDelegate HandleDeath void HandleDeath() Debug.Log( quot Died via delegate quot ) public class HPDelegate MonoBehaviour public delegate void voidDelegate() public voidDelegate handleDeathDelegate private void OnCollisionEnter2D(Collision2D other) handleDeathDelegate() Pro Outside objects are able to observe changes events Con more complicated to setup longer code Now the question is, what other ways are there in a component based approach, are there more pro con for each approach and when is which kind of implementation prefered over the others?


Vibration causing lag on OnePlus 6 has anyone experienced vibration causing lag on OnePlus 6 (or other device)? I'm developing a mobile game on unity and lately I have been Integrating Nice Vibrations to our game which is basically a wrapper for both Android and iOS vibration. Basically whenever vibrations become too rapid, like 10 vibration patterns second , my OP6 drops framerate from 60 to 20. This lagging happens with any game that uses a lot vibration so it can't be caused by any bug in our codebase. Has anyone else faced similar behaviour and managed to fix it?


How can I render 3d objects over uGUI? I have a scene with 3d objects but need uGUI as background. How can I achieve this?


UDP server in unity not working I know there are a lot of UDP examples out there, but I really need to know specifically what I am doing wrong. I have Wireshark monitoring my data traffic and according to that program Unity is not sending data at all. Could some of you coding wizards look over this and help me find my mistake? public class heatLampControl MonoBehaviour Ben Stewart, june 6th, 2016 this code controls the "Position" of the heat lamps, ie what angle the heat should be coming from. The value will be added to a new UDP connection to the dSPACE machine Update 6 10 Added UDP functionality, as accessing the UDP class that was created for this purpose turned out to not function correctly public float lampIntensity 0.0f Multiplier for relative intensity of the sunlight GameObject sun public GameObject player dropped in via GUI public bool isNight false is it night? if so, heat lamp should turn off public double sunAngle angle about the y axis. that is the only angle that can be controlled. public bool isOn false public string keyDown public int port public string dataStr byte data public GameObject cycle following three keep track of day night cycle public Day Night.TimeOfDay tod public Day Night dayNight public int strLength private IPAddress ip private UdpClient udp private IPEndPoint ipep public float fruitIntensity public float hayIntensity OlfactoryControl olfactory string hostname IPAddress ipList void Start () hostname Dns.GetHostName () ipList Dns.GetHostEntry (hostname).AddressList port 13722 cycle GameObject.Find ("DayNight") dayNight cycle.GetComponent lt Day Night gt () sun this.gameObject olfactory GameObject.Find ("Olfactory").GetComponent lt OlfactoryControl gt () ip ipList 0 ipep new IPEndPoint (ip, port) udp new UdpClient (13722) Update is called once per frame void Update () sunAngle player.transform.eulerAngles 1 Math.Atan2 (sun.transform.position 2 , sun.transform.position 0 ) gets the positional angle of the sun compared to the player keyDown Input.inputString if (isNight Input.GetKeyUp (KeyCode.L)) IF L is pressed down, light will come on lampIntensity 0f isOn false if (!isNight amp amp Input.GetKeyDown (KeyCode.L)) lampIntensity 1f isOn true tod dayNight.tod if (tod Day Night.TimeOfDay.Idle) lampIntensity 1.0f if (tod Day Night.TimeOfDay.SunRise) lampIntensity (dayNight.timeOfDay (dayNight.sunSet dayNight.StartTime)) hayIntensity olfactory.hayIntensity fruitIntensity olfactory.fruitIntensity sendUdp () june 30th edit void sendUdp() dataStr hayIntensity.ToString () fruitIntensity.ToString () lampIntensity.ToString () byte sendBytes System.Text.Encoding.ASCII.GetBytes (dataStr) Debug.Log (dataStr) udp.Send (sendBytes, sendBytes.Length, ipep) Debug.Log ("Data sent to IP Address " ip.ToString() " on port " port.ToString())


How to render the sprites for a 2D soft body physics system This is not a question as to how to achieve soft body physics, but rather if I have a mass spring system how to modify a sprite with that information. I am using unity so I dont have access to vector based graphics.


How do I make UIText scale properly in a VerticalLayoutGroup in Unity? I have a Panel with an AspectRatioFitter on it. In there, I have a vertical layout group, with three buttons, Standard Mode, Speed Mode, Chaos Mode. I have the Layout Group's anchors set to keep its size relative to the parent Panel. The problem is that the text doesn't resize when I change the screen resolution. You can see it's cut off to say "Standard M" in the bottom image. But if I say "Best Fit", the texts aren't the same size, because the boxes are big enough to allow the shorter text to be bigger. The only way I've been able to fix this is to adjust the sizes and anchors of the text boxes by hand. Is there an automatic way to do this?


How to detect collision in C script not attached to any game object I have public variables which I populate through the inspector. One script is attached to a single object and the other script has a gameObject array property. Please see below public class GamePlayScript MonoBehaviour public BallScript ballScript public BrickGroupsScript brickGroupsScript Use this for initialization void Start () Update is called once per frame void Update () BrickGroupsScript contains an array of bricks which has a isBroken bool property. Also the above code is attached to an empty game object. How can I detect when the ball game object is in contact collided with a brick with isBroken true?


How to activate Xbox controller vibrations in Unity? Is there any way to toggle the XBOX controller vibrations in Unity ? I came across Handheld.Vibrate() but it seems like it's not meant for controllers.


Vertex Snapping on a mesh with an armature I've made a selection of modular walls for a game i'm working on and some of the pieces have moving parts, like doors and flaps, but the moving pieces with an armature attached don't use vertex snapping like all of the other pieces and it leaves ugly gaps in the walls. I've tried everything I can think of to get them lined up, the closest I can get is lining them up by eye and this leaves small gaps when in game and isn't perfect. Does anyone know of a way to get vertex snapping to work with meshes that have an armature attatched? I've attached a picture to try and explain


Why does the keyboard continue to control disabled buttons? Having the whole panel with all its children including buttons disabled by simple gameObject.SetActive(false) doesn't prevent the buttons from interacting (navigation and clicks) with the keyboard. What could be the reason?


changescene after timeline Is there a way to change the scene after playing a timeline with the new timeline system? I have 3 scenes in my project. The first scene is where a player interacts with an object to trigger a change to the second scene. The second scene then plays my timeline. When the timeline finished playing I want to change to the 3rd scene. How can I trigger the scene change at the end of that timeline?


Fill all unallocated space with texture I have a system of bunkers underground, and I need to fill all the free space where there are no buildings with earth. Yes, I can manually add a ground texture to the plane, but I have procedural level generation. I thought there might be some kind of filter on the camera that I don't know about. Or maybe there are some other solutions?


Is there a standard way to rig a humanoid? I am using some placeholder humanoid models for my game, which will be replaced later. I am concerned that when I replace them, they will not work with my animations, due to different rigging. Is there a standard rigging that artists use for humanoids? Such as, is there always a the same number of body parts attached in the same hierarchy, or does this vary based on the artist studio? If there is a standard, what is it? If there isn't how can I ensure that my animations and models play nice? I use Unity, if it's relevant. Disclaimer I am not an artist, and I have no idea what I am talking about. Please feel free to ask for clarification.


Using UDP vs Websockets I am running a Unity Game on a PC (for development purposes) and then on an Android phone (for production). I need to send data to the Game continuously from a WiFi enabled microcontroller (Esp32). Is it better for me to use UDP or Websockets for data transfer? What are the pros and cons of each method? In this scenario, the game device will act as a mobile hotspot while the esp32 will connect to this hotspot.


How can I easily assign an array in the inspector? If you make a public array class member in Unity, you can individually assign objects to the array in the inspector menu. It looks like this However, this is cumbersome if you you want to assign the same array to many objects. It's easy to do this programatically, but I'd rather not hard define the array in code it makes moving renaming the objects harder. If I want to pass the same array to multiple game objects, how can I do it more efficiently than dragging each individual element into the inspector?


Trying to understand exactly how the server sends data to the client to prevent malicious actions I recently started coding a game with one of my friends and he is taking care of the front end and I am doing the back end. I read many blogs articles tutorials on how the back end communicates with the client side and they all show different ways of doing this. In our game the player can move his character by right clicking where they want to go. Does this mean the movement happens on the client side or should the client send a coordinate to the server and the server checks if its valid and responds with 'move verified' which then allows the client side to carry out the action? If this is the case how does collision take place because it will have many calculations and can cause major stress on the server. but doing it client side will make it vulnerable to malicious scripts. The game needs to be in real time and 10 people will be playing simultaneously in a single match.I know the coords of all players have to be constantly sent to the client from the server so each player can see all players. We are using Unity and socket.io. We successfully got communication with one another. But I just want to make sure I am on the right track before I start going deeper into the code. I can show my code if its needed but its bare bones connections. Thanks in advance!


How to reduce the size occupied by my video animations? I have a mobile game but my build size is currently 4gb. Furthermore, it crashes on open and I suspect it has something to do with the huge build size. In my project are 10 animations made of a series of images, each one using around 250 300 images. Each one is quite large as the animation takes up most of the screen so they are high resolution. What can I do to reduce the build size? I have tried converting it into a video file and using the raw image component to display it as a movie texture, however, it seems unity doesn't support videos with alpha channels, and the alpha channel is critical to my animation. I thought about combining them into a single image, but lets be real, if each image is more than 1080p, then combining 250 300 images into a single file will be massive. So what can I do to reduce the size of the animations?


Mesh disapears before out of fov I use a C script to move the vertecies of my quad around the world space. It works perfectly fine, but when I move rotate the camera away, so it does not look at the position of the quad, the quad disappears. I cannot change the size of the quad, since that would not work with my other scritps. How can I force the camera to allway render the mesh of the quad?


Scale one object to be cover multiple other objects I have placed and aligned several objects next to each other. For the sake of understanding, lets just say I placed 10 cubes next to each other. I snapped them all together (Move V Click amp Drag). The cubes look great so far. Now I want to make a plane in front of the cubes, that has exactly the width of the cubes altogether. Now, I can place a new plane in front of the, no problem. I can snap a single edge to the cube on the most right, also no problem. But now, how can I make the size exactly the same as all the cubes together? Sure, I could eyeball it from top view, an kind of make it about the same size, but chances are, it's a little bit too short or too long. Isn't there a possibility to snap one edge, lock it, and snap another edge making the object scale automatically to the desired width?


Instances in the Unity Profiler Timeline What do Instances mean when you click on an operation in the Timeline section of Unity Profiler? In this example Total 11.90 ms (10 Instances)


Unity3D Creating Sharing light baked levels without updating the game I want to give myself freedom to add more levels after releasing the game. For creating levels I broke down structure and created a tilemap like a structure. here's an example I will add them up to create a level and send it to server from where I can download the JSON in game and read it at run time to place things around. The problem is I want to also use Global Illumination. What I can do is send lightmap data with created level to server and download and use it for lighting after generating level. But what If my map is huge?? I don't want to have lightmap size. The other thing I can do is create light baked prefabs, suggested by this article, https unity3d.com how to light baked prefabs on mobile. But every single object has to be attached to a surface and baked because of shadows. Is there a better approach? Thank you.


Blender rigid body physics animation into Unity? I'm stuck trying to get these cube objects to explode into chunks when destroyed in Unity. I've set up a physics sim in Blender of the effect I want, originally planning to replace the unbroken GameObjects with this fragmented one coupled with the explosion animation upon destruction. I guess it's not that simple. I've tried "Bake to Keyframes" in blender and exporting as an FBX, but Unity imports each individual fragment with its own Animator Avatar and a crazy amount of animations, which is almost useless. Any better ways to go about this?


My .FBX model is not picking the .TGA texture file I'm at a complete loss. An artist has sent me a 3D model so I can test it in Unity. This is exactly what I got Guy.fbx Guy DIF 512.tga Alright. So I move the folder into the Unity inspector. Suddenly, a Materials folder is created within such folder. The Materials folder has one material. Anyway, now I put the Guy prefab into the scene. It doesn't have textures applied. No problem. A simple Google search yields this response The textures for your model have to be in your Unity project for Unity to apply them automatically when you import. There are 3 different ways to make sure this happens 1 Use Textures for your 3D model from a textures directory already in your Unity project 2 Embed them in the FBX 3 Copy the textures into your project before you import your model I will avoid the second option for now to avoid troubling the artist. Let's see the third option... 3 If you are using 3D software packages that might not have newer FBX plugins or are importing native files you generally do not have the option to embed media, so you will need to copy the textures into a directory inside your project called textures nested next to the model before you import it e.g. Projectx Assets Models Textures ModelTexture.tga Projectx Assets Models Model.fbx Ok, so I created Assets Models Textures and imported the Guy DIF 512.tga file into it. Then in Assets Models folder I import the Guy.fbx file. Doesn't work. The model still doesn't have textures applied. Alright, so let's look at the first option then. ... Let's look at the first option... 1 If you create your textures in your Unity project to start with and source them from a textures directory nested under Models for example, Unity should always create materials and pick up the textures correctly at import Assets Models Textures Assets Models Uh, isn't this the same as the third option? How do I import my 3D model? I am using Unity 5.


Rendering Mode transparent is not applying in webgl build I am using this method to convert opaque rendering mode to transparent. item.color new Color(1, 1, 1, value) item.SetFloat( quot Mode quot ,3) item.SetOverrideTag( quot RenderType quot , quot Transparent quot ) item.SetInt( quot SrcBlend quot , (int)UnityEngine.Rendering.BlendMode.One) item.SetInt( quot DstBlend quot , (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha) item.SetInt( quot ZWrite quot , 0) item.DisableKeyword( quot ALPHATEST ON quot ) item.DisableKeyword( quot ALPHABLEND ON quot ) item.EnableKeyword( quot ALPHAPREMULTIPLY ON quot ) item.renderQueue (int)UnityEngine.Rendering.RenderQueue.Transparent This is working fine but not working in my webgl build.


Unity2D Horizontal Scaling to Support Various Aspect Ratios? I am trying to work out how to support various resolutions for my Android game. I have come up with a solution, but do not know how to implement it. Automatically, I am told that Unity vertically scales the screen to match the screen, leaving more room at the sides. How can I change this behaviour? I am hoping to shrunk the game down till it fits horizontally, and filling it the background above and below with more decorative features. How can I achieve this? I'm sorry if there is an obvious answer, I'm quite new working with the Unity UI system. If it makes it any easier, my game is heavily based on UI, and is locked in landscape. BIG EDIT I completely rephrased this question because it was so broad and messy.


How to sample from six cubemap images for a skybox in Shader Graph? I'm trying to update a skybox shader to URP and reimplement it in Shader Graph. The shader code itself is pretty straightforward, but I don't know enough about Shader Graph yet to set up the basic skybox. It's a standard cubemap skybox made up of six textures for x, x, y, y, z, and z. Trying to Google different variants of "unity shader graph cubemap skybox" turns up tons of noise and nothing actually useful that I can see. Does anyone know what the basic node setup is I would need to input six images and output a skybox?


How do I load an asset bundle? I am trying to load a bunch of prefabs from an asset bundle. I am building the asset bundles for StandaloneWindows64 BuildPipeline.BuildAssetBundles(BuildPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64) I load my asset bundle using Unity's new web request system var www UnityWebRequest.GetAssetBundle(Url) yield return www.Send() if (www.isError) Debug.LogError(www.error) yield break var bundle ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle However, my bundle does not have my asset bundle in it. It only has the manifest Output "1 asset bundlemanifest" Debug.Log(bundle.GetAllAssetNames().Length " asset " bundle.GetAllAssetNames() 0 ) If I look at my manifest, I can see my asset bundle names "structures" does exist ManifestFileVersion 0 CRC 3317959940 AssetBundleManifest AssetBundleInfos Info 0 Name structures Dependencies I tried retrieving it from my AssetBundleManifest var manifest bundle.LoadAsset lt AssetBundleManifest gt ("assetbundlemanifest") But the AssetBundleManifest only has functions which return strings and Hash128s. How can I instantiate the prefabs in my asset bundle named "structures"?


What is the best way to import autocad models into unity? I just got someone to create a 3d environment for my game in autocad 2015. I exported that environment and imported it into unity but that doesn't work well as I am unable to see my environment in the scene view correctly. Any suggestions on how to do it better? I am not good with 3d modeling and I ever used autocad models in unity before. Any kind of help is highly appreciated. )


Unity Cloud Build Corrupted reffernces. Reimport All Assets possible? When references in scenes or prefabs are missing, usually a reimport all fixes all issues. But when those problems occur in a cloud build that get's its data from a git repository the solution seems much harder. The AssetDatabase API allows for a reimport in a prebuild script using UnityEditor using UnityEditor.Build using UnityEditor.Build.Reporting class Reimporter IPreprocessBuildWithReport public int callbackOrder get return 0 public void OnPreprocessBuild(BuildReport report) AssetDatabase.ImportAsset( quot Assets quot , ImportAssetOptions.ImportRecursive) But the UnityEditor libary isn't accessible in a cloud build. Is there a way to fix missing references in a cloud build or trigger a reimport via a pre build script or something similar? PS Local builds after a fresh checkout of the github project do not have this issue, and only Cloud builds suffer from these missing references. Maybe someone knows the root of the issue and how to overcome it, so that none of these hacky solutions would be required.


Why aren't the Physics2D.Raycasts reliably colliding with the 2D Box Collider walls? I've got this NPC walking around and I'm trying to create a cone to represent their line of sight, including how it would be blocked by buildings, similar to how Nicky Case has implemented it as described here https ncase.me sight and light My main problem with this, right now, is that it seems like I'm not detecting collisions between my 2D box colliders and Physics2D.Raycast when I would expect to much of the time. The green rays in the image below are NOT colliding (this is fine on the corners, I don't really care, but when the rays are going straight through walls, that's a big problem for me). Red rays are colliding. Why aren't the Physics2D.Raycasts reliably colliding with the 2D Box Collider walls? I believe everything is in the same z plane and has the correct collision matrix in place. ! image of my NPC and raycasts from them at various points along their path List lt UnityEngine.Vector2 gt endPoints new List lt UnityEngine.Vector2 gt () GameObject corners GameObject.FindGameObjectsWithTag("verticies") corners MUST BE WORLD ORIENTED! for(int i 0 i lt corners.Length i ) UnityEngine.Vector2 corner new UnityEngine.Vector2(corners i .transform.position.x, corners i .transform.position.y) RaycastHit2D endPoint Physics2D.Raycast(this.transform.position, corner) if(endPoint.collider ! null) endPoints.Add(endPoint.point) Debug.DrawLine (this.transform.position, endPoint.point, Color.red) else Debug.DrawLine (this.transform.position, corner, Color.green)


Player Flying after colliding Unity I have a Player with a capsule collider on him and i have various objects in the scene. Most of the objects have either mesh collider or box collider enabled. When i move my player and the player collides with any object, my player just starts flying into space, literally. Any way to fix this? Thanks in Advance. The code i have on my player is this using UnityEngine using System.Collections public class Controller MonoBehaviour Animator anim Rigidbody rbody float inputH float inputV int Life 20 bool Dead false public float sensitivity 10f void Start () anim GetComponent lt Animator gt () rbody GetComponent lt Rigidbody gt () void Update () if (Dead false) inputH Input.GetAxis ("Horizontal") 50f inputV Input.GetAxis ("Vertical") 20f anim.SetFloat ("inputH", inputH) anim.SetFloat ("inputV", inputV) float moveX inputV Time.deltaTime float moveZ inputH 0.5f Time.deltaTime this.transform.position this.transform.forward moveX this.transform.position this.transform.right moveZ transform.Rotate(0, Input.GetAxis("Mouse X") sensitivity, 0) if (Input.GetKey (KeyCode.Z)) Life if (Life 0) Dead true anim.SetBool("Dead",Dead)


Should the level design be in Unity scenes (GameObjects) or in 3D programs (mesh) I am wondering what is the most common and best way to design a game in Unity from the point of view of best practice and performance and the most easily maintainable? Is it really performant to design the level in Unity editor using a GameObject for each part of the level? or should the whole world of the level be designed in any 3D software and then exported to Unity as a on GameObject?


XInputDotNet not working when building for UWP in Unity I am working on a game where a controller has to vibrate. I have found the XInputDotNet plugin which worked very well in the editor and a normal windows build, but if I build for UWP (both Xaml and D3D) the controller doesn't vibrate. When building in unity for UWP it also gave me an error saying this Plugin 'XInputInterface.dll' is used from several locations Assets Plugins x86 XInputInterface.dll would be copied to lt PluginPath gt XInputInterface.dll Assets Plugins XInputInterface.dll would be copied to lt PluginPath gt XInputInterface.dll Plugin 'XInputDotNetPure.dll' is used from several locations Assets Plugins x86 XInputDotNetPure.dll would be copied to lt PluginPath gt XInputDotNetPure.dll Assets Plugins x86 64 XInputDotNetPure.dll would be copied to lt PluginPath gt XInputDotNetPure.dll Please fix plugin settings and try again. UnityEditor.Modules.DefaultPluginImporterExtension CheckFileCollisions(String) UnityEditorInternal.PluginsHelper CheckFileCollisions(BuildTarget) (at C buildslave unity build Editor Mono Plugins PluginsHelper.cs 25) UnityEditor.HostView OnGUI() The only way I found to remedy this is by deleting one of the plugin folders. I tried manually copying the ddl's to the build folder, but this didn't help. I tried using the 32 bit dll's and the 64 bit dll's, I tried building for x86 and x64 and I tried all three modes in visual studio(Debug,Master,Release). I found some links to the Windows.Gaming.Input namespace, but I dont't know if it is possible to add this namespace to unity and if so how. Does anybody have an idea how to fix my problem?


Setting a texture's "Max Size" while ensuring that its dimensions are still multiples of 4 A version of my game has several large textures with dimensions that are multiples of 4 so that Crunch compression can kick in. A ported version of my game, for platforms that have very limited RAM restrictions, will need us to limit the quot Max Size quot of our textures to 512 or 256, etc. There are some cases in which a Crunch friendly texture, when resized by Unity's quot Max Size quot parameter, will actually end up with dimensions that aren't multiples of 4. 944x800 would end up as 512x434, if we select quot 512 quot , which isn't good for Crunch. The naive solution in my mind is to write a simple script tool that resizes pads all my textures by a couple of pixels in such a way that Unity's resize will end up in a Crunch friendly way. However, I'd rather do that as a last recourse if possible. Is there a more standard way to approach this situation of mine?


How to properly copy paste object between folder? I'm new to unity and found some simple task can't be done here. For example in projects tab, i want to copy paste a script from script folder to other folder. I should be able to simply select the script, press ctrl C , go to target folder , press ctrl V to paste but nothing happen. So for now , i have to duplicate it then move it to new folder then rename it. But why can't i do simply copy and paste ?


Moving a character according to the animation, rather than code I'm using 3ds Max to export character animations in which my character is moving. I expected this to mean that the character will move in Unity, but it doesn't... For example, if my animation (in 3ds Max) moves my character forward for a second, from 0,0,0 to 1,0,0, in Unity, the character snaps back to 0,0,0 once the animation ends. Is there a way to change the position of the character according to the animation, without something like CharacterController.Move?


Display canvas in front of player I have stuck in this simple problem but unable to understand that why i am unable to control it. I have these line of code which is displaying my canvas object in front of my player(camRotationToWatch object name in code) at certain rotation of the player. if (camRotationToWatch.transform.localEulerAngles.x gt navigationCanvasXMinmumLimit amp amp camRotationToWatch.transform.localEulerAngles.x lt navigationCanvasXMaximumLimit) if (!navCanvasHasDisplay) navigationCanvas.SetActive(true) Debug.Log(camRotationToWatch.transform.forward) Vector3 navCanvas camRotationToWatch.transform.position camRotationToWatch.transform.forward navCanvasDisplayDistanceFromCam navCanvas new Vector3(navCanvas.x, 2f, navCanvas.z) navigationCanvas.transform.position new Vector3(navCanvas.x, navCanvas.y, navCanvas.z) navigationCanvas.transform.rotation camRotationToWatch.transform.rotation navCanvasHasDisplay true else navigationCanvas.SetActive(false) if (locationPanel.activeSelf false amp amp infoPanel.activeSelf false) navigationCanvas.SetActive(false) navCanvasHasDisplay false This code is actually work fine when camRotationToWatch object rotate from down to up and Canvas show at correct position but as I try to to rotate camRotationToWatch from up to down it display(active) Canvas at very top position. How can I restrict canvas to show at same position (No matter player rotate from up to down or down to up) but display on front of the player object?


Creating custom types that extend certain objects Really new to C scripting. I'm trying to extend a TileBase type object to be able to hold custom methods and variables. I want to create a pathfinding script and I need to store certain information for each tile. Something like this TileBase startPoint tilemap.GetTile (tilemap.WorldToCell (transform.position)) startPoint.customVariable 5 Is there a way to extend TileBase into a new type and create custom methods inside it? How can I achieve this in Unity?


Are prefabs the only way to dynamically build a world in Unity? I'm trying to understand how to setup my Unity prefabs and scripts to dynamically spawn a series of "encounters", with each encounter containing several GameObjects. For example, imagine spawning the next several portions of an infinite runner level. One encounter is a ramp, the other encounter is a pit with some coins. This is what I am currently doing A global SceneManager script has a handle to an EncounterFactory prefab. When needed, the SceneManager will begin constructing the game world. The EncounterFactory prefab contains a script that has a method SpawnRandomEncounter. The EncounterFactory also contains handles to several other prefabs for the objects that can be found in an encounter. The SpawnRandomEncounter method uses the prefabs linked to EncounterFactory and builds the expected GameObjects. So when building out a new "encounter", the SceneManager clones the EncounterFactory (which serves as the parent object for the full encounter), and then calls SpawnRandomEncounter to build out the child objects. This seems suboptimal. First, I need to have myriad prefabs for each thing that could be spawned. It also requires a meta prefab to EncounterFactory. That is, a prefab who just allows me to spawn other prefabs. Is there a better way to dynamically build out a game world or level in Unity? Or is it prefabs upon prefabs upon prefabs? For example, I'm aware that I can find an existing object by name. (e.g. find EncounterTemplate5 and clone that.) However, that requires that EncounterTemplate5 exist in the game world. (So it can be cloned.)


Help in 2d platform script Now I finished my 2d game but when I set up it in my mobile it becomes like this so I change some scripts in Maincamera but it's still the same How can I change the screen to become horizontal in my mobile like this? what I need that how can I make it fit my mobile screen.


Android build has white image over game In unity when I am playing my game it displays fine, but when I build and run it to my nexus 5 there is this white something I don't even know over my game. Any suggestions for fixes?


Unity Gyroscope orientation (attitude) "wrong" I am using the Unity reference and example implementation here https docs.unity3d.com ScriptReference Gyroscope.html I struggle to fix an orientation problem. When my phone lies flat on the ground, screen facing upwards, unity thinks I am looking as if I'd take a photo of a landscape. When I actually hold the phone as if I'd take a landscape photo, the screen shows me the sky. Rotating then shows me an arc from sky to my left or right side. What I want is Holding the phone as if I'd take a landscape picture should do the same in Unity. Here is a short video where the phone lies flat and then I pick it up and look left and right on a chair. and this is the codesnipped responsible protected void Update() GyroModifyCamera() void GyroModifyCamera() transform.rotation GyroToUnity(Input.gyro.attitude) The Gyroscope is right handed. Unity is left handed. Make the necessary change to the camera. private static Quaternion GyroToUnity(Quaternion q) return new Quaternion(q.x, q.y, q.z, q.w)


Is it possible to make an obj with single triangle I am not good in using blender so i wanted to ask if it is possible to make an object with just one triangle and how would it look like, will the no of triangle increase if you scale it up.


Why do we get artifacts on objects rendered using depth node depth render camera on Android? I've encountered and error I can't seem to find online. I get it on all the water shaders I test, and any thing else that I have a depth node depth render script on the camera for. I'll share a bit more information about what we're doing in the game. This artifact changes as we pinch zoom on Android. So I wonder if the Render Depth script doesn't like that we are changing the zoom depth for some reason? Maybe it has something to do with how we are handling out cameras movement in Unity? It is adding more depth information somehow, because the shader is reacting to the artifact. Depending on where the line cuts, the other details will warp to meet it. This problem doesn't show on all phones. Mostly Android, newer versions, but wasn't showing up on an older S5. Some other things I've tried within the shader are different shader models 2.5 amp 3.0. Any suggestions on tests I can do, or ideas on what might be the issue? Here are the nodes I use for the opacity depth Currently we've got the controls on one camera, and the depth script on another. Update, I've found someone talking about a similar sounding problem, but I'm not sure how to do this myself. Thread here https forum.unity.com threads depth texture not working on some devices.319568 "If I set my RenderTexture Depth format to 16 bits instead of 24 bits it's working!" How do I do this? Can I edit my Camera script to do this? The Camera script seems simple, but I'm not sure how to make it render 16bits instead of 24 bits to test this out. Toony Colors Pro Mobile 2 (c) 2014 2018 Jean Moreno using UnityEngine using System.Collections using System.Collections.Generic Makes the Camera render a depth texture. This is needed for some water shaders that use depth based effects such as edge intersection. ExecuteInEditMode, RequireComponent(typeof(Camera)) public class TCP2 CameraDepth MonoBehaviour public bool RenderDepth true void OnEnable() SetCameraDepth() void OnValidate() SetCameraDepth() void SetCameraDepth() var cam this.GetComponent lt Camera gt () if (RenderDepth) cam.depthTextureMode DepthTextureMode.Depth else cam.depthTextureMode amp DepthTextureMode.Depth Thanks!


Is there a way to hardcode a JSON file into a Unity build? I'm currently creating an external tool to generate dialogues that are exported as JSON files. The idea is that after you create a dialogue (as a JSON), my main Unity project reads that file and generates a dialogue. Right now it works just fine, but the JSON is an external file that you can modify even after compiling the game (of course). Is there a way to actually "hardcode" that JSON file so that the game doesn't need to find and read the file every single time it plays?