Generate a large data structure using a compute shader I know that RWTexture2D Result void CSMain (uint3 id SV DispatchThreadID) Result id.xy float3(1,2,3) will result in an texture containing the numbers 1,2,3 however I'm now looking for a way to control a compute shader in such a way as to generate either a 3D texture with control over which order my operation occur or a way to fit a data structure in the return value of the compute shader. For a simplified example let's say that I want to generate either a 2D array of linked lists with each value in the linked list being equal to 1 the next value so 9 8 7 6 , 11 10 9 8 8 7 6 5 , 6 5 4 3 2 from the input texture 6,8 5,2 or store the same in a 3D texture (the real version will be more complex so we will not be able compute that 5 2 7 but instead have to relly on the fact that 5 1 6 6 1 7) Any idea how to do this?


How to calculate the stopping distance of a wheel collider? I have an 'AI' bus in my game that needs to pull over occasionally at a bus stop. What I want to do is change the acceleration and brake force based on the stopping distance of the bus. I don't want to simply use the distance between the bus stop and the bus because each time the bus pulls over, it could be traveling at a different speed. Right now it uses the distance between the bus stop and the bus. It doesn't really work well though because if a bus is traveling faster, it will take a longer distance to stop and will likely go past the bus stop. Same thing if it were going slower. How do I calculate the stopping distance my bus will take to come to a complete stop?


Instantiate from two values, each in separate array I have a problem with Instantiating GameObjects from floats in arrays, which I have to merge into one Vector2 (or Vector3). I have only two values in arrays GameObject somePrefab float value1 float value2 First I have to combine them into a vector, then Instantiate as many prefabs as the combined vector number is... Can anybody help me with how to merge these floats into a vector and instantiate?


Audio Clip not working on Collision when destroying an object So I made a game where you shoot a laser and if it hits the enemy it makes an explosion sound and destroys the enemy. The only thing is whenever I try to get the audio to play it doesn't which I assume is caused by the enemy being destroyed. I have tried to use the Play() methods and PlayOneShot() methods but they both don't seem to help me out. This is my current code public AudioClip explosion public AudioSource explosionAudioSource public void OnTriggerEnter2D(Collider2D other) void Start() explosionAudioSource GetComponent lt AudioSource gt () if (this.tag "Enemy" amp amp other.tag "Laser") explosionAudioSource.PlayOneShot(explosion) Destroy(other.gameObject) Instantiate(enemyExplosion, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity) Destroy(this.gameObject) uiManager.UpdateScore() Thanks!


Remove delay when changing axis input in the Unity Input Manager I had a problem playing with the Input Manager, where for example When Horizontal ( ) is pressed, it increase its value but, when Horizontal ( ) is pressed, the horizontal value stays positive for a little, but keeps decreasing. This causes the character to continue playing "right" animations and still moving to right for a few seconds, instead of instantly playing 'left" animations and moving to left. The problem also makes the character movie a little after the player releases the key. I have also used Input.GetKey(), but that means the player cannot change the setting from the game launcher, and I don't want to create player setting in game, for now. What I am trying to achieve is when Horizontal ( ) is pressed, then the player presses Horizontal ( ), it should instantly turn left without delay. When the player is not pressing any Horizontal key, it should stop moving horizontally, instantly. This problem also appears along the Vertical axis. How do I make it so input snaps to 1 or 1, with out slowly moving back and forth?


What is wrong with my Chest script? I'm making an RPG in Unity3D and I am trying to make a script for a chest to open. So I built this script! But it doesn't work. I just want some help fixing this script. pragma strict var Text GameObject var OpenedChest GameObject var CurrentChest GameObject function OnTriggerEnter() Text.SetActive(true) if (Input.GetKeyDown("e")) CurrentChest.SetActive(false) OpenedChest.SetActive(true) function OnTriggerExit() Text.SetActive(false) I get no compiler errors. When I go into the collider that triggers the text, that works, but what doesn't is when I press E to open the chest. It doesn't activate the other chest. What is wrong with my script?


Allow code after a bugged line to continue without use of try and catch My problem is with C in unity, but I think the problem can be applied to all coding languages. For example I have a start function event that may initiate many things. Some lines of code may issue a bug but I want to allow new lines of code run after that without having to encapsulate every line of code with try and catch. Is there any common solution for this that I'm missing?


Getting location bounds of centered text I want to show a dialog box where the user should answer a question. It would look like this The question is aligned horizontally. I don't show the entire question text right away, but it builds up character by character like this To do that, I store the text string in a variable at the script start, then I set the text to "", and in a coroutine I add character after character to the text component. My problem is that (because of the horizontal alignment) Unity wants to build it up starting from the center like this Since this is not what I want, I was thinking that I should perhaps measure the bounds of the entire text while it is horizontally aligned, then I would turn off the horizontal alignment and make it left aligned instead and set its position according to the measure bounds. However, I don't know if I can measure the bounds of the text anyways. Can anybody suggest how to handle this problem?


Animator from another gameobject keeps disappearing from script on play I am working on a gun script and it worked fine until earlier today when I made a change to the script and it stopped working. I put it back, but for some reason now the animator object attached to the script keeps disappearing. using System.Collections using System.Collections.Generic using UnityEngine public class RifleShooting MonoBehaviour private float NextTimeToFire 0f private int CurrentAmmo private bool IsReloading false Space(10) Header("Floats") public float Damage 10.0f public float Range 100.0f public float ImpactForce 60f public float FireRate 15f public float ReloadTime 1.0f Space(10) Header("Others") Space(5) Space(10) Header("Others") Space(5) public int MaxAmmo 10 public Camera FPSCamera public Animator GunAnimations public ParticleSystem MuzzleFlash public GameObject impactEffect public bool AllowedToShoot true Start is called before the first frame update void Start() GunAnimations GetComponent lt Animator gt () if (CurrentAmmo 1) CurrentAmmo MaxAmmo private void OnEnable() IsReloading false GunAnimations.SetBool("Reloading", false) Update is called once per frame void Update() if (IsReloading) return if (CurrentAmmo lt 0) StartCoroutine(Reload()) return if (AllowedToShoot false) return if (Input.GetButton("Fire1") Input.GetButtonDown("Fire1") amp amp Time.time gt NextTimeToFire) NextTimeToFire Time.time 1f FireRate Shoot() IEnumerator Reload() IsReloading true Debug.Log("Reloading...") GunAnimations.SetBool("Reloading", true) GunAnimations.SetBool("IsShooting", false) yield return new WaitForSeconds(ReloadTime .25f) GunAnimations.SetBool("Reloading", false) yield return new WaitForSeconds(.25f) GunAnimations.SetBool("IsShooting", true) CurrentAmmo MaxAmmo IsReloading false void Shoot() shooting script here Also if it helps here is what I see in the console when I try to fire MissingComponentException There is no 'Animator' attached to the "M4A1" game object, but a script is trying to access it.


Using a object as origin for a Raycast using mouse position as direction Is there any way to cast a ray from an object using the mouse position as the direction for the ray? I ve been looking for a while but I can t find something like that anywhere, so if anyone could help with this it would be great. I m using kind of a top view, you can see how here And what I want to do is set a empty game object on top of the character to act as the origin for the ray, then when I press a key the mouse is unlocked and an area appears, here s how that looks And I want to use the position where the mouse clicks to be the direction of the ray.


Unity3d multiplayer canvas so I am making multiplayer game and I stuck on one thing, I have blood overlay canvas in my scene(you know, in fps games if somebody shoots you your screen becomes red and this stuff), and when I shoot enemy, his screen becomes red, but mine also. thats what i ahve now if raycast hits enemy, player script calls ColorController.MakeItred() color controller is attached to this canvas image, here is its code void Start () if (current 100 current 0) opacity 0 Update is called once per frame void Update () image GetComponent lt Image gt () image.color new Color32(reds, greens, blues, opacity) if (current 0) opacity 0 if (!playing) if (opacity gt 0) StartCoroutine(toLower()) if (opacity 255) playaudio() public static void MakeItred() opacity 255 public static void MakeItOff() opacity 0 void playaudio() AudioSource audio GetComponent lt AudioSource gt () audio.Play() private IEnumerator toLower() playing true opacity 1 yield return new WaitForSeconds(interval) playing false btw thats function in player code that calls colorcontroller.makeitred, ClientRpc public void Rpcdoit() ColorController.MakeItred() Nick thanks.


Upgrade items on shop menu I made a game and I made a Magnet upgrade and I have 8 game objects to set active 1 by 1 every time when I upgrade the magnet and I have (int upgrade 0 ). But when I upgrade these game objects it's set active, but if I quit the game and start again all these game objects are FALSE. How can I make e.g if I upgrade to (int upgrade 6) and to make my game objects active only from element 0 to element 6. I do upgradeMagnet() to void Update but its make active only 1 game object depends from (int upgrade) if (int upgrade) is 5 and only game object element 5 is active. public GameObject upgranded public int upgrade 0 public void upgrandeMagnetButton() upgrade 1 upgradeMagnet() void upgradeMagnet() if (upgranded upgrade ) upgranded upgrade .SetActive(true)


Lamba expressions The Operator. Any plain English help to understand this please? I've been adding Google Play support into my game. For the most part I'm getting on swimmingly, but I'm having a hell of a time understanding exactly how the submission calls to submit score and achievements work. It's the gt operator and surrounding method that confuse me, such as this one that I have in my code. It all works, I just don't know how. I've read up a bit and I think these are called Lambda expressions. But I want to know why it is this way, and why it isn't made so we can just use the standard typical bool instead of making this strange way to send the result of whether or not our player is logged in. Hope that makes sense. Here's the code in question Social.localUser.Authenticate((bool success) gt if (success) Debug.Log("score authenticed successfully") else Debug.Log("score not authenticed, check user is signed in") ) Social.ReportScore(score, GPGSIds.leaderboard pinball wizards, (bool success) gt ) Particularly, the bottom line really has me stuck.


Default mipmap level elements to use for CopyTexture in Unity Scripting? I want to make a tiled map. I want to use the function CopyTexture to copy from a Texture2D (where is stored my tileset) to a RenderTexture. I want to use the third overloading (with all the arguments) which allow me to choose from where in the source texture and where in the render texture I will copy. But I need to specify mipmap levels and elements. I don't know what to use as mipmap levels and elements in this function. Thanks to everyone who can help me )


Integrating Unity physics with Entitas I've used Entitas a bit and it appeared to me as a great way of creating clean, modular code. I've seen few examples of games created with this framework, and most of them were puzzles, TD's, simple RPG's, etc. Those made me come to think, that ECS like that is not suitable for games making big use of Unity built in physics engine. Rigidbody in this case is part of View layer, but it would affect for example "position" component, so we can't say they are really separated. Unity Physics also works at it's own pace, so there is not really a chance for independent Component System based simulation. Are there any generally accepted solutions, or if I don't wan't to write my own physics engine, I should give up Entitas?


Getting scene normals in Unity When I get the depthnormals with the shaderreplace script, it just replaces all the shaders in the scene and uses the meshes geometry to calculate the normals, ignoring the normalmap textures applied on them. How can I get the final rendered scene normals to a rendertexture like it appears in the editor windows normal debug mode that is used for deferred light calculations and ambient occlusion and such ?


Adding large 3d models into Unity I have a 3d model of a restraunt with several characters in it probably over a hundred objects. Whenever I try to import it into Unity Unity just loads forever until I force close it. How do you import such large models without Unity crashing?


How can I manually call fire OnTriggerExit() for colliders a trigger is inside of in Unity? In Unity, the OnTriggerExit() method is not called fired (not sure if it's an event or not) when an object is disabled or destroyed within it's collider. In comparison to it being fired is an active object that was within it's collider no longer being inside the bounds of that collider on the next frame. I want to be able to call OnTriggerExit() on my triggers OnDisable() method as a workaround. How would I go about calling firing OnTriggerExit() manually?


Goalkeeper Jumping Algorithm? This may be a "best way to" question, so may be susceptible to opinion based answers (which is ok for me). But I would also like if there are any tutorials , research papers , etc. I'm trying to make a 3D free kick game, and I want to decide on the Goalkeeper algorithm. Usually (and in my game) the shot is a function of direction , power and swerve. Maybe wind can be a factor too. So the shots trajectory is pre deterministic, i.e., the point that intersects the goal (or out) plane is determined as soon as the shot fires. So what could be a good approach for the goalkeeper to jump (or walk) ? I have two approaches in mind 1 determine the point, and jump to there. 2 when the ball is closer than a threshold distance, estimate the point by the ball's velocity vector, and jump to there. The problem with the first approach is, goalkeeper will always save the shot, which I want to prevent. So there should be some kind of randomness, or the goalkeeper's ability to jump and walk will be restricted. The problem with the second approach is, when there is a high amount of swerve, the goalkeeper will always fail to save the shot. So how could these approaches be better? Thanks for any help ! Edit if you want to play the game, click here


Is Unity 2017 random number generator deterministic across platforms given the same initial seed? Is unity engines random number generator deterministic across platforms given the same initial seed or should I implement my own? I know there have been some modifications to the random number generator recently. Answers are appreciated, I don't have the devices on hand to perform any tests and I haven't yet found a direct statement on the matter.


How to properly format classes for JSON deserialization with JSON.net for Unity? UPDATE This answer has been solved and this post updated to I am creating an inventory system and decided to keep a master list of all the items. The goal is to use Newtonsoft's JSON.net to parse the item list and populate the database of items. The JSON item list looks like JSON "Ingredients" , "Consumables" "ID" "TP Small", "Icon" "Sprites porridge.png", "Name" "Small Tan Pill's Porridge", "Consumable" true, "Cooldown" 0, "Duration" 3, "Effect Description" "Restores 100 health.", "Description" "A hearty drinkable meal from everyone's favorite hypercellulose gelatin timelord!!!", "SFX" " eb4e9ad8 c6ac 414f 8d5e c3d012ca6ae6 ", "Bonuses" "HP" 100, "Stamina" 100, "Tolerance" 20, "Attack" 4 , "Concoctions" , "Equipment" , "Abilities" And this is the structure of the classes we are using to match the JSON Classes System.Serializable public class Items public List lt ItemBase gt Ingredients public List lt ItemBase gt Consumables public List lt ItemBase gt Concoctions public List lt ItemBase gt Equipment public List lt ItemBase gt Abilities System.Serializable public class ItemBase public string ID public string Icon public string Name public bool Consumable public int Cooldown public int Duration public string EffectDescription public string Description public string SFX public StatBonus Bonuses System.Serializable public class StatBonus public int HP public int Stamina public int Tolerance public int Attack The deserialization code TextAsset json Resources.Load lt TextAsset gt (path) itemList new Items() itemList.Abilities new List lt ItemBase gt () itemList.Concoctions new List lt ItemBase gt () itemList.Consumables new List lt ItemBase gt () itemList.Equipment new List lt ItemBase gt () itemList.Ingredients new List lt ItemBase gt () itemList JsonConvert.DeserializeObject lt Items gt (json.text) This code now works as intended!


Having multiple different friction values on a single piece of track? I am trying to figure out a good performant way to give a piece of track multiple values of dynamic friction. A track piece is 10x10 units in Unity and the idea is to puzzle them together to a big track like the tracks in Trackmania. The game itself features no acceleration, except from gravity. To make things more interesting I want to give each track piece at the start of the scene multiple random friction values within a given range. Currently I achieve this by making each piece of track consisting of 100 little tiles which are 1x1 units and they get a random friction values assigned. This approach works somewhat fine as long as there are less than 30 to 40 track pieces(3000 4000 tiles) but with more than that the fps are dropping really low. As it is a racing type of game I had to set the quot Fixed Timestep quot in the project settings to 0.001 to get accurate time measurments and this is hurting the performance as well. With a lower timestep the collision detection with all the little tiles is really bad too. Is there a more elegant and or performant way to achieve this in within the unity physics system?


Unity3D RigidBody adding force diagonally (x,y,0) results in two separate movements instead of one diagonal movement? The intentions of this function are to utilize the RigidBody component from a "target" object and clear its force while applying a diagonal force in the direction upwards and away from the side they are facing. I have omitted the portion in which detects the other direction for the sake of simplicity in reading the function as I've been testing this function while the user faces the right hand direction. Variables target refers to the other object currently in the scene targBody refers to the RigidBody component of the target object damage refers to the current damage integer of the object. The damage used in this instance is from the target object facingRight refers to a bool in which is true whenever the current object is facing the right hand direction. public void Damage() targBody.velocity Vector3.zero if(facingRight) Vector3 newVel new Vector3(target.GetComponent().damage 16, target.GetComponent().damage 16, 0) targBody.AddForce(newVel, ForceMode.Impulse) print("Stuff") target.GetComponent().damage 3 For some reason, when I apply the force, the target object doesn't move diagonally. Instead, it moves horizontally before moving vertically however, for some strange reason the horizontal speed is always greater than the vertical speed as it goes so fast that it nearly teleports! I'm not sure if this error happens because of a coding problem on my part that I'm just not recognizing or if it's a problem with RigidBody in which I need to use a workaround for.Anyone have any ideas on what can make this function work the way I want it to?


Unity SceneView Positionning object with mouse position in Editor script I would like to create an editor tool who can change the position of an object in the scene view into other object in the world, based on mouse position, like in the picture bellow (the red pyramid is my object to positionnate rotate) I would like to do a raycast from the scene view camera to the mouse position (or something like that), to get the gameObject over the mouse, and then get the position of the verticle normal for position and rotation of my gameObject For now, I have tryed some code who didn't work, I have my object named "preview", and inside the methode OnSceneGUI() in a editor script i have managed to move my preview object, but now I have to know where to put it... Thanks ! EDIT here some of my try Transform previewPoint here my transform void OnSceneGUI() PointCreator() private void PointCreator() test 1 Camera sceneCam SceneView.GetAllSceneCameras() 0 Vector3 spawnPos sceneCam.ViewportToWorldPoint(Event.current.mousePosition) previewPoint.position spawnPos test 2 Vector3 mousePosition Event.current.mousePosition mousePosition.y SceneView.currentDrawingSceneView.camera.pixelHeight mousePosition.y mousePosition SceneView.currentDrawingSceneView.camera.ScreenToWorldPoint(mousePosition) mousePosition.y mousePosition.y previewPoint.position mousePosition


How do I define a required component on a Unity game object? I have a script that expected the game object to have a Terrain component. Is there an attribute I can add (or some other way) which will prevent a designer from adding my script component MonoBehavior to a GameObject that does not have the Terrain component? The only alternative I have been able to find is to attach my script to something else, and then have a public Terrain field, which requires the user to attach the terrain object to it. (since the editor won't allow you to associate a different object type.) I just want the reverse. Any thoughts?


How to correctly implement custom tick system? I am making a custom tick system to suit my needs (calling normal ticks every 0.2 seconds, medium ticks every 5 seconds etc...) I followed the tutorial in this video CodeMonkey tick system tutorial In his tutorial, he implements the tick counting as shown private const float tickTimerMax 0.2f private void Update() tickTimer Time.deltaTime if (tickTimer gt tickTimerMax) tickTimer tickTimerMax Tick Happens every 0.2 seconds. OnTick?.Invoke(this, new OnTickEventArgs Tick Tick ) However, in other sources I have seen that instead of subtracting tickTimerMax from tickTimer, we just straight up set the tickTimer to 0, as shown if (tickTimer gt tickTimerMax) tickTimer 0 Tick It's hard to say if there's a big difference between these two methods, because at first glance they seem to do the same thing, but clearly they have their differences. So I'm wondering, which one I should use?


Camera is centered on character, but doesn't show character in game window I'm using Unity 4.6.3. I create an animation from sprite. When I press Play button, I see animation plays on scene window, but on Game Window, I don't see anything. Here is Inspector for main camera Here is Inspector for Player I have checked that both z 0 when execute. Please tell me which part I config wrong ?


Unity test Play mode window problem I tried to find an answer to his problem but i wasn't successful. When i press play to test my game, instead of the play mode going to the Game tab and play the game there, with all the unity tabs and options still on the screen, it goes almost full screen, all of the unity window goes to the game mode and i can't see anything but the game, to see the scene, options, etc.. again i need to stop the play mode. For example, if i want to test triggers in play mode, i can't because all i see is the game window. How can i test the game just in the Game tab? Perhaps i changed some setting. I'm not sure if im explaining my problem correctly. Thank you


Align UI element to gameObject in 2D I have a 2d game where I want to display UI element perfectly aligned to specific gameObjects. I have an ortographic camera and I used to Camera.main.WorldToScreenPoint() function giving it the gameobject position modified, for instance, by 1 on X component to get the UI element on its perfect right. My problem is that the element is not on the gameObject's perfect right, but sensibly above. See this schema Expectation G UI element Reality UI element G I tried also to use the WorldToViewportPoint() but it's not giving the desired result. So, I think this is the right way to go but I can't guess what I'm missing. Any clue? EDIT After a little bit more observations it seemed that the UI element alignment depends somehow on it's distance from the center of the screen (of the camera viewport I guess), so that if the gameObject is below half height the UI element y position won't be on the perfect right but slightly below it and if above half heigth will be slightly above the perfect right. Same for x coordinate. Is there a way I could control this?


unity read from text file to instantiate objects I'm trying to use the following code to read a text file stored in the Resources folder or in a file on my computer, and instantiate objects in a Unity 3D scene accordingly. I'm having trouble getting it to work. I've tried attaching the script to either the main camera or an empty gameobject. Neither work so far... I either end up with an error saying the path does not exist (when I put the text file into the project folder on my desktop), or a null exception, or that the path contains invalid characters. Where am I going wrong? I'm trying to use a jagged array because I'll need users to eventually be able to change the text file on the go to create a level. The text file contains the following data S 0 0 0 1 0 0 1 0 2 2 0 0 2 1 My script currently reads using System.Collections using System.Collections.Generic using System.Text.RegularExpressions using UnityEngine using System.Linq using System.IO using UnityEngine.UI public class GenerateLevel MonoBehaviour public Transform player public Transform ground public Transform floor valid public Transform floor obstacle public Transform floor checkpoint public const string sfloor valid "0" public const string sfloor obstacle "0" public const string sfloor checkpoint "2" public const string sstart "S" public string textFile "maze" string textContents Use this for initialization void Start () Instantiate(ground) TextAsset textAssets (TextAsset)Resources.Load(textFile) textContents textAssets.text string lines System.IO.File.ReadAllLines(" maze.txt") string textFile textFile Resources.Load("assets resources maze").ToString() string jagged ReadFile(textContents) for (int y 0 y lt jagged.Length y ) for (int x 0 x lt jagged 0 .Length x ) switch (jagged y x ) case sstart Instantiate(floor valid, new Vector3(x, 0, y), Quaternion.identity) Instantiate(player, new Vector3(0, 0.5f, 0), Quaternion.identity) break case sfloor valid Instantiate(floor valid, new Vector3(x, 0, y), Quaternion.identity) break case sfloor obstacle Instantiate(floor obstacle, new Vector3(x, 0, y), Quaternion.identity) break case sfloor checkpoint Instantiate(floor checkpoint, new Vector3(x, 0, y), Quaternion.identity) break Update is called once per frame void Update () string ReadFile(string file) string text System.IO.File.ReadAllText(file) string lines Regex.Split(text, " r n") int rows lines.Length string levelBase new string rows for (int i 0 i lt lines.Length i ) string stringsOfLine Regex.Split(lines i , " ") levelBase i stringsOfLine return levelBase


Obscure primitive data types against cheating im trying to create lightweight value obscurer, against possibility to blatantly change primitive values in memory editor. Such as cheat engine. Here's what i have to far. lt summary gt Obscure for type int. lt summary gt public class ObscuredInt public ObscuredInt() this.value 0 public ObscuredInt(int value) this.value value private int a private int b lt summary gt Current obscure value. lt summary gt public int value get return a b set a Random.Range(int.MinValue, int.MaxValue) b value a usage ObscuredInt health new ObscuredInt(5) health.value 10 printInConsle(health.value) This works by simply never storing actual value, but rather a combination of two integers, which sum represents the value. That way the value is actually never cached long time in the memory. So finding it in a primitive way using cheat engine is not possible. My question I've seen other examples of obscuring, which involve conversion to binary or string hashing or other quite heavy operations. This example is of course much more lightweight, how is this example worse than more advanced hashing or conversions. What flaws do you see with this example? What can you suggest? Thank you


Using Burst Compile attribute on methods Can we use BurstCompile attribute without using any Jobs or ECS System in Unity? does adding BurstCompile attribute before methods bring us any benefits?


How can I implement the traffic( drawing) functionality in the game? I am a beginner game developer. Games such as "Cities Skyline", "Simcity", "Citybounds", and "Traffic lanes 3" directly build roads and show simulations of cars moving over them. I have no knowledge to make these things. I can use Unity, construct2. How can I express things like roads, lanes, intersections, snapping, traffic simulations, path finding, driver AI, traffic lights, even wheels on the road? Road drawing Traffic simulating


Project transfer, will re importing all my models damage my project at all? Recently I had to transfer my Unity game project to another computer and downloaded the same version of Unity I was using for my 3D project and checked that all the files and folders were in the same place and everything. When I start up the game though my models have vanished and in the hierarchy it just says missing prefab instead of telling me what it was, like it used to if I'd move a model to another folder or something like that. It shows all my files there and I was about to reimport them all but I got a warning that said "Rebuilding assets is only if your project has been corrupted due to an internal Unity bug. It can take several hours to complete, depending on the size of your project. Please submit a bug report detailing the steps leading up to here." I am sure that re importing all my models will fix this but I want to ask if this will have any negative effects on my project or possibly damage anything? This game is extremely important to me and I've been working on it for the past 3 years(being self taught which is why it's taken so long and I'm still learning) Thank you guys in advanced! D


Why is anti aliasing not being applied to my 2D objects in Unity? I am drawing 2D objects in Unity. Some of these objects are drawn using the standard sprite method that is built into Unity. Others are computed as distance functions in a shader. In both cases I can't get Unity to apply anti aliasing despite the setting being set. Is there an extra step that I am missing that is required to get anti aliasing to work properly? Would it be better to implement my own form of AA in a shader?


Is it more efficient detect when audio clip ends with AudioSource.isPlaying or with AudioClip.length? In Unity, I want to trigger an event when an audio clip finishes playing. Would it be more CPU efficient to keep checking if the audio clip is playing with WaitUntil(() gt audioSource.isPlaying false) or would it be more efficient to use WaitForSeconds(audioClip.length) to simply wait a certain amount of time? How can I run a test in Unity to see which one is more CPU efficient?


Regarding Profile Pictures of Facebook Friends Background I am creating a Leaderboard of Facebook friends in unity. Question Can we download and save the images of Facebook Friends on the device of the user for the purpose of reuse? I would like to store the images of the FBFriends on the user's device so that there is no need to download the same pictures everytime the game is restarted. Is it legal to do so? I asked the same question in Facebook Developers forums but I did not get any response. Kindly guide me. How do devs build a leaderboard of Facebook friends normally? Thankyou.


3D visual effects on videos I'm trying to get some hands on experience with 3D visual effects on videos. Similar to those AR apps, I want to add a 3D model with effects, say a dragon, to a video. Something like this famous demo https youtu.be u5hQpRbHERg But I don't really want to make it this fancy with camera tracking. I like to start with the simplest approach probably just placing a dragon on the field (like its last scenes) with fixed camera. What's the best way to do it? Some tutorials would be very helpful.


Cave lighting in Unity I have a cave that is inside a mountain (one mesh) that I created in Blender. I would like to make the cave quite dark inside so that either the player can light it up, or it is lit up with things such as crystals. Because I have ambient light through the scene, it's proven to be quite awkward to make it dark, and removing the ambient light kinda destroys the look. I then played around with having a separate material for inside the cave so that I can make it darker, which kinda worked, but then I noticed a big issue with shadows. The following images is from inside the cave far from the entrance. The first image is with the default settings for shadow distance (in this case it was 70 in the quality settings). As you can see in the image, the shadow doesn't fill the cave because of the distance. Second image is with the shadow distance turned up to make sure the cave is in darkness (not pitch black though, due to ambient lighting), this took the setting from 70 to around 500. The problem with setting the distance so high, is that it causes artifacts on geometry outside the cave, which look nasty. What's the best way to make a cave dark (doesn't need to be pitch black) without removing ambient lighting for the whole scene? I was looking at similar art styles to what I am working on, and Grow Home (Unity) is basically where I am heading. They have caves which would be acceptable for what I need, but am not sure how they done it. As far as I know, they have dynamic lighting, as I believe there is a day night cycle, so I don't think anything is baked.


No Support for UnityScript (JavaScript) on 2018.3 Hey I ve been working on a project for over 3 years and yesterday I have updated the unity from 2018 to 2018.3 and lost support for JavaScript. All of my scripts attached to gameobjects are there but not working while playing the game. I ve tried the UnityScript to C website but didn t work. I m a macOS user so couldn t use the converter tool on git (because it s been developed only for windows). I ll appreciate any suggestions.


Shader to see silhouette through alpha blended sprites I want to achieve in Unity a see through effect like the one in these examples In my specific scenario there are a couple of requirements Sprites are using alpha blending, and sprites have transparent areas. There are 2 kind of elements that occlude the character. One should create the silhouette effect, and the other one should behave like normal. For occluding elements that create the silhouette I enable ZWrite, and disable it for elements that doesn't. For the character I tried setting the queue of the shader to transparent 1, and added this pass Pass ZTest Greater Lighting Off Color Color And the effect works partially The silhouette is drawn all over the character, even the parts that are transparent. Transparent parts shouldn't create a silhouette. The silhouette is created when the character is behind a sprite, even if that part of the sprite is transparent. Being behind a transparent part of the sprite shouldn't create the silhouette. The character appears infront the rest of the elements, even if it is behind them. I guess this is because setting the queue to Transparent 1. But if I leave it as Transparent, the character is drawn in the correct order, but the silhouette is never seen. I tried to follow these tips someone gave me, but I'm unable to get it to work 1) Leave the pass that renders the sprites as is. 2) Add a pass that writes to the z buffer, but has a shader that uses clip() to discard pixels based on alpha. You can't use the z buffer to make soft z tests without using MSAA and alpha to coverage. The quality of that won't be great, but it's the best you can do. A faster alternative is a pattern or noise dither, or a good old fashioned threshold if your sprites all have fairly sharp edges. 3) Add third pass to occludable objects that draws the occlusion color using the z test and make sure it's drawn as a final pass. I'm kind of new to shaders, specially in Unity, and I just can't figure out how to make it work properly.


Using Physics.Raycast inside OnCollisionEnter2D function void OnCollisionEnter2D(Collision2D collision) foreach(ContactPoint2D contact in collision.contacts) RaycastHit raycastInfo Physics.Raycast(contact.point, Vector3.forward, out raycastInfo, 1000.0f) if(raycastInfo.collider) Debug.Log("Hit!") I am using this code to raycast an abject with the contact position of collision. The collision part works fine, when collision happens this function is triggered. But when I raycast to that position, RaycastHit variable return empty. I couldn't find what I am doing wrong.


How to avoid spaghetti in the animator? I am working with animations in Unity and so far I have made only four (Up Down Left and Right) and my animation window looks following... Problem is that if I was moving Up I want hero to stay looking Up not go to 'neutral idle' (or however he started), but that means I have 4 Idle positions... and each of them can transition to Up, Down, Left or Right and they go exponentially with each additional action... Which makes me feel like I am doing something wrong.... Is there a better way of making transitions between different actions?


How to randomize Motion animation without create a state for each animation? I'm using Animator and state for animating my charachter. So, i've (example) an Idle state, associated to an Idle motion animation , and a Death State, associated to a Death animation. But I've 5 possible animation for death so i would like to randomize death animation without create a state for each animation. My State "Death" has a "Motion" variable. I would like to change at runtime this "motion" variable. Is it possible ? Thanks


Help needed, following Unity multiplayer Health Bar tutorial. Only working on Server Host instance of the game was really hoping someone can be good enough to look over my code, I've been trying to fix it for several days. I followed the Unity tutorial which is fairly basic but the bit that confuses me (and potentially where the problem lies) is the if (!server) return part at the top of my TakeDamage() function. The problem im seeing is that once I get to that part of the tutorial, the bullet fired by the Host is registered against the other player and I can see his health has gone down (great so far!) , but when I load the instance in the editor (i did running another standalone on my laptop and connect to internet matchmaking but the same thing occurs) his bullets are not registered (even though my debug log tells me the Ray did hit the player. The tutorial tells me to make it return if not server, it then uses SyncVar and a hook that is supposed to call the method "OnChangeHealth" whenever currentHealth is changed. This DOES NOT appear to be happening, and the TakeDamage code is only happening on the Server Client Host instance. I was trying to adapt the tutorial to my own game, so there are some slight differences in the function and class names, but to me it looks to be exactly the same functionality wise. I will have to just post my full code here as I don't know which part is causing the issue (MANY THANKS FOR READING AND OR HELPING) the Player class public class Player NetworkBehaviour private GameObject startScreen public const int maxHealth 100 SyncVar(hook "OnChangeHealth") public int currentHealth maxHealth private float playerHeight private AudioSource audioSource public AudioClip painBodySound public AudioClip painHeadSound public AudioClip painHeadSound2 public RectTransform healthBar void Start () startScreen GameObject.FindGameObjectWithTag("StartScreen") if (startScreen ! null) startScreen.SetActive(false) playerHeight GetComponent lt Collider gt ().bounds.size.y currentHealth maxHealth audioSource GetComponent lt AudioSource gt () void Update () if (!isLocalPlayer) return if (Input.GetKey(KeyCode.LeftControl)) transform.localScale new Vector3(1, 0.5f, 1) else transform.localScale new Vector3(1, 1f, 1) public void TakeDamage(Vector3 hitPoint, int bulletDamage) check that its Server so that damage only gets applied on the server if (!isServer) return currentHealth bulletDamage audioSource.PlayOneShot(painBodySound) if (currentHealth lt 0) currentHealth 0 Debug.Log("Dead!") private void OnChangeHealth(int health) healthBar.sizeDelta new Vector2(health, healthBar.sizeDelta.y) Inside the bullet class is this function private void CastBulletRay() ray new Ray(bulletSpawnPos, bulletSpawnDirection) if (Physics.Raycast(ray, out hit, bulletRayDistance)) if (hit.collider.tag "Baddie") Debug.Log("ray has hit a baddie") Destroy(gameObject) if (hit.collider.tag "Player") Debug.Log("ray has hit a player") hit.collider.gameObject.GetComponent lt Player gt ().TakeDamage(hit.point, bulletDamage) Destroy(gameObject) and inside The Unity RigidBodyController class I'm using, I added Command void CmdFireBullets() muzzleFlashObject.SetActive(true) audioSource.PlayOneShot(gunFireSound, 0.2f) Create a new bullet GameObject newBullet Instantiate(bulletPrefab, bulletSpawnPoint.transform.position, bulletSpawnPoint.transform.rotation) as GameObject Spawn the bullet on the clients NetworkServer.Spawn(newBullet)


How can I parse different types of objects from JSON? I'm trying to save the player's inventory as a JSON data but I'm having a problem. I have a class Sword which extends an abstract class Weapon which extends another abstract class called Item. This is what JSON file looks like with the Sword and Armor objects in it "category" "type" "Weapon", "subtype" "Sword" , "id" 0, "value" 1, "name" "Wooden Sword", "description" "Sword made out of wood", "slug" "wooden sword", "stats" "wear" 100, "damage" 5 , "category" "type" "Armor", "subtype" "Helmet" , "id" 1337, "value" 1, "name" "Steel Helmet", "description" "Whatever...", "slug" "steel helmet", "stats" "wear" 100, "defence" 5, "vitality" 3, "dexterity" 1 How can I parse these objects into their respective C objects, putting the first entry into a Sword object and the second one into a Helmet object. There will be other types of objects in there too, so it's not limited on these two.


Unity's Android Notification system works on my Xiaomi, but on a Huawei every notification has an "Unknown" status? When my app starts I check whether there is a notification or not if there isn't I create one via SendNotification(...) if there is, I check their status var status CheckScheduledNotificationStatus(notificationId) On my Xiaomi their status is Scheduled, so I update them SendNotificationWithExplicitID(...) But on a Huwaei it's always Unknown, in that case I create a new SendNotification(...) And replace the old ID in the PlayerPrefs. But on the next startup it's unknown again. Maybe I should use SendNotificationWithExplicitID(...) as well when the status is Unknown so I can keep the ID? Here is the code var notification CreateNotification(jsonWrapper.Name, fireTime, title, text) if (PlayerPrefs.HasKey(jsonWrapper.Name)) var notificationId PlayerPrefs.GetInt(jsonWrapper.Name) var status AndroidNotificationCenter.CheckScheduledNotificationStatus(notificationId) if (status NotificationStatus.Scheduled) AndroidNotificationCenter.SendNotificationWithExplicitID(notification, "default", notificationId) Logger.Log( "Updated a notification jsonWrapper.Name at fireTime .") else if (status NotificationStatus.Unknown) var id AndroidNotificationCenter.SendNotification(notification, "default") PlayerPrefs.SetInt(jsonWrapper.Name, id) PlayerPrefs.Save() Logger.Log( "UnknownStatus Registered a new notification jsonWrapper.Name at fireTime .") else var id AndroidNotificationCenter.SendNotification(notification, "default") PlayerPrefs.SetInt(jsonWrapper.Name, id) PlayerPrefs.Save() Logger.Log( "Registered a new notification jsonWrapper.Name at fireTime .")


How to rotate object just like in the scene? Look at this image, I selected an object and pivot is set to local When I rotated selected object in the scene by X axis, it rotates exactly I wanted. But if I rotate axis from inspector or script, it doesn't rotated to desired angle. I'm not sure, but it seems it's related about Quaternion, but everything I tried doesn't worked well. How do I rotate that object just like in rotated from scene?


How can I retain the soundtrack state across levels to have continuous play? Suppose I have two levels. I want the same soundtrack to play on both of them. At the moment I have an audio source in each level, playing the soundtrack. However, when you move from one level to the other, the soundtrack will of course restart over (because it's a different audio source). How can I "resume" the soundtrack? Or rather, how can I retain the soundtrack state across levels to have continuous play?


Unity C Game Object Movement Issue I'm trying to move a game object within a set x and y range. I thought the code below would work, but it does nothing. The idea is the player controls the platform and tries to move under the ball. Any suggestions would be appreciated. using UnityEngine using System.Collections System.Serializable public class Boundary public float xMin, xMax, yMin, yMax public class PlatformController MonoBehaviour public float speed 10f public Boundary boundary public Rigidbody platformRB void Start() platformRB GetComponent lt Rigidbody gt () void FixedUpdate() float moveHorizontal Input.GetAxis ("Horizontal") float moveVertical Input.GetAxis ("Vertical") Vector3 movement new Vector3 (moveHorizontal, moveVertical, 0f) platformRB.velocity movement speed platformRB.position new Vector3 ( Mathf.Clamp (platformRB.position.x, boundary.xMin, boundary.xMax), Mathf.Clamp (platformRB.position.y, boundary.yMin, boundary.yMax), 0f ) Here's how the rolling ball works (as is intended) using UnityEngine using System.Collections public class BallMovement MonoBehaviour public Rigidbody ballRB public float thrust Use this for initialization void Start () ballRB GetComponent lt Rigidbody gt () Update is called once per frame void FixedUpdate() ballRB.AddForce (Vector3.right thrust)


After building a .exe file game view does not show whole viewport So, I went to build a game today in a .exe, and when I build it, it doesn't show the whole viewport as it does in the unity engine itself. So the game is cut off. It does this no matter what I do. What I see in Unity What I get running the exe Anyone know what's causing this?


Animation import What am i doing wrong? I need some help with an Animation that i want to import with Humanoid type (made in Blender). Essentially i made an animation in blender with IK FK (Rigify, with a bone for the sword, and IK to the hand). This is the preview in blender https i.gyazo.com 4f197c5e0ff1b291b45399fb4325ffc9.mp4 And this is when i import and set the animation with humanoid (activated the mask on the sword bone, parented with the root bone) https i.gyazo.com b042c29895be8e3db93edaa22e2a3665.mp4 In Blender i keyed IK and FK swith with the slider of Rigify, so i can move the hand without sliding. What i'm doing wrong? This is the Blender Rig (Rigify) with the sword bone https i.gyazo.com 00a1f9f523e67c0371b7f00e48c58ae9.mp4


How to slide a non kinematic rigidbody? I'm studying Unity3d, coming from a 2d background, and I'm a bit confused how some things work. I'd like to slide a non kinematic rigidbody, i.e. "just move it forward", like if it was hovering over the terrain. Applying a force makes a ball rotate forward, while I wanted it to slide forward without rotating, also unless that force is huge, a cube just won't move (for the same reason). I understand there are kinematic objects which are "easier" to "just move", but I both think I might really need non kinematic ones, and I think I need to understand them anyway. edit I did try to use some "rotation constraints freeze", but they just prevented the sphere from moving at all.


Create a stack driven coroutine based state machine for Unity I am working on a game where I am using a coroutine based state machine which is mostly a multi class implementation of this link. I am using it because it allows me to create multi frame sequences. I wanted to know how would I go about making a stack based machine, so that I can overlay game states such as when I want to pause the game to show a menu i can run a pause menu state pausing the running game state, while still allowing the state objects to be rendered in the background Here is the code I am using for a state public abstract class State Inject MonoBehaviour gameObject Inject public EventSystem eventSystem StateMachine parent public State(StateMachine p) parent p public abstract IEnumerator Enter() public abstract IEnumerator Exit() public abstract IEnumerator Update() public IEnumerator Run() yield return gameObject.StartCoroutine(Enter()) while(parent.CurrentState.GetType() GetType()) yield return gameObject.StartCoroutine (Update ()) yield return gameObject.StartCoroutine (Exit()) State machine run function State Current The current state , the one at the top of the stack while(Current! null) yield return Component.StartCoroutine(Current.run()) The problem with this approach is as soon as the state machine's current state changes (That is when i push it down the stack adding a new state on top) , the while loop in the Base state class's run method will end and will call the exit coroutine causing the state to end which is undesirable as according to the stack pattern the state should be paused Moreover as coroutines work in unity, the yield return statement(in the state machine) wont return until the previous started coroutine exits , which is currently as of now responsible for starting the states . My question is how do i alter this code so as to pause the previous state (that will be pushed into the stack) instead of exiting it and starting anew state this implementation works fine if there is to be only a single state in the memory


UNET spawn dynamically generated object unity Spawning works when all clients are connected, but if a client connects after I spawn all my prefabs there are errors. I spawn the object before changing its Rigidbody's velocity, which seems to cause the problem. I spawn objects, change them, then the other client joins, and the errors come. these are the errors Failed to spawn server object, assetId 953c1c6ecbb84304280d1334ef5dae0b netId 26 I also make changes to variables on other scripts. All objects have network identities, network transforms, and are spawnable prefabs.


Calculating the weight of an object irrespective of the triangle or vertices count in Unity I have a meat piece which I want to weigh. Now there can be anything like fish, cheese, or other items that we can cut and measure. I want the weight to be determined by myself instead of determining from getting the surface of the item as it varies with different tris count. Currently, I am calculating the weight from the following code. public static float CalculateSurfaceArea(Mesh mesh) var triangles mesh.triangles var vertices mesh.vertices double sum 0.0 for (int i 0 i lt triangles.Length i 3) Vector3 corner vertices triangles i Vector3 a vertices triangles i 1 corner Vector3 b vertices triangles i 2 corner sum Vector3.Cross(a, b).magnitude weightMultiplier is a constant value for getting a reasonable weight value. return (float)(sum 2.0) weightMultiplier So if there's a meat piece like bellow and I want it to be a weight of let's say 3kg(6.6lb) then when I cut it into half it should give me values respectively (1.5kg). So I want the weighing factor to be in my control so that if in the future we have really detailed high poly items the weight shouldn't get affected by that.


How hard is it to port games from the PC to other platforms? I am trying to learn game development with the Unreal Development Kit and Unity, trying both out, and trying to get an idea how they work. For now, I'm mostly focusing on PC games. How hard is the technical aspect of porting a PC game that I made in the Unreal Development Kit or Unity to another platform, such as Play Station 3, or Xbox 360? is there some kind of option where we can just select the target platform from a combo box and press deploy, or do we need to modify the game for each platform?


How can I call Schedule() on interface that inherits from IJob So I have a voxel terrain engine, and I have an interface that all meshing jobs should inherit from. That looks like this (simplified from the actual) public interface IMesherJob IJob VoxelDataVolume lt byte gt VoxelData get set NativeArray lt MeshingVertexData gt OutputVertices get set NativeArray lt ushort gt OutputTriangles get set One example of a meshing job is marching cubes, which looks like this public struct MarchingCubesJob IMesherJob So here's my question If I have a reference to an IMesherJob, can I somehow call Schedule on it? If I have a reference to MarchingCubesJob, I can call Schedule on it This works MarchingCubesJob myMeshingJob GetMeshingJob() JobHandle handle myMeshingJob.Schedule(voxelCount, 64) But this does not work IMesherJob myMeshingJob GetMeshingJob() JobHandle handle myMeshingJob.Schedule(voxelCount, 64) I noticed that Schedule() is an extension method for T where T struct, IJob so that might be interfering with it, but it should still work because IMesherJob inherits from IJob


Accessing a char array from another class I'm working on a crossword puzzle game. In order to set the letters in my tiles, I have a script attached to text components that accessing a char array that stores my letters. It looks like this First class public class GenerateBoard MonoBehaviour public static char , gameBoard new char 15,15 void Start() gameBoard 0, 0 'W' Second class public class SetLetter MonoBehaviour Text letter public int x public int y Start is called before the first frame update void Start() letter GetComponent lt Text gt () letter.text GenerateBoard.gameBoard x,y "" Update is called once per frame void Update() Debug.Log("glitch " GenerateBoard.gameBoard 0, 0 ) I would expect Debug.Log to print 'W' but it appears to be empty. Why isn't it accessing the letter 'W' from the first class? When I use Debug.Log in my first class it properly prints 'W'.


admob ads problem in uity In unity 2019.1.3f I want to implement google admob ads in that game but after importing GoogleMobileAds v3.18.0.unitypackage in to my project I got a porblem. when I hit play button this window poped up. Please help me regarding the problem Thank you


GameObject not exiting through leftScreen I'm trying to wraparound game object so that, it exits through right screen and enters through left and vice versa. The code snippet below is what I'm working on. Vector3 Pos mainCam.WorldToScreenPoint(transform.position) Vector3 LS mainCam.ScreenToWorldPoint(new Vector3( 1, 0f, 0f)) Vector3 RS mainCam.ScreenToWorldPoint(new Vector3(1, 0f, 0f)) if (Pos.x gt Screen.width) transform.position new Vector3(LS.x, transform.position.y, transform.position.z) if (Pos.x lt 0) transform.position new Vector3(RS.x, transform.position.y, transform.position.z) So far, exit through right and re enter through left works, but the gameObject does not exit through the left screen, there seems to be a barrier preventing it, or maybe my parameters for the second if statement are wrong.


How to merge Sorting Layers in Unity? I have two unity3d projects, both are using sprite renderers and sorting layers. Project 1 has Following Sorting Layers Default Tile Map Items Animals UI Particles Project 2 has Following Sorting Layers Default Background Slots Chips Foreground Map UI Project 1 is my main project. I need to merge these both projects. I created new layers in project 1 and then imported project 2 but sorting layers of project 2 are broken .Setting each layer again in project 2 is very difficult task and rework. How can i merge these two project without breaking any sorting layer or tags ?


Unity Failed to build APK. See console for details i am getting this error whenever i am trying to build a project. i looked at so many solutions but this one just doesn't go away. This is the error CommandInvokationFailure Failed to build apk. C Program Files Java jdk 9 bin java.exe Xmx2048M Dcom.android.sdkmanager.toolsdir "C Users Mohit AppData Local Android sdk tools" Dfile.encoding UTF8 jar "C Program Files Unity Editor Data PlaybackEngines AndroidPlayer Tools sdktools.jar" stderr Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java 62) at java.base jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java 43) at java.base java.lang.reflect.Method.invoke(Method.java 564) at SDKMain.main(SDKMain.java 130) Caused by java.lang.NoClassDefFoundError sun misc BASE64Encoder at com.android.sdklib.internal.build.SignedJarBuilder. lt init gt (SignedJarBuilder.java 177) at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java 446) at com.android.sdklib.build.ApkBuilder. lt init gt (ApkBuilder.java 422) at com.android.sdklib.build.ApkBuilder. lt init gt (ApkBuilder.java 362) at UnityApkBuilder. lt init gt (UnityApkBuilder.java 214) at UnityApkBuilder.main(UnityApkBuilder.java 34) ... 5 more Caused by java.lang.ClassNotFoundException sun.misc.BASE64Encoder at java.base java.net.URLClassLoader.findClass(URLClassLoader.java 466) at java.base java.lang.ClassLoader.loadClass(ClassLoader.java 563) at java.base java.lang.ClassLoader.loadClass(ClassLoader.java 496) ... 11 more stdout exit code 1 UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.HostView OnGUI() what i have tried so far 1) downgrading android sdk 2) moving zipalign file from build tools to tools folder 3) setting up keystore


How to approach a coloring app? I want to make a coloring app in unity. I don't need flood filling. THe player will select a color and click the shape to fill that color. The app will have designs as shown below Here the problem is, design has to be empty with black outline. One way would be to create textures using the jpg of each shape. However, there are thousands of shapes and each can be colored in about 7 colors. So, i will have to create 7 textures for each shape.Is there any way to create model with black outline so that only inner color can be changed?


AddForce doesn't work anymore when Acceleration is added Everything worked fine until I added acceleration on the x axis..now when I try to jump it just lifts up very little from the ground in a weird way and then it slowly sinks down like having 0 gravity. Here is the code I'm using public class PlayerMovement MonoBehaviour public float baseSpeed 10f public float maxSpeed 10f public float timeFromZeroToMax 10f public float jumpSpeed 10f public Collider coll float accelRatePerSecond float forwardVelocity Rigidbody rb void Awake () rb GetComponent lt Rigidbody gt () coll GetComponent lt Collider gt () accelRatePerSecond maxSpeed timeFromZeroToMax forwardVelocity 0f void FixedUpdate() transform.Translate(transform.right baseSpeed Time.deltaTime) forwardVelocity accelRatePerSecond Time.deltaTime forwardVelocity Mathf.Min(forwardVelocity, maxSpeed) if (isGrounded() amp amp Input.GetKeyDown("w")) rb.AddForce(transform.up jumpSpeed Time.deltaTime, ForceMode.Impulse) void LateUpdate() rb.velocity transform.right forwardVelocity bool isGrounded() return Physics.Raycast(transform.position, Vector3.down, coll.bounds.extents.y 0.1f)


How to serialize animation state? In Unity, I have an Animator on a character. Upon saving loading the game, I want to preserve the pose and animation state the character is in. However, I can see no way to read write all the data from the Animator Animation Controller in such a way that I can store it in and retrieve it from a binary file. Is there a non obvious way to achieve this?


Depth write and depth test in Unity Scenario several objects (o1, o2,.., on) have to be rendered with the z test disable, but the z values must be written to the depth buffer. In another pass, some other objects (t1, t2,..., tm) need to be rendered considering with the z test enabled, and considering the prior values from the previous pass. Is it possible to achieve this with Unity's material script? The goal is to support a custom order for the rendering of transparent objects (the o1,..,on in the scenario description) alongside with matte objects (t1,..., tm). I tried using the features mentioned here, but the results were incorrect, i.e. as if the z values were completely discarded inbetween passes. Can anyone, perhaps, share a code stub for this scenario?


Object made of cubes looks different based on the distance in Unity3D? I made a "Wall" from basic Unity3D cubes. They are placed tightly so the wall looks like one big rectangular prism. If I look at it from close distance, it looks as it should be one big rectangular prism. But if I start moving backwards, away from the wall, the cubes' edges become visible And this whole thing happens in a circular way. If I just start moving backwards from the wall, first I start to see the cubes' edges just at the further parts of the object, and then the pure white circle starts shrinking, the edges become visible at bigger and bigger parts of the object. then the blurrier edges appear at the further places and the previously appeared sharper edges circle starts shrinking as well. (this phase is shown on the image above) This should be some kind of shading optimization, like mipmap, right? How can I fix this? I want the wall to be seamless from all distances. Update Changing the shader to Unlit gt Color, fixes the issue. This thing only occurs on the lit side of the wall. The shadowy side of the wall, (which isn't lit directly by the directional light of the scene) is rendered normally.


How to "place" object in a 3d world without overlapping them ? I would like to place object in a 3d world "like minecraft player can do". What I'm trying to do is to allow the user to place objects, without overlapping them (like in minecraft you can do). So if the player try to place an object partially over another, my game automatically "move and place" the object in the allowed position. What can be the right approach ?


How do I account for the velocity difference between a ship and it's fired projectile? In my project, I have a ship that moves and increases it's movement speed with respect to time and how long the acceleration button is being pushed(just like the way a real life car works), now as expected, the ship fires projectiles when I press the fire button. The problem here, is that at a point in the game, the ship reaches it's highest speed terminal velocity, and now it's faster than the projectile it fired which is not what I want, so, how do I create a realistic projectile movement based on the ship's velocity? This is so that if the projectile is fired when the ship is moving slowly through the game scene, it doesn't move so fast that we can't see it travelling in the forward direction, and at the same time if it is fired when the ship is moving at top speeds, the ship is not seen to be faster than or as fast as the projectile's speed. I want to keep the code as optimized as possible, so I am using this line for the projectile's movement public float velocity 100f void Update() transform.position transform.forward Time.deltaTime velocity


Moving script not working after SetActive Pause change I have a pause menu for my game which instantiates a texture and sets a text frame to active and slides both objects onto the screen using the code below Instantiating the menu texture and activating the text frame public void MenuPressed () Vector3 newPosition new Vector3 ( 13, 0.06f, 2) Quaternion newRotation Quaternion.Euler (0, 0, 0) Instantiate (menu, newPosition, newRotation) menuButton.SetActive (false) textFrame.SetActive (true) Time.timeScale 0 Moving the menu items float xLimit 5 float speed 0.6f void Start () StartCoroutine ("MoveMenu") IEnumerator MoveMenu () while (true) transform.position Vector3.right speed if (gameObject.name "Main Text Frame") xLimit 7 if (transform.position.x gt xLimit) yield break yield return new WaitForEndOfFrame () Now this all works fine, but the issue that I have is on a multiple pause situation. When the pause button is pressed and spawns the menu and activates the text, the game pauses as expected. One of the options on the menu is to resume playing, when the pressed the game carries on as expected. The problem I am having is that if the pause button is pressed again, the menu texture spawns in and slides on screen as intended, but the frame for the text does not. The frame gets set active but does not actually move. Any ideas for how to fix this? P.S Here is the code I use to resume the game after it had been paused public void Button1Pressed () Time.timeScale 1 GameObject menu GameObject.FindWithTag ("Menu") Destroy (menu) gameController.paused false textFrame.SetActive (false) menuButton.SetActive (true) textFrame.transform.position new Vector3 ( 15.2f, 4.0f, 2.5f)


Making a new instantiated prefab as a child for existing GameObject I've been searched about how to make these fruit to move as the basket movement if it collided with it, and I've been found that if I want to perform this I've to let these fruit to be a child to the basket game object .. for example banana.transform.parent basket.transform banana and basket each of them of type "GameObject" ... BUT unfortunately this way didn't work !! and I don't know why ?? So now I need to know if it is possible to destroy the banana if a collision with the basket happened and instantiate a new banana in the basket as a child at run time ?!! I need to try this stupid way because I've tried all the other ways and nothing worked (


Correct way to project a texture with alpha and colors onto surfaces in Unity I am experimenting with Unity and wanted to project a unit circle beneath a unit and my very first naive approach was to create a child plane below the unit, assign the material to it and stretch it using the Pro Builder UV editor but it looked horrible In order to figure out what's wrong I read a lot of various approaches to "fix" that issue which were mostly the following use a higher resolution for the texture do not use any compression do not use a POT resolution change the filtering option from bilinear to point ... Eventually I figured that I have to do something completely different and that is how I stumbled upon the idea to use a shader attached to a projector game object in order to project a material. Unfortunately though it turns out the shader expects a grayscale image and only tints the projection based on a parameter. For reference this is the shader I have just copied from the web (source) Shader "Projector AdditiveTint" Properties Color ("Tint Color", Color) (1,1,1,1) Attenuation ("Falloff", Range(0.0, 1.0)) 1.0 ShadowTex ("Cookie", 2D) "gray" Subshader Tags "Queue" "Transparent" Pass ZWrite Off ColorMask RGB Blend SrcAlpha One Additive blending Offset 1, 1 CGPROGRAM pragma vertex vert pragma fragment frag include "UnityCG.cginc" struct v2f float4 uvShadow TEXCOORD0 float4 pos SV POSITION float4x4 unity Projector float4x4 unity ProjectorClip v2f vert (float4 vertex POSITION) v2f o o.pos UnityObjectToClipPos (vertex) o.uvShadow mul (unity Projector, vertex) return o sampler2D ShadowTex fixed4 Color float Attenuation fixed4 frag (v2f i) SV Target Apply alpha mask fixed4 texCookie tex2Dproj ( ShadowTex, UNITY PROJ COORD(i.uvShadow)) fixed4 outColor Color texCookie.a Attenuation float depth i.uvShadow.z 1 (near), 1 (far) return outColor clamp(1.0 abs(depth) Attenuation, 0.0, 1.0) ENDCG With that shader I was able to render the following effect Since I have no experience with shaders at all I just blatantly copy amp pasted it and do not know (yet) how to customize them or even write custom ones in the first place. Assuming my approach to combine a projector with such a shader is the way to go, I'd like to know whether there is any shader you can share that allows me to project an unlit texture with transparency and its own color such as the following example


Reopening Unity project after two week break, project is trashed I've spent about 6 months using Unity nearly every day. Then I take a two week break, re open my project, and the entire build is trashed. There are 166 errors, here are a few Assets TextMesh Pro Examples amp Extras Scripts ChatController.cs(6,14) error CS0101 The namespace ' lt global namespace gt ' already contains a definition for 'ChatController' private Renderer renderer Assets Scripts Board Tile.cs(23,22) warning CS0108 'Tile.renderer' hides inherited member 'Component.renderer'. Use the new keyword if hiding was intended. Assets TextMesh Pro Examples amp Extras Scripts ObjectSpin.cs(8,18) error CS0101 The namespace 'TMPro.Examples' already contains a definition for 'ObjectSpin' I've re imported Text Mesh Pro Examples amp Extra, restarted my project multiple times, to no avail. This is very concerning to me because it makes me feel like Unity is not a stable plaform ... Are Unity projects attacked by gremlins if not used every couple days?


Chroma depth shader unity I'm trying to reproduce a post effect with unity seen in the answer here. Chromadepth answer For the moment I just manage to reproduce the wave effect with a quick edge detection. I tried multiple textures but can't find one that fit do the same effect. I am using this texture The result for far. Shader "Unlit ChromaDepthEdge" Properties MainTex ("Texture", 2D) "white" Ramp ("Texture", 2D) "white" Threshold("Threshold", Float) 0.1 SubShader Pass ZTest Always Cull Off ZWrite Off CGPROGRAM pragma vertex vert pragma fragment frag pragma target 3.0 include "UnityCG.cginc" struct appdata float4 vertex POSITION sampler2D MainTex sampler2D Ramp Request camera depth buffer as a texture. Incurs extra cost in forward rendering, "just there" in deferred. sampler2D CameraDepthTexture float4 MainTex TexelSize float4x4 InverseViewMatrix float Threshold void vert ( float4 vertex POSITION, out float4 outpos SV POSITION) outpos UnityObjectToClipPos(vertex) fixed4 frag (UNITY VPOS TYPE screenPos VPOS) SV Target Convert pixel coordinates into screen UVs. float2 uv screenPos.xy ( ScreenParams.zw 1.0f) uv.y (uv.y 1) 1 Depending on setup platform, you may need to invert uv.y Sample depth buffer, linearized into the 0...1 range. float depth Linear01Depth( UNITY SAMPLE DEPTH(tex2D( CameraDepthTexture, uv))) float2 uvDist 3 MainTex TexelSize.xy float depthUp Linear01Depth(UNITY SAMPLE DEPTH(tex2D( CameraDepthTexture, uv uvDist float2(0, 1)))) float depthDown Linear01Depth(UNITY SAMPLE DEPTH(tex2D( CameraDepthTexture, uv uvDist float2(0, 1)))) float depthLeft Linear01Depth(UNITY SAMPLE DEPTH(tex2D( CameraDepthTexture, uv uvDist float2( 1, 0)))) float depthRight Linear01Depth(UNITY SAMPLE DEPTH(tex2D( CameraDepthTexture, uv uvDist float2(1, 0)))) float mean ((depthUp depth) (depthDown depth) (depthLeft depth) (depthRight depth)) 4 Compressing the range, so we get more colour variation close to the camera. depth saturate(2.0f depth) depth 1.0f depth depth depth depth 1.0f depth return depth Use depth value as a lookup into a colour ramp texture of your choosing. fixed4 colour tex2D( Ramp, depth 6 Time.y 4) return lerp(colour, colour 6, mean gt Threshold) ENDCG What did I miss ? Thanks in advance.


How can I optimize coroutines? I have a script which has a Queue datastructure (code below). This queue holds more than 100 Actions. So currently my script does a yield return null after every Dequeue, which means that one Dequeue() call is executed every frame. private static readonly Queue lt Action gt DataQueue new Queue lt Action gt () private bool isHandlingQueue Helper bool to check if Coroutine is active private IEnumerator HandleQueue() isHandlingQueue true while (DataQueue.Count gt 0) DataQueue.Dequeue().Invoke() yield return null isHandlingQueue false yield return null I'm trying to achieve that multiple Dequeue and Invoke actions take place in the same frame. One Dequeue and Invoke takes between x and y ms, this varies depending on the Action itself. Example Lets say the Queue has 100 entries and the game runs at 60 frames per second (minimum). One iteration (Dequeue Invoke) in the while loop takes about 5 ms in this example. Here is the thing In this case it is essentially waiting for 11.67 ms for the next frame (16.67 ms each frame at 60fps). I don't want the system to wait, but use the remaining 11.67 ms to Dequeue and Invoke 2 more Actions, so it only waits for 1.67ms each frame. In this ideal case the Queue get's cleared in 34 frames instead of 100 frames. All help to point me in the right direction is appreciated!


Assign a ScriptableObject to MonoScript through code Sample code public class Item MonoBehavior public ItemObject item the scriptable object void Start() do stuff Normally I would drag and drop the asset of the ScriptableObject in the inspector. How can I find and assign the asset (from Project View) through the script during runtime and possibly add it to a List lt gt or Array ?


How do I storing a Score in each level? I have a problem when I store the DistanceScore to text, the problem is why the DistanceScore always storing at text number 1, this happens when I play at level 2 which is the DistanceScore could be store in text number 2and so on, FYI I have 3 levels here. here the preview as you can see on the top of level 2 gameplay is distance so when i dead the distance saved and storing to text each level. and when I go to the main menu the Level 1text updated instead of Level 2. this is my script public Item item public int mapIndex public enum ITEM TYPE LEVEL public ITEM TYPE type private void Start() loadItemInformation() public void loadItemInformation() for (int i 0 i lt item.Length i ) if ( type ITEM TYPE.LEVEL) item i .bestScore.enabled true item i .distance.enabled true float distanceUi PlayerPrefs.GetFloat( quot distance quot i.ToString()) float value PlayerPrefs.GetFloat( quot Time quot i.ToString()) float minutes Mathf.FloorToInt(value 60) float seconds Mathf.FloorToInt(value 60) if (value 0) item i .bestScore.text quot No Record Yet quot else item i .distance.text quot Unstopable quot item i .bestScore.text quot Best Time quot string.Format( quot 0 00 1 00 quot , minutes, seconds) item i .distance.text quot Long distance quot distanceUi.ToString() System.Serializable public class Item public TextMeshProUGUI bestScore public TextMeshProUGUI distance here the distance script region Distance Header( quot Distance quot ) public Transform checkPoint public TextMeshProUGUI distanceText M GameManager GameManager private float distance private float highDistance float index endregion private void Start() GameManager FindObjectOfType lt M GameManager gt () checkPoint GameObject.FindGameObjectWithTag( quot Finish quot ).transform distanceText GameObject.FindGameObjectWithTag( quot DistanceTxt quot ).GetComponent lt TextMeshProUGUI gt () index (float)(PlayerPrefs.GetInt( quot Level quot )) typo here i call it set and now I've fix it index PlayerPrefs.GetFloat( quot Level quot ) distance (checkPoint.transform.position.x transform.position.x) if (transform.position.x gt checkPoint.transform.position.x) distance 0 PlayerPrefs.SetFloat( quot distance quot index, distance) if ( GameManager.isDead GameManager.isTimeout GameManager.fuelFinished) PlayerPrefs.SetFloat( quot distance quot index, distance) PlayerPrefs.Save() distanceText.text distance.ToString( quot F1 quot ) quot m quot and for item i .bestScore.text this work to storing each level but why for the distance not working.


Generating Mesh using Compute Shaders I am working on a game project in unity which has a procedurally generated terrain made up of 16 128 16 chunks of blocks. The map size is going to be finite (Possibly up to 100 100 chunks). Currently the data for the chunk is stored in a 1D Array, and takes a couple milliseconds to generate. But generating the mesh takes longer, averaging 30 40ms. So generating terrain as it enters the range of the camera isn't feasible as it's too slow, and generating all the meshes on load up would take a lot of memory as well as a long time. I've thought about attempting to try it on the GPU through Compute Shaders (although I don't have any experience with them). Would generating the mesh for each chunk in a Compute Shader be viable efficient? (The chunks could be made smaller if would be more performant)


How to scale game with orthographic camera correctly? During porting to android I encountered that the game does not fit on the screen in portrait mode. It uses an orthographic camera. How could I scale to game to fit the screen in portrait mode?


Why does 'InvalidCastException Specified cast is not valid.' occur for ARKitFaceSubsystem? Why does 'InvalidCastException Specified cast is not valid.' occur for ARKitFaceSubsystem in the snippet below? var faceManager FindObjectOfType lt ARFaceManager gt () if (faceManager ! null) m ARKitFaceSubsystem (ARKitFaceSubsystem)faceManager.subsystem


Performance of manipulating a mesh in realtime Does Unity allow streaming mesh data that can be continuously changed? I have a level that is dynamically changing based on some parameters. The number of triangles stays the same, they just change positions. I'm speaking of around 2000 triangles that need their position updated each frame (they follow a spline that is computed on CPU), running on mobile phones. I can't use a TrailRenderer because the object is a whole level. I can't use bones, because I need to know the final position for each vertex for my custom collision code. The mesh should be marked Mesh.MarkDynamic.


How to access specific child indices (directly, not using tags or searches)? I have a game object whose prefab is structured a very specific way. It is a conveyor belt. I intend to arrange them end to end and animate them all at once using a script. Right now I am trying to get the normalized heading vector between two children, TargetStart and TargetEnd (see images below) You can see that both of these objects are children of the prefab's first child. Because all of these instances will be structured the same, I want to compute the heading for the conveyor belt by accessing the locations of these children by their indices relative to the parent (which sounds like it should be simple and should be more efficient than searching by name or tag). I am anticipating a structure like this (pseudo code) heading targetEnd's position targetStart's position vector3 heading gameObject.GetChild 0 1 .position gameObject.GetChild 0 0 .position vector3 direction heading heading.magnitude How can this be done? I would like to know this so I can access any child I need to for any object by the child's index.


How to update UI after changing text in a view After applying a text change to a scrolling view, how do you get the new height of the text, resize other UI elements around the changed text length, etc? Many have posted this question. Some have noted that the rect size doesn't change or that they have to wait multiple frames to then react to the UI updates.


Why is there a gameObject inside a GameObject In order to manipulate a game object via script in Unity I need to access the gameObject inside the main GameObject. Why is it structured this way? What is the main GameObject representing compared to the gameObject? public class Sun MonoBehaviour private GameObject satelliteGameObjects private Rigidbody satelliteRigidBodies public GameObject Satellites private void Start() if (Satellites null) Debug.LogError( "You haven't added a nameof(Satellites) .'") throw new InvalidOperationException( " nameof(Satellites) should not be null") satelliteRigidBodies new Rigidbody Satellites.Length satelliteGameObjects new GameObject Satellites.Length for (var i 0 i lt Satellites.Length i ) var satellite Satellites i satelliteRigidBodies i Satellites i .gameObject.GetComponent lt Rigidbody gt () satelliteGameObjects i Satellites i .gameObject satelliteRigidBodies i .AddForce(Vector3.up 100) In the example above, I'm passing a GameObject into this class. However, in order to call members on the actual game object, I need to go through the gameObject property.


How to force Landscape Mode Unity3D Android Game? I am developing a small side project on Unity that will ultimately be for Android but I cannot figure out how to force landscape on the device and when I have tried it out the game just goes all over the place! I am using Unity Canvas and have spent a long time with binding position points etc. but I cannot work it out! Could someone please tell me how to force the phone into landscape mode?


How do I get my mouse based input system to work on Android? I am developing the ball breaker game in unity and right now my game work with mouse click button. but i want my game work in android. so what changes i want to do in this code? So when i set the arrow and its jump ball and hit the brick. Here is the code with image BallController.cs using System.Collections using System.Collections.Generic using UnityEngine public class BallController MonoBehaviour public enum ballState aim, fire, wait, endShot public ballState currentBallState public Rigidbody2D ball private Vector2 mouseStartPosition private Vector2 mouseEndPosition private float ballVelocityX private float ballVelocityY public float constantSpeed public GameObject arrow Use this for initialization void Start () currentBallState ballState.aim Update is called once per frame void Update () switch (currentBallState) case ballState.aim if (Input.GetMouseButtonDown (0)) MouseClicked () if (Input.GetMouseButton (0)) MouseDragged () if (Input.GetMouseButtonUp (0)) ReleaseMouse () break case ballState.fire break case ballState.wait break case ballState.endShot break default break public void MouseClicked() mouseStartPosition Camera.main.ScreenToWorldPoint(Input.mousePosition) Debug.Log (mouseStartPosition) didClick true public void MouseDragged() didDrag true Move the Arrow arrow.SetActive(true) Vector2 tempMousePosition Camera.main.ScreenToWorldPoint(Input.mousePosition) float diffX mouseStartPosition.x tempMousePosition.x float diffY mouseStartPosition.y tempMousePosition.y if (diffY lt 0) diffY .01f float theta Mathf.Rad2Deg Mathf.Atan (diffX diffY) arrow.transform.rotation Quaternion.Euler (0f, 0f, theta) public void ReleaseMouse() arrow.SetActive (false) mouseEndPosition Camera.main.ScreenToWorldPoint(Input.mousePosition) ballVelocityX (mouseStartPosition.x mouseEndPosition.x) ballVelocityY (mouseStartPosition.y mouseEndPosition.y) Vector2 tempVelocity new Vector2 (ballVelocityX, ballVelocityY).normalized ball.velocity constantSpeed tempVelocity if (ball.velocity Vector2.zero) return currentBallState ballState.fire


How to get consecutive voice clips to sound natural In the game I'm working on I have to play several short consecutive voice clips to form a complete sentence. Example (each bracket is a different voice clip) Bob here, we're at some town and are on our way to some city . Stitching together different voice clips like this makes it sound stilted and disconnected. This is because there are unnatural pauses when switching clips, and the pitch and tone of the speaker changes. My current efforts include two methods for removing the unnatural pauses starting the next clip early if a silence is detected at the end of the preceding clip skipping the first few milliseconds of the new clip up to the first detected 'sound'. These work OK at removing the unnatural pausimh, but detecting what 'silence' is is difficult, especially when dealing with multiple voice actors and microphones. How could I make stitching together voice clips sound more natural? Any advice would be appreciated. This has to be done in real time inside the game (I'm using Unity), and can't be pre processed or done ahead of time.


Unity ScrollView not scrolling with Clamped or Elastic I have a ScrollView object in my project. It is set to Clamped. Inside the ViewPort, I have Content and what I actually want to scroll, a TextViewMesh. The Content has a Content Size Fitter, with its Vertical fit set to Preferred Size. The problem is, when I run it, and try to scroll, it does not scroll at all, in ScrollView to the current setting. If I set the ScrollView mode to Unrestricted, it scrolls to the infinity. What I am doing wrong? How can I set my ScrollView to scroll the text (which can vary in lenght)?


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?


How to give individual tiles their own collider in Unity's tilemaps? My floor tile is a 2D drawing of a 3D platform, for lack of a better description. I want my player character to stand not on the top of the tile but a little inside it, as the red circle does in the picture. How do I give this tile its own collider that would fit this shape, while letting others have a normal, square one?


Unity 3d 4.6b New GUI system doesn't take touch when already a touch event is occurring in 3d scene I know this is beta version but.. I have a Canvas Button which works fine when I tap it normally. I have a joystick in my scene which is drawn by separate camera other than mainCamera. now, while i am operating joystick without leaving it, if I tap on he Canvas Button it does not respond. When I lift finger from joystick and tap on it, it works fine. Same goes for another Canvas Toggle control. It has something to do with the layering or anything else...I'm not sure?


How do I make an object not appear grey regardless of distance? My moon texture is on a plane 500m away and I would like to know if there is a way to keep displaying the texture As opposed to it turning grey as pictured here regardless of the distance it is from the camera. Any help is greatly appreciated, Thanks.


In unity, making a navmesh for a tiny planet? I'm trying to build a scene in a small planet, and baking will always give me the result on the half top of the planet. But what I want is to create a navmesh all around the small planet. I am wondering if there is a way to convert a mesh that I well built in blender, to be a navmesh in Unity. That means using the mesh totally without baking. Or, if there is some other ways to create navmesh for my poor planet.


How to go back to the old input system? I have tried using Unity's new input system, but it's incredibly hard to learn, the documentation is poor, and the old system is much easier to work with. I would like to revert my project back to the old system, but I am unsure how to do that. How do i disable the package and reconfigure my project so it will accept code using the old system?


Unity how intercept Mouse Click on UI and not fire "shoot"? I've a classic void Update() if(Input.GetMouseButtonDown (0)) Fire() What i want to do is that if I click on a UI button , the Fire() routine not will be called. How to do to say Unity if InputGetMouseButtonDown(0) amp amp !UI clicked ?


Object goes straight through game object without colliding The "shot" is supposed to collide with the left bumper and then be destroyed, but the shot goes right through it. Both objects have a box collider. The following is the code I am using pragma strict var speed int 2 var collided with GameObject function Update () transform.Translate(Vector3( 1 speed Time.deltaTime, 0, 0)) function OnCollisionEnter (col Collision) if (collided with.tag "Left") Destroy(gameObject) I have made sure that all the tags are assigned correctly and that there are no spelling errors. The variable collided with is also assigned to the left bumper. What am I doing wrong?


Draw GUI.Button on certain position on a scrollable background Problem is in a 2D game I have a large background around 2 screens wide. And on there I got 4 buttons placed on top of background all over complete width. Now when I swipe of move my mouse around I scripted that the camera will move with it. So for the GUI.Buttons (Unity4.5) to stick on their place I used a variable drawX drawX Camera.main.transform.position.x 100 The 100 is for calculating it to pixels. I then add this to my buttons when drawing. scaleX Screen.width 1920f scaleY Screen.height 1200f if (GUI.Button(new Rect((500 drawX) scaleX, 700 scaleY, 325 scaleX, 425 scaleY), "")) Now the problem is that under 1920x1200 my target resolution everything works exactly pixel perfect. But when changing the resolution or aspect ratio to something else the drawX increases to much or not enough so the buttons don't move on the same pace as they did in the 1920x1200 version. Somebody got the solution for me?


360 Orbital Camera Controller I have a stationary cube in my scene that I'm orbiting a camera around. I have my MainCamera nested under a GameObject that I'm calling 'OrbitalCamera'. I setup the script so that a click (or tap) and drag will rotate the camera around the object in space so it feels like you're rotating the cube (ie if I click the top of a face on the cube, and pull down, I'm rotating the X value) but you'll actually be rotating the camera. For the most part, my script works. However, after rotating the Y so much, the camera is upside down and the X gets inverted. Here's my script public class OrbitalCamera MonoBehaviour public bool cameraEnabled SerializeField private float touchSensitivity SerializeField private float scrollSensitivity SerializeField private float orbitDampening protected Transform xFormCamera protected Transform xFormParent protected Vector3 localRotation protected float cameraDistance void Start () cameraEnabled true xFormCamera transform xFormParent transform.parent cameraDistance transform.position.z 1 void LateUpdate () if (cameraEnabled) TODO FIX PROBLEM WHERE WHEN CAMERA IS ROTATED TO BE UPSIDEDOWN, CONTROLS GET INVERSED if (Input.GetMouseButton(0)) if (Input.GetAxis("Mouse X") ! 0 Input.GetAxis("Mouse Y") ! 0) localRotation.x Input.GetAxis("Mouse X") touchSensitivity localRotation.y Input.GetAxis("Mouse Y") touchSensitivity Quaternion qt Quaternion.Euler(localRotation.y, localRotation.x, 0) xFormParent.rotation Quaternion.Lerp(xFormParent.rotation, qt, Time.deltaTime orbitDampening) Is there a good method to achieve this type of 360 camera? I'd like dragging from right to left to always move the camera left and dragging left to right to always move the camera right no matter how the camera is oriented.


Unity Hub 2.3.0 Buggy Setup? I recently downloaded the new Unity Hub 2.3.0 setup and since I hadn't used (or downloaded Unity Core) using the previous version of the Hub, I simply deleted the folder containing Unity Hub instead of uninstalling it like any normal person would. Now, every time I open the Unity Hub Setup and try and install it, it always shows the same "Installation Aborted, could not install successfully," error. I can't even uninstall the previous version from Windows Settings! I've tried changing the destination folder, but still doesn't work. Any help is appreciated! P.S. This error occurs when installing UnityHub, not the Unity Core Platform! I've also looked at all other similar posts. Thanks.


first person character controller error I have opened new scene, deleted camera and imported first person character controller from Standard assets. I placed plane on scene and put first person character controller on plane. I got this error Assets Standard Assets Characters FirstPersonCharacter Scripts RigidbodyFirstPersonController.cs(3,27) error CS0234 The type or namespace name CrossPlatformInput' does not exist in the namespaceUnityStandardAssets'. Are you missing an assembly reference? How to fix it?


How do I create a toggle button in Unity Inspector? I want to create a tool similar to Unity's Terrain tool, which has some nice toggle buttons in the inspector How can I achieve similar design to this? I know how to create normal buttons and other UI components in the inspector, but I can not find enough information to make the buttons toggle. So far I have used normal toggles that produce a checkbox var tmp EditorGUILayout.Toggle( SetAmountFieldContent, setValue ) if ( tmp ! setValue ) setValue tmp if ( setValue ) smoothValue false tmp EditorGUILayout.Toggle( SmoothValueFieldContent, smoothValue ) if ( tmp ! smoothValue ) smoothValue tmp if ( smoothValue ) setValue false Setting the toggle GUIStyle to "Button" does not produce the wanted result. The text or image content goes on left of the button instead of inside. var tmp EditorGUILayout.Toggle( SetAmountFieldContent, setValue, "Button" ) Also none of the options found in GUISkin does not seem to help.


How to find the angle of an arc for reflection I am using the following code to calculate points for a circle arc drawn with a Line Renderer. for (int i 0 i lt pts i ) float x radius Mathf.Cos(ang Mathf.Deg2Rad) float y radius Mathf.Sin(ang Mathf.Deg2Rad) arcLine.positionCount i 1 arcLine.SetPosition(i, new Vector2(x, y)) ang (float)totalAngle pts How can I change the angle ang to create a reflected arc along the line P1P2 as in the image below? Please note that totalAngle represents the portion of the circle that is to be drawn between 0 and 360.


Weird behavior using TextMeshPro I have a very simple scene setup. What I want to do is to create a button prefab composed of a sprite and a TextMeshPro object. When I group the sprite and the text under a GameObject, the pivot of the compound object appears very far from the center of the GameObject (please see the attachment). I can't move the pivot of the text to the center no matter what I do. Is this an expected behavior?


Projecting grid textures to select parts of the terrain (Unity) So I'm trying to be smart and not use 500 some tile prefabs to make a grid, and so far the back end portion has gone swimmingly. I initially used a dedicated mesh to represent the grid, but as I'm now opting for 3D terrain (and not tilemapping), I figured that was a lot of unnecessary vertices especially if I want to have the grid conform to the terrain. My shader inexperience, on the other hand, is causing me to stop and overthink this. Using FE as inspiration, I'm thinking about projecting the transparent grid texture onto a base terrain layer. If I wanted parts of the terrain to not be covered by the grid (such as the water area in the picture), would I simply use the world coordinates to tell the shader don't do anything there? The most confusing part for me, however, is how to go about highlighting tiles. I want movement and attack tiles to also be 'painted' onto the terrain in specific colors, but obviously they only affect an even smaller portion than the terrain than the grid. Would I simply be using the same shader to grab world coordinates once again and more or less start stop overlaying the movement attack texture over the grid terrain? And if I'm really being efficient, those textures belong to the same png and I just use UV's to switch between them like a sprite sheet? Is this even a good practice for shaders in the first place? Redrawing and adding textures to only parts of a material? Should I be redrawing and updating the whole texture instead? I guess I get thrown off because I'm only familiar with a 1 1 mesh to material design, so the so the thought of a single mesh but multiple textures on discrete parts that may or may not overlap makes somewhat sense on paper but implementation in Unity is just above me atm. Thanks!