Testing Live Ads Before Publishing Admob I am testing ads with the test device method and test ads are showing perfectly but when I try to load live ads they won't load. I have implemented the OnAdFailedToLoad which tells me that ads are not loading, this only happens when I try to load live ad but in the test ad everything works fine. Does this happens all the time? we can't see live ads without publishing the game first? or there are no ads available at the moment if so when do the get available or they even get available for new users. How can I make sure that I will get live ads after publishing the on Google Play Store. I don't know I am just confuse about this thing, I am using Unity 3D and building for Android. I have searched on internet but everybody says that ads might not available at the moment I am just curious why are ads not available its been two days and I haven't seen any ad when are the ads going to be available. Thanks for reading this.


What does 'vertex splitting' mean? In the documentation of MeshUtility.SetPerTriangleUV2 it is said the following Will insert per triangle uv2 in mesh and handle vertex splitting etc. What do they mean by 'vertex splitting' ?


Detect Collisions While Dragging 3D Game Object Hello i am making a game in which i have to drag a sphere on x axis and z axis on a plane with my mouse and i have created walls from cubes so that my sphere not go anywhere else in the game but while dragging my sphere is not detecting collisions with the wall i also added rigidbody but nothing is working ths is my code thanks using UnityEngine using System.Collections public class Ball MonoBehaviour Rigidbody r private void Start() r GetComponent lt Rigidbody gt () void OnMouseDrag() float distance to screen Camera.main.WorldToScreenPoint(gameObject.transform.position).z Vector3 pos move Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance to screen)) transform.position new Vector3(pos move.x, transform.position.y, pos move.z)


Unity runs custom AssetPostProcessor every time on save I've written a AssetPostProcessor script that make some changes to prefabs and materials on import in some specific folders. I'm using this method to do that private static void OnPostprocessAllAssets(string importedAssets, string deletedAssets, string movedAssets, string movedFromPath) if the importedAsset is a prefab GameObject obj (GameObject)AssetDatabase.LoadAssetAtPath(objName, typeof(GameObject)) if (obj) if (AssetDatabase.GetAssetPath(obj).Contains("Assets Tiled2Unity Prefabs")) Here's some code that changes the asset For some reason, every time I save this AssetPostProcessor is run which is something I don't want because this is lost time for something that isn't needed. What can I do to stop this?


Dynamic model scaling Imagine a (3D) game like Railroad Tycoon 3. Player selects a rail track, clicks LMB and drags the mouse to the end position. During this drag, the rail track model scales and adopts to the landscape, so user sees the resulting track in dynamic. The question how this can be done? A brief idea links sketches will be enough. I just don't know how to start (I'm novice game developer). If it is matter, I use Unity as a game engine. Thanks in advance.


Create an atlas texture in photoshop to use in unity To create a button in NGUI looks like we need to create something called Atlas that is a material that contains a lot of little images called Sprites. I created a set of 40 sprites (for 20 buttons needed in game, normal state and clicked state) in photoshop in a 2048x2048 image file. When i tried to use NGUI atlas maker i realized that atlas maker requires each sprite in a separate file and wants to merge them in the atlas itself! Well, i already have them in one file, should i slice all these buttons and save them in 40 other separate files and let the atlas maker merge them again for me? (Sounds very stupid!) Isn't there any way to give the merged 2048x2048 file to atlas maker (or any other equivalent plugin software) and then tell the software "Hey! I have 40 sprites in this image, let me tell you where they are! The first one is in (3,3) with size of (150px, 150px), The second one is..."? UPDATE I found a part of solution, unity could identify my 40 sprites in texture using sprite editor tool, but NGUI cannot still find them. I created a material using "Unlit Transparent Colored" shader and referencing the atlas to it, then i created a new empty game object, added UI Atlas component to it and referenced the material in it, but it says there are no sprites. If i make a prefab out of this game object then NGUI can use it as an atlas and my problem will be solved


How do I run a headless Unity server in a Windows Docker (without GPU)? I am trying to run a headless Unity server on a Windows Docker. On Linux, there is Xvfb, but I don't know how I could get similar results on Windows. How would I do that?


Coroutine wrong Behavior when scene is loaded. Ok so I have this coroutine IEnumerator ShowCharTraits() while(!hasPlayerChosen) yield return null traitPanel.SetActive(true) hasPlayerChosen false traitPanel.SetActive(false) Debug.Log("Got called! job done") It's being called like this from the awake method in my GameManager players GameObject.FindGameObjectsWithTag("Player") foreach (GameObject g in players) ui Controller.StartShowCharTraits() g.GetComponent lt PlayerToken gt ().isTurn false StartShowCharTraits() is a simple method that does this public void StartShowCharTraits() StartCoroutine("ShowCharTraits") Now, I have checked the tags, no null reference exception, actually no errors or warnings are being thrown. If i load the scene in the editor and then play it everything works fine. traitPanel.SetActive(true) get called and my panel shows up. However when I load my scene from another scene using SceneManager.LoadScene(1) the above mentioned line is never reached. Any ideas why this is happening ?


In Unity, how do I make text annotations appear when I mouse over GameObjects in playmode? How do I make text appear when I mouse over GameObjects in game? What is the Unity jargon for this? I'm assuming it's 'annotations'.


How to get error line when debugging APK from Logcat I made android game by Unity and built APK. When I got error from this game, I can see the error message 07 06 00 35 38.905 I Unity(31609) (Filename . Runtime Export Debug.bindings.h Line 43) 07 06 00 35 38.906 E Unity(31609) NullReferenceException Object reference not set to an instance of an object 07 06 00 35 38.906 E Unity(31609) at GameManager.OnRealTimeMessageReceived (Boolean isReliable, System.String senderId, System.Byte data) 0x00000 in lt filename unknown gt 0 07 06 00 35 38.906 E Unity(31609) at GooglePlayGames.Native.NativeRealtimeMultiplayerClient OnGameThreadForwardingListener lt RealTimeMessageReceived gt c AnonStorey4. lt gt m 0 () 0x00000 in lt filename unknown gt 0 07 06 00 35 38.906 E Unity(31609) at GooglePlayGames.OurUtils.PlayGamesHelperObject.Update () 0x00000 in lt filename unknown gt 0 07 06 00 35 38.906 E Unity(31609) 07 06 00 35 38.906 E Unity(31609) (Filename Line 1) However file name and error line is wrong, so I can't check where exactly error came from. I checked my logic almost 2 hours also the object references too, but there is no logic to access undefined object code. It could be, but I can't see where it is. I must run this app because it uses Google Play Games Service, so it requires completed built APK without developlemt option checked. Using Application.RegisterLogCallback not much help, it has exactly same result. How do I get exact error line in this case?


Assigning a colour to imorted obj. files that are being used as default material I am having a problem with assigning a colour to the different meshes that I have on one object. The technique that I have used is the first approach on this site. Is it possible to export a simulation (animation) from Blender to Unity? So what I would like to do is the following. I have about 107 meshes that are different frames from my shape key animation of my blender model. What I would like to have is that the first mesh will be bright green and up to the 40th mesh the colour turns to be white greyish... the best would be if I could assign every mesh by hand a colour, however they are all default materials. And if I assign the object a colour, the whole "animation" is going to be in that colour


Detect clusters of tokens on an x y grid Ok, so I have a two dimensional grid working on integer x and y coordinates. Each of this coordinates can have one and only one token on it. The tokens have the capability of check and return an adjacent token given a direction in which to search (they'll return null in case nothing is there) I now need an algorithm to check the grid for clusters of 3 or more adjacent tokens and add each cluster to a dedicated variable (meaning than, instead of just stopping after return one cluster, it needs to check for all clusters on the board) I've been thinking for a while but came out with nothing, any help?


Concept design pattern for industry simulation required I am making a mobile game simulating industry. A brief high level description is below. A hub could be thought of as a base city, within which there are rooms buildings which determine what is produced and consumed. Rooms buildings need people to work them. People have their own produced and consumed resources that need to come from rooms buildings. The buildings like machines in a production line have paths of commodity flow defined. How to implement people with their own needs like thirst, sleep and illness while coordinating the buildings is causing me trouble. I know many games have this same premise but can t turn up enough info on their workings to help me. The real challenge is that I do not want to run the game where time passes relatively slowly and each person can move around and make decisions constantly. I want to be able to change the speed of the game, likely from running a day every 30 seconds to a month every two minutes. So was focusing more on when changes to the system were occurring. The number of hubs is likely to reach 80 each with 20 rooms and say 30 people to give an idea of scale. Do you have any example games or coding approaches that could help light my way? Each concept I think through falls over. Your help is very much appreciated and thanks for reading! If I have not included enough details please let me know, it is my first post so unsure how far to go into it.


How to detect RayHit on part of model and not entire model I'm building a low poly role playing Hack and Slash game. When I click it renders a sprite amp character moves to that location(with RayCast). But in this case. I don't want the click to occur on side of the bridge. Clicks should only occur in green coloured part amp not in the red part. How should I fix this problem?


Models keep turning white Unity 5.3.5p1 I'm using Unit 5.3.5p1 but for some reason my models randomly turn white after I build an exe to run outside the editor. The textures work perfectly fine within the editor, but as soon as I build and run outside they sometimes show with appropriate colour, but many times do not and end up blank white. Does anyone know what might be causing this in general? I've downloaded the latest unity shaders and replaced all current shaders. Currently I'm using the Standard shader only, and it is 100 unmodified.


How to calculate a movement Vector3 to kill unnecessary momentum and start moving in the right direction? Imagine a rocket is accelerating in a straight line toward PointA, picking up momentum every frame, then suddenly decides it wants to go toward PointB instead. It can't just turn straight toward PointB and start accelerating, because the new acceleration plus the pre existing momentum will carry it wildly off course, and not straight toward PointB. It could turn exactly 180 around to aim directly away from PointA and thrust until it comes to a stop, then turn toward PointB and start accelerating from scratch. But that's very inefficient, especially if the two points are in generally similar directions. It would be more efficient to turn and start accelerating in some specific direction that will bleed off the unnecessary momentum but keep any useful momentum, course correcting so that it is now moving toward PointB. I'm trying to figure out how to calculate that quot specific direction quot that the rocket needs to start accelerating toward, in order to efficiently reach PointB. I have the rocket's position, the Vector3 of its inertia, and the Vector3 locations of PointA and PointB, but I'm not experienced enough in Vector Math to totally understand what's needed. Especially since we're talking about acceleration (not just speed), so the angle will no doubt need to be recalculated each frame as the changing momentum leads to a changing angle toward PointB, etc. Can anyone help me out?


Top Down Octree Generation of Procedural Terrain I'm trying to implement a voxel based terrain generation system in Unity3d (C ). I have successfully implemented a uniform 3d grid system, and have extracted the isosurface out using Marching Cubes and Surface Nets algorithms. I quickly bumped up against the inherent issues in representing all space with a 3d grid. Much of this space was either above or below the surface, and I turned to space partitioning with octrees, as it didn't seem too difficult. One of the great things about octrees is that octree nodes that that don't have edges intersected by the surface don't need to be split again. I researched, and found a couple resources to construct my code. One is Volume GFX, and another is the original Dual Contouring paper by Ju et al. My edge checking is done by the Marching Cube's checking from Paul Bourke's code. If the "cubeindex" is either 0 or 255, then no edge is intersected, and the octree node does not need to be split. My Octree generation code works for something like a quarter sphere, where the surface features are extremely normal As seen in the picture, only octree nodes containing the surface are subdivided. Working great. Now, however, when we move to something more complex, like Unity3d's PerlinNoise function GASP! What's that hole doing in the mesh at the lower right corner? Upon closer inspection, we see the octree didn't subdivide properly (red lines highlighting the offending node's dimensions) This turns out to be the same issue Jules Bloomenthal highlights in her paper on polygonization, page 10, Figure 10. Traditional methods at generating top down octrees ("Adaptive Subdivision"), are sensitive to fine surface features relative to the size of the octree node. The gist X X lt Node X X X's tested values, all outside of the surface! lt surface The surface breaks the surface, but comes back down before it goes over a vertex. Because we calculate edge intersections by looking at the signs at the two vertices, this does not flag the edge as crossed. Is there any method to determine if these anomalies exist? Preferably, the solution would work for more than just the Unity3d noise function, but for any 3d noise function (for cliffs overhangs floating islands, etc). UPDATE Thanks to Jason's awesome answer, I was able to answer my own questions I asked (in the comments under his answer). The issue I had was that I didn't understand how I could create a bounding function for trigonometric functions (sine,cosine,etc) due to their periodic nature. For these guys, the periodicity is the key to bounds functions. We know that sin cos reach their extrema values at a set interval, specifically every 2. So, if the interval we are checking contains any multiple (cos) or half multiple (sin) than 1 1 is the certain extrema. If it doesnt contain a multiple (i.e. the interval 0.1,0.2 ), then the range is simply the values of the function evaluated at its endpoints. UPDATE 2 If the above doesn't make sense, check Jason's answer to my comments.


Change alpha value of the Standard Shader I want to edit the Standard shader provided by Unity in order to change the alpha value of a fragment (pixel) according to given parameters I pass to the shader. For now, thanks to this link, I have been able to Retrieve the standard shader, Retrieve a custom Core.cginc I included in the DEFERRED pass of the custom shader, Create a custom Editor script to handle the Shader and my custom parameters, Selecte Fade as the rendering mode of the shader to handle transparency, using the custom editor script, Create a custom file replacing UnityStandardInput.cginc and changed the references in the Core.cginc file. But now, I can't seem to figure where to change the alpha value of the fragment. I've tried a ton of possibilities in the Core.cginc file. Changing the color and the map of the Albedo works, but I can't find where the final alpha value is set. I've browsed the files in the CGIncludes folder in the builtin shaders of Unity. UnityStandardCore.cginc Already tried many possibilities (including the returned value of Alpha declared in UnityStandardInput.cginc CustomInput.cginc Alpha function, no effect Since the files are huge, I don't feel it will be useful to copy paste them here. Thanks for your help in advance.


Colliders stop working when they move I'm trying to make a game where you play basketball as a catapult. Obviously an idea like this leans heavily on the unity physics engine. The cup of the catapult has a bucket on it to keep the ball from falling out. When you hit space, the arm of the catapult spins, which should throw the ball out of the bucket of the catapult. Instead, the ball passes through the cup of the catapult(when it isn't spinning, it acts normally and rolls around the bucket) and then it doesn't fall whatsoever, eve though has gravity is enabled. Here are my physics settings The ball The cup(and also a cup with flipped normals) The Rim of the bucket Here's my ball throwing code public class BallThrower MonoBehaviour private Vector3 axis Start is called before the first frame update void Start() axis transform.position Update is called once per frame void Update() if (Input.GetKey(KeyCode.Space)) if (transform.rotation.z gt 95.4) transform.Rotate(0f, 0f, 5f, Space.Self) What's missing here? Should I make the cup a rigidbody? Let me know if you need more info, Thanks!


Creating a list of buttons dynamically in code I have a list of contacts. I need to create a scrollable list of buttons that are created dynamically so I can add each contact name as the button text. How would I do this all in code? My biggest concern is making sure the sizes stay consistent. I haven't had to do that in code before. EDIT And here is the code to add the buttons to this for (int i 0 i lt count i ) if (i gt 0) crt.sizeDelta new Vector2(crt.sizeDelta.x, crt.sizeDelta.y initHeight) GameObject contactButton Instantiate(Resources.Load("Contact Button")) as GameObject contactButton.transform.parent contactsList.transform contactButton.GetComponentInChildren lt Text gt ().text names i


No shadow on custom model I have custom low poly model ,the thing is it is not receiving shadows. Unity's default plane do receive the shadow but not my low poly plane. Here is image that demonstrate more,


Filling of a multidimensional array with string I'm trying to fill a dropdown with a lis,t if some input is correct. now when trying to create the list from a text file (to save the program) i should split the line on a comma so i have 3 settings for one asset For ex asset1,colour,used,broken. the list should show the asset if the item is broken (0 is not broken, 1 is broken). public string ,,, UsedAssetList string lines System.IO.File.ReadAllLines( "" Application.persistentDataPath " assetlist.txt") cmbAssetNumber.ClearOptions() for (int i 0 i lt lines.GetLength(0) i ) UsedAssetList lines i .Split(',') if (UsedAssetList i,0,0,1 "1") list new Dropdown.OptionData(UsedAssetList i,0,0,0 ) cmbAssetNumber.GetComponent lt Dropdown gt ().options.Add(list) The lines i .Split(',')gives me the error Error CS0029 Cannot implicitly convert type 'string ' to 'string , , , ' I think everything is on point, except the filling of my list. any idea on how i can get this right? EDIT I was thinking the list should look like this "asset1","Gold","1","0" , "asset2","Green","0","1" , ... EDIT While the text file looks like asset1,Gold,1,0 asset2,Green,0,1 ...


Smooth Lighting Falloff So, I'm having some issues with lighting in my Unity game. I had implemented torches, which seem to be working fine, but I have a creature (gelatinous cube) that I've put spot lights facing to give it a "glow". The reflected and refracted light ends up having two issues the light abruptly ends at the edge of floor tiles, and depending on the position, the light sometimes goes from it's blue color to a reddish color. I have a short (11 second) video here http www.labyrintheer.com wp content uploads 2016 11 Nov 17 2016 21 07 57.mp4 so that you can see what I'm talking about. I've tried changing global lighting settings and playing with the settings on the spot lights, but nothing seems to resolve the issue. Still images for anyone hesitant to click the video link Hard falloff Reddish color Using a single point light inside the cube, instead You can see it on the wall in the upper right and the floor at the top a bit. The upload seems to have lowered the quality a bit, but you can still see it. The single light makes it a little bit better, but there's still complete falloff.


What are the steps to instantiate a button in Unity? Given a Canvas test canvas containing a Button test button and an empty GameObject that manages instantiation and scripts and the like called test manager, what are the steps to instantiate this button through code as opposed to having it already there? I've tried making the button a prefab and instantiating it as I would any other object but that didn't work. I tried making the canvas a prefab and then trying the button but nothing. I've searched around for quite some time and there's mention of RectTransform and SetParent but steps or specific details would clear up my confusion


Raycast Masks not working Unity3D I'm having a problem with filters masks when raycasting. I've created a LayerMask and then in the inspector selected the layer I want to ignore when Raycasting. however then I print out the name of the object hit by the raycast I am still getting hits on objects on the layer masked out, as well as on other layers. public LayerMask rayMask RaycastHit hit Ray ray Camera.main.ScreenPointToRay(Input.mousePosition) if (Physics.Raycast (ray, out hit,rayMask)) Debug.Log (hit.collider.name) I have paused the Game and checked that the object I'm getting a hit on is indeed on the layer in the mask.


How To Rotate A Vector around A Pivot Point In Unity, I'm trying to figure out how to rotate an object around a pivot point. I found a snippet of code over on the regular stack overflow, but it wasn't working even close to correctly. I have edited it a bit and now its starting to work a little better, but its still pretty off from what I need. It rotates around the object, but about half way through it jumps to another position. The one half actually rotates with the pivot point, albeit a little bit offset from where it should be, and if you keep rotating it the offset becomes greater and greater. Then the other half is just completely off, still not as bad as the original code though. Sorry I'm having trouble explaining, here is a GIF to make it easier. public Vector3 RotTesta(Vector3 point, Vector3 pivot, Quaternion pointRotation, Quaternion pivotRotation) To rotate an object around an arbitrary point, translate first (the arbitrary offset) then rotate as opposed to rotate scale translate Vector3 offset point pivot Vector3 rotationOffset pivotRotation.eulerAngles pointRotation.eulerAngles offset Quaternion.Euler(rotationOffset) offset return offset pivot calculate rotated point This just handles its position, after you call this you would just do transform.rotation pivotRotation. If someone could please help me out with this I would be very grateful.


How to Change position rotation of a parent while keeping X and Z Rotation Sooo this question is a problem , a evolution by another solution of this problem here How can I change the parents rotation so the childs rotation is looking at a specific direction Basically We have a "Eye" (HTC Vive). We have a "Parent" which is the Parent of "Eye". We can not change the position or rotation of the Eye in code. We can only change the position and rotation of the Parent. 1.We want to modify the Parent Position so that Eye to goes to a certain "Target 1" position. 2.We want to modify the Parent Y Rotation so that the Eye looks at a certain "Target 2" position. 3.While doing this we dont want to modify the Parent X or Z , because this would lead to a Rotated game experience. The Parent Position changes so the Eye gets to "Target 1" position. The Parent Position changes so Y Rotation should look at Target 2 position The Parent X Z Rotation should not modify the Eye X Z


How to calculate Camera correct position and distance to Frame all my Scene? Consider I have N dynamic points on my Scene, I would like to "frame" all them, with my Camera. How can i calculate (at runtime) Vector3 Position to correctly frame all my scene ? This is my idea Calculate Avarage for all my points Move my Camera "up" Zoom out to correctly "frame" all my points (i don't know how to calculate ) Use Unity LookAt(myAvaragePoint) I think i've to use some trigonometryc function to calculate the Y Camera position (to zoom in, zoom out), but i don't know which! Thanks


Discrete line inside a 3D matrix First of all a little premise I'm following this tutorial on YouTube for procedural 2d cave generation in unity using cellular automata and I'm extending it in order to make caves in all three dimensions. With this approach, caves are based on a 3d matrix where if a cell value is 1 it is a wall and if 0 it is an empty space. The "rooms" created, after being logically connected, need to be "physically" connected by making a path of zeros in the 3d matrix and the tutorial explains how to do this in 2d. Can you, please, suggest me the approach on how to draw a discrete line (of zeros in this case), in a 3d matrix, that goes from point A to point B? I'll attach a screen of a map example where rooms are drawn with cubes and red lines are the logical connections.


Unity Rigidbody2d jittering movement in the y axis As said, rigidbody moves fine, even smoothly in the x axis. Problem comes in on the y axis. Whenever the character goes up or down, it noticeably shakes. Additional Info Unity 5.6 Using linear interpolation Mass is 5 Linear Drag is 20 Gravity is 0 Angular Drag is 0 Locked rotation on the z axis Dynamic Rigidbody No parent Object, not even a child using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMovement MonoBehaviour Rigidbody2D rbody Animator anim public float speed 0 SpriteRenderer sr Vector2 movementVector void Start () rbody GetComponent lt Rigidbody2D gt () anim GetComponent lt Animator gt () sr GetComponent lt SpriteRenderer gt () void Update() sr.sortingOrder ((int)Camera.main.WorldToScreenPoint (sr.bounds.min).y) 1 movementVector new Vector2 ((Input.GetAxisRaw("Horizontal")) 3, Input.GetAxisRaw("Vertical")) if (movementVector ! Vector2.zero) anim.SetBool ("isWalking", true) anim.SetFloat ("inputX", movementVector.x) anim.SetFloat ("inputY", movementVector.y) else anim.SetBool ("isWalking", false) void FixedUpdate() rbody.AddForce (movementVector speed) I also noticed that changing the mass and linear drag affected the movement speed on the y axis but not on the x axis, and movement on the y axis is noticeably faster than on the x axis, which is why I multiplied the horizontal input by 3.


Random Sobol 3D Cell in Unity There is a blueprint in UE4 for making Sobol random 3D cell. It places random objects inside cell structure. How to make this in Unity? For example, if I make a sphere prefab I would need to generate Sobol distribution in some volume. EDIT Seyed Morteza Kamali have made a script


Overriding CoRoutine doesn't execute base code I want to have a CoRoutine declared as virtual in parent class and then overridden in child classes. protected override IEnumerator f(Vector3 to) ... yield return base.f(to) ... What happens (or doesn't happen) is that the base code doesn't get executed. Debuggin it I step into the base.f(to) and the cursor just stand on function name. If I press step next control returns to the child. I really have no clue how to handle this situation. Any clue?


Starting Couroutine in newly activated gameObject I'm working on a UI system that animates an element's properties using coroutines. Every element that should be animated has a component called AnimatedUIElement which provides the function Enter(). The function Enter() is basically starting coroutines depending on the chosen animation settings, but only after calling Enable(), which sets the gameObject active with gameObject.SetActive(true) , updates its component references and makes the element interactable. AnimatedUIElement also defines an Exit() function acting similar, but disabling the element after the animation. public class AnimatedUIElement MonoBehaviour private CanvasGroup canvasGroup ... public void Enter() ... TriggerEntry() private void TriggerEntry() PlayChildrenEntry() Calls Enter() on all animated Children Enable() StartCoroutine(SomeAnimation(...)) private void Enable() gameObject.SetActive(true) Init() canvasGroup.interactable true canvasGroup.blocksRaycasts true private void Init() canvasGroup GetComponent lt CanvasGroup gt () ... private IEnumerator SomeAnimation(...) ... public void Exit() Similar to Enter, but disabling the element Now I want to open the options panel by clicking a button in the game's UI. The panel is inactive (unticked) in the beginning, while the AnimatedUIElement component is enabled. UI Hierarchy Options Button calls Enter() on Options Panel. The desired setup in the Button Component calling OptionsPanel.Enter() and MainPanel.Exit() But clicking the button throws the following exception Coroutine couldn't be started because the the game object 'Main Menu Button' is inactive! UnityEngine.MonoBehaviour StartCoroutine(IEnumerator) AnimatedUIElement AnimatePosition(Vector2, Vector2, Single, AnimationCurve) (at Assets Animated UI Elements AnimatedUIElement.cs 265) AnimatedUIElement TriggerEntry() (at Assets Animated UI Elements AnimatedUIElement.cs 93) AnimatedUIElement Enter() (at Assets Animated UI Elements AnimatedUIElement.cs 73) AnimatedUIElement PlayChildrenEntry(Transform) (at Assets Animated UI Elements AnimatedUIElement.cs 219) AnimatedUIElement TriggerEntry() (at Assets Animated UI Elements AnimatedUIElement.cs 79) AnimatedUIElement Enter() (at Assets Animated UI Elements AnimatedUIElement.cs 73) UnityEngine.EventSystems.EventSystem Update() In this stack trace you can see that the Options Panel did not start coroutines as no animation was defined in its component, but called Enter() on its children, which are animated. Using debug logs I found out that, while Init() is called immediately after Enter(), Awake() is called after the coroutines (which happen later in the program flow) throw errors. This makes it seem like the object is not available instantly after calling setActive(true). Is there an explanation and possibly a fix for this behavior?


How can I rotate a camera on the X and lookat target and once looking at the target to stop slowly the rotation? This is a screenshot showing the camera position. I want it to rotate slowly smooth to the left and once looking at the soldier to stop rotating. using System.Collections using System.Collections.Generic using UnityEngine public class SoldierNaviFight MonoBehaviour public Camera fightCam public Transform target public float speed 2f Use this for initialization void Start () Update is called once per frame void Update () The script is attached to a empty gameobject. What I want to do is once the camera stopped rotating and looking at the soldier to make the soldier start moving to the right and camera should follow the soldier rotating and keep follow the soldier moving. The main idea is to create a cut scene. The camera is position at this point just to display the cut scene. To make the first rotation to the target I tried this using System.Collections using System.Collections.Generic using UnityEngine public class SoldierNaviFight MonoBehaviour public Camera fightCam public Transform target public float speed 2f Quaternion targetRotation Use this for initialization void Start () targetRotation target.rotation Update is called once per frame void Update () Quaternion.RotateTowards(transform.rotation, targetRotation, Time.deltaTime speed) But the camera is not rotating at all. This is screenshot of the Hierarchy and Inspector The script is attached to GameObject SoldierNaviFight The camera that I want to move is the child of SoldierNaviFight SoldierNaviFightCamera UPDATE This will rotate the camera but it's rotating it to the right instead to the left to the soldier. Not sure why using System.Collections using System.Collections.Generic using UnityEngine public class SoldierNaviFight MonoBehaviour public Camera fightCam public Transform target public float speed 2f Quaternion targetRotation Use this for initialization void Start () targetRotation target.rotation Update is called once per frame void Update () fightCam.transform.rotation Quaternion.RotateTowards(fightCam.transform.rotation, targetRotation, Time.deltaTime speed)


How can I transform a world space point to a camera's screen coordinate? I'm trying to transform a point in fragment shader from world space to screen coordinate of a second camera. Not the main one. I think I know how to achieve that to the main camera, but I'm struggling to find an easy way to transform a point in world space to screen coordinate of camera2.


Making certain GameObjects visible for a camera I have 2 cameras in my 2D game. One displays gameobjects normally, and the other camera draws some of these gameobjects reflected (scale.y 1). The reflected camera would draw only objects in the "Water" layer, and I would change the layer of the GameObjects I want to reflect on the precull and postrender functions. This way I can decide which GameObjects would be reflected, changing the layer on the fly at runtime, which is a requirement. Precull Change the desired GameObjects layer to "water", and apply scale.y 1 OnPostRender Change the Gameobjects layer to their original value, and apply scale 1 This was working correctly when my objects were simple, but now my objects are more complex, and I can't rely on changing the layer of the gameobjectson the fly, as I can't tell what their original layer was for each part of the object, in order to revert the changes applied during the precull. Is there anyway to tell a camera which objects should it render besides using the culling mask?


Rotate object always at same speed on screen, no matter camera distance? I am rotating a globe like XCOM's hologlobe, I rotate it using Quaternion.RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta). I found a good value for maxDegreesDelta, in my case it is 5.0f. There is a limit on how close or far the camera can be, let's assume clos is 1.0f and far is 2.0f. I want to be able to zoom into the globe, but obviously when I do, it rotates a bit too fast then. When zoomed out, rotation speed is satisfying When zoomed in, rotation is too fast, making it more difficult to manipulate And the problem is even more evident as game view size gets bigger, i.e. fullscreen. Using Mathf.Lerp and Mathf.InverseLerp, I've tried to make maxDegreesDelta and mouse delta proportional to the distance the camera is but it's hardly convincing. Note I rotate the globe, not the camera. Question How can I ensure object rotates at same speed on screen, no matter how close or far camera is ? Code (assumes there is a sphere of radius 0.5 at Vector3.zero and camera is positioned at Vector3.back) using UnityEngine using UnityEngine.InputSystem namespace Test2 public class GeoScapeController MonoBehaviour region Public public Transform TargetObject public Camera TargetCamera Range(0.01f, 1.0f) public float Sensitivity public bool Smooth public float ZoomDistanceMin public float ZoomDistanceMax endregion region Private SerializeField HideInInspector private Quaternion TargetRotation SerializeField HideInInspector private int ZoomLevel SerializeField HideInInspector private int ZoomLevels SerializeField HideInInspector private Vector3 ZoomVector SerializeField HideInInspector private Vector3 ZoomVelocity private void Reset() Sensitivity 0.05f Smooth true ZoomDistanceMin 0.625F ZoomDistanceMax 1.25F ZoomLevels 10 private void Start() TargetRotation Quaternion.LookRotation(TargetObject.forward, TargetObject.up) ZoomVector TargetCamera.transform.position private void Update() var mouse Mouse.current var delta mouse.delta.ReadValue() var scale new Vector4( 1.0f, 1.0f, 1.0f) var x mouse.leftButton.isPressed ? delta.y scale.y Sensitivity 0.0f var y mouse.leftButton.isPressed ? delta.x scale.x Sensitivity 0.0f var z mouse.middleButton.isPressed ? delta.x scale.z Sensitivity 0.0f var r Quaternion.AngleAxis(x, Vector3.right) Quaternion.AngleAxis(y, Vector3.up) Quaternion.AngleAxis(z, Vector3.forward) if (Smooth) hopefully, quaternion limits won't be crossed ! TargetRotation Quaternion.RotateTowards(TargetRotation, r TargetRotation, 2.5f) TargetObject.rotation Quaternion.Slerp(TargetObject.rotation, TargetRotation, Time.deltaTime 5.0f) else TargetObject.rotation TargetRotation r TargetRotation var wheel (int) mouse.scroll.ReadValue().y 120 if (wheel ! 0) ZoomLevel Mathf.Clamp(ZoomLevel wheel, 0, ZoomLevels) var lerp1 Mathf.InverseLerp(ZoomLevels, 0, ZoomLevel) var lerp2 Mathf.Lerp(ZoomDistanceMin, ZoomDistanceMax, lerp1) ZoomVector Vector3.back lerp2 TargetCamera.transform.position Smooth ? Vector3.SmoothDamp(TargetCamera.transform.position, ZoomVector, ref ZoomVelocity, 0.3f) ZoomVector endregion


Unity 5 Input Field How to confirm password entry with ENTER only and not a click loss of focus I have an input field password box, currently the password is 'submitted' either by clicking Enter or by clicking elsewhere on the screen. This seems to be the designed way, as it states this in the documentation (https docs.unity3d.com Manual script InputField.html) "A UnityEvent that is invoked when the user finishes editing the text content either by submitting or by clicking somewhere that removes the focus from the Input Field." As I have other buttons on the same screen that users can click on, I would like it so mouse clicks are not counted as an invoke. Is this possible? Many thanks in advance


Environment collision in a pseudo 3d 2d space The game is a 2D brawler with depth movement in the vein of Golden Axe, Final Fight, Castle Crashers etc. Characters and environment are all 2d sprites as well. I've had no real issue setting up collision between characters to take the depth into account either. However, it's just not a proper brawler without higher ground to jump to and pits to throw the enemy into, and that is where I run into a bit of an issue with how best to implement it. I considered making the collision boxes for the level in the 3D space and having the sprites just translate the z movement of their game object into y movement of the visual component, but I don't particularly like that approach because it feels difficult to work with for doing the level design of matching 3D colliders to a drawn backdrop and placing objects in there. Any suggestions for a design that is the 2D first, so to speak? Ideally being able to "paint" height levels and pits in the 2D design wise. If it matters, I'm working in unity with a primarily 2d space (though involving the third dimension here will be necessary), but I think the base design problem would be fairly engine language agnostic.


Is this Code saving performance ? It is kind of a Occlusion Culling I wanted to do Occlusion Culling on my Scene but I just get a bunch of Errors like "Couldn't load geometry..." etc. I tried to do like another way but the same thing, the Occlusion Culling just disables the Objects the Camera dont see. I tried it with OnTriggerEnter and Exit. I have 2 Areas one is on the left and one on the right, when the Player is walking in the first Area the Box Collider checks it and disables the Objects in Area2 but when Player is walking into Area2, Objects in Area1 disables and Different. Got the Script on both Areas that it disables a list of arrays as GameObjects. My Question is, does this save performance ? public GameObject deactivatingModels bool playerEntered false void OnTriggerEnter (Collider other) foreach(GameObject envis in deactivatingModels) if(other.gameObject.tag "OcclusionCuller") envis.SetActive(false) Debug.Log ("Player has entered Occuling Zone") void OnTriggerExit(Collider other) foreach(GameObject envis in deactivatingModels) if(other.gameObject.tag "OcclusionCuller") envis.SetActive(true) Debug.Log ("Player has left Occuling Zone")


Unity build does not launch and leaves no logs errors I have released my first title Audio Infection ( https store.steampowered.com app 911580 Audio Infection ) for a bit over a year ago. Recently 1 user has so far encountered an issue where the game does not launch. He is the only user that encounters this problem. He has this issue on both Win 7 and Win 10. His system specs are fine and his drivers are up to date. The game does not leave a log file, rather it looks like it is unable to boot. There are no Windows error reports on it either. I watched it through Discord screenshare because I could not properly understand his issue. I had asked a few other random people to test my game and demo (he has the issue with both, the demo and full version) however no one else (including me) is able to reproduce this behavior. At this point I have tried updating Unity from 2018 to 2019 (no change in behavior) added manual logging (with no results) updating drivers (on his system) installing Visual C (on his system) empty project with Unity sample scene (he was able to load the sample scene!) deleting crashhandler.exe (used to fix similar issue in the past based on older threads) modifying files deleting and downloading the files What else can I try in order to figure out what is causing the issue? I am honestly clueless. Since the sample project was able to boot on his system there is definitely something wrong with the build on my end. However he is the first person with this issue. It doesn't even get to the point of launching on his system and it can't be found in the memory either. It is almost as if Windows is blocking it from launching, however that is not the case. But the result is very similar to that. There is a free demo on the store page available in case you want to see if it boots on your system. It works for both VR and non VR systems. When no VR devices are detected all VR related contents are disabled. This has been thoroughly tested and worked on loads of different Windows systems with different specs, with VR and no VR. Once again, there are no errors, no logs, the build doesn't even make it to that point, yet that exact same build works for literally everyone else on various systems. I am absolutely clueless about what to do in order to resolve this issue. Any help advice or pointers towards the right direction are greatly appreciated! PS he is not a troll, I have known this guy for a long time now and he genuinely wants to support me.


Particle spawn on collision spawns too many particles So i have the following code private void OnCollisionEnter(Collision collision) foreach (ContactPoint contact in collision.contacts) if (contact.otherCollider.CompareTag("Ground")) Instantiate your particle system here. Instantiate(Effect, contact.point, Quaternion.identity) Now this works great however it spawns way too many particles (as the animation I am doing with the item hits the ground a lot). Is there a way to limit the particles in a sensible way?


How do I link a GameObject activated state to a UI button being held? How do I go about this functionality When a user taps and still holds onto a UI button, a GameObject will be set active, when they release the UI button, the GameObject will be deactivated.


unity how to keep prefabs updated I have a number of prefabs in unity and I regulary update them, is there an easy way make sure unity updates these prefabs so that I don't have to update 20 identical objects in identical ways acros 10 different scenes?


How to prevent a cube from falling through a plane in Unity I am trying to prevent a player cube from falling through the plane (Battleground) in Unity, but after adding Mesh collider to both the cube and plane, as well as adding a rigidbody, nothing seems to work. The only way I can prevent this from happening is by locking the y axis of the cube, but this is a problem because I am adding in a jumping ability, and the player needs to be able to fall of the map. Is this something I can do within the Unity editor, or do I need to make a script that does that. To verify, all 3 colliders have "Is Trigger" Enabled, the platform is not designed to be moved, so the X, Y and Z of both the plan's rotation and position are locked, and the material for the colliders are all default. Each of the cubes and the plane's material are custom (Not the collider's material). The X, Y and Z of the cube's rotation are locked. Both cubes have the tag 'player' The code for player movement is using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMove MonoBehaviour private Rigidbody rb Use this for initialization void Start() rb GetComponent lt Rigidbody gt () Update is called once per frame void FixedUpdate() float h Input.GetAxis("Horizontal") 5 float v Input.GetAxis("Vertical") 5 Vector3 vel rb.velocity vel.x h vel.z v rb.velocity vel


Managing multiple animation files in a Unity project I am on my project, but find it hard to understand what I'm missing from those few animation and rigging tutorials. I have an FBX I modelled and rigged from blender... Or I could just take a model from Mixamo or other resources. Is it possible to have loosely coupled .anim files which could be mix matched at runtime with different FBXs? It seems the Animator Controller can reference each .anim file independently if necessary, so I guess we can make one animation per fbx and split anim files in Unity project explorer... There must be a better way, right?


Tweaking screen transitions not to fire every time in Unity I'm making a simple screen transition system for my game which consists of two states firing the right clips (one for the starting half od the transition animation, one for the ending one) and a condition between the end and start one which is set to true when user wants to change the level (so that the Start animation would fire in the previous animation and the End in the new one). This is cool and all but poses two problems firstly, the game starts with the End phase animation which looks a bit weird. Secondly, since the Restart button in the main game just reloads the level, it causes the End transition to fire every time too which looks weird and out of place. How would I go about tweaking the Animator so that the End phase only runs when I actually change the level as opposed to when starting the game or reloading the current scene? Maybe there's some way to pass some kind of a parameter when loading a new scene that I'm not aware of? This way, I could just pass a flag like shouldFireEndAnimation so that it does not fire when the game just starts or a level restarts?


Move a point to another, along an elipse according to this picture, I want to move my yellow object, smoothly to the red one. And I want to have an eliptic trajectory in relation to my center point. So for now I'm having this code yellowPoint.position Vector3.SmoothDamp(yellowPoint.position, redPoint.position, ref currentVelocity, dampingMove) How can I change it to add the elipse, depending on a third center point ? the itinial code can change of course. Thanks you !


iOS build size is too large in Unity I have finally completed my game and ready to upload my game to the App store, but my build size is too large. I have checked log statement and it is roughly 13.3 mb but when i build my game and test on iOS device it is 80.0 mb. Also Scripting Backend is 'Mono2x' Stripping Level is 'use micro mscorlib' Script Call Optimisation is 'Fast but no Exception' My Game size must be around 15 to 20 mb why it is too large? What i am missing?


Determining how loud an AudioClip is I have some code that uses GetSpectrumData from an AudioSource playing a song to create a level layout for the player to play. I want to add a functionality where the players can upload their own songs and play the levels created with the data from these songs. Unfortunately, when comparing different audio files, I encountered this As you can see, the amplitude differs drastically from clip to clip, subsequently creating levels that are trivial to complete or almost impossible. I want to find a way to determine this "loudness" so I can tone it down or amplify it with a multiplier after getting the data from the song. Also, is there a way to extract this data without playing the song?


AddListener will not listen to onClick event Based on this question on the Unity forum, I've made this code to instantiate a button and add an onClick event. Setting some other component properties right of the prefab. shopTurretItem.GetComponent lt UnityEngine.UI.Button gt ().onClick.AddListener(() gt UnityEngine.Debug.Log("Click") ) Instantiate(shopTurretItem, transform) The variabele shopTurretItem is my prefab type of UnityEngine.GameObject. The problem is that the log Click will never be shown. If I add breakpoints on the first code line, the compiler will stop the code. If I place it into the closure, it'll never be hit if I click on that button. This is the inspector of my prefab shopTurretItem. What's wrong with this code?


How to teleport a game object to an empty game object? I am trying to make a respawn system where if the player touches a plane, (the name of the object is tutlvl1 flrdead) they get teleported to an empty object at player spawn named quot RESPAWN quot . But, several tutorials and unity answers threads lead me to nowhere since they were written from back in 2013 or somewhere around there. Code using System.Collections using System.Collections.Generic using UnityEngine public class deathfloor MonoBehaviour Start is called before the first frame update void Start() Update is called once per frame void Update() public gameObject myObject You can name it whatever you want. myObject.transform.position new Vector3(3.076, 1.74, 3.651) How can I fix this to do what I need for my game?


Unity Built In Scrollable Containers? Is there a way to get a scrollable container in Unity without purchasing a plugin such as NGUI or TK2D? I want to create a scrollable container of interactive elements that can be clicked on individually and be scrolled horizontally by the user dragging their finger. You can kind of think of this as something similar to the shop menus in Clash of Clans. Here's a quick mock that I made to demonstrate the behavior I'm looking for https www.youtube.com watch?v bOJSMDPdFUQ Is there a built in way to do this in Unity without the need of purchasing an extra plugin such as NGUI or TK2D?


How can I reduce this code? Could you help me to reduce this code as much as possible? public GameObject TextPage public void Skin0() foreach (GameObject go in TextPage) go.SetActive(false) TextPage 0 .SetActive(true) public void Skin1() foreach (GameObject go in TextPage) go.SetActive(false) TextPage 1 .SetActive(true) public void Skin2() foreach (GameObject go in TextPage) go.SetActive(false) TextPage 2 .SetActive(true)


How do I rotate a sphere so that a position on it comes to a specific location? Sorry for my english. I added a picture to explain what i want. I want rotate Big Sphere to make the black point locate in front of camera. (to the white point's position) not black point moving, whole sphere moving. or is it better to move camera to black point? which API should i use?


Runtime NavMesh Builder source mesh combined mesh is skipped because it does not allow read access I'm getting this error Runtime NavMesh Builder source mesh combined mesh is skipped because it does not allow read access I checked all the models and it has the read permission. I also noticed, that in some cases unchecking the static checkbox helps and I'm getting a smaller amount of these errors.


How can I my homing missile avoid walls (2D)? Okay, I have the homing missile implemented. It will follow the player, but I want it to avoid the walls. I tried out A but I want to make my own. I need some help plzz.


Grid of buttons in Unity button bounds are stretching beyond their visuals, capturing clicks meant for other buttons I am using unity UI for the first time and trying to create a level selection menu just like Angry Birds. I had successfully created the dynamic level selection menu. It was all good in the inspector but when I build and run it, something strange happens when I click on the first button of the first row, instead of that button, the last button of that row got clicked. I searched and found that the image was not stretching (because of preserve aspect property checked) but the bounds were stretching with the resolution so the bounds were overlaping and the wrong button was getting clicked. There is a panel which is child of the canvas gameObject. Buttons are child of panel gameObject. Panel's anchors are set to stretch the canvas. Buttons' anchors are set to stretch the panel. Here is the code to create menu dynamically. public class UITest MonoBehaviour public Button button public RectTransform parent void Start() SetupButtons() void SetupButtons() float x 155 float y 55 for(int i 1 i lt 15 i ) var I i var btn Instantiate(button) as Button var btnRect btn.GetComponent lt RectTransform gt () float width btnRect.rect.width 5 float height btnRect.rect.height 5 btn.transform.SetParent(parent, false) btnRect.anchoredPosition new Vector2(x, y) btn.onClick.AddListener(() gt Temp(btn, I)) if(i 5 0) y (height) x 155f else x width Debug.Log(width ", " height) void Temp(Button btn, int i) Debug.Log("Clicked " i) Debug.Log(btn.GetComponent lt RectTransform gt ().anchoredPosition " " btn.GetComponent lt RectTransform gt ().rect) Here are some screenshots to better understand the problem. I hope you guys have understood the problem please help me solve the problem.


How to be sure that a target goal in a match 3 game level will not be impossible? This is clearly not a coding problem but the logical one. I am starting to learn how to make a match 3 game. but there is a question rising in my mind. when i will set goal to complete the level, how will i know the goal is achievable ? suppose in a level where i have to collect 5 Red, 12 blue, 9 green objects by matching the same(like farm heros). how would i decide how much moves i need to set to make this goal achievable. i mean it should be challenging but not be impossible. since the objects spawn in a random whats the surety that there will be enough number of gem in the game to not make impossible. is there some logical explanation for this, or i just have to test and look out how many moves it takes to achieve the goal. Is there an algorithm which generates the gems according to target set, or they are generated in random manner? To be more clear towards my question i am going to take an example of King.com's farm heros saga . In level 9 the target is to collect number of four types of objects 26,26,14,5 respectively. and the maximum number of moves are 22. now this goal may be achievable and challenging(i mean you can achieve it in two or three trials ) but not impossible. Now my question is what made those guys so sure that it will not be impossible, how they decided that 22 move will be enough and challenging. well.. they could have put the maximum number of moves to 5 or 6. but that would surely make it impossible to clear the level. so how they decided to keep move 22 or this. Are they using static pattern to generate and spawn objects, or ratio of collectible gems is fixed(i.e in total gameplay there will be X ,Y ,Z ,M of gems respectively ), or there is some other way. I just need some hint what should i look for..


How can I add orbit effect to the camera? On my player I have the component Animator , Rigidbody , Capsule Collider , Third Person User Control script , Third Person Character script. On the Main Camera there are two scripts but only one is activated for now Camera Follow and Mouse Orbit With Zoom The Camera Follow script is working fine. The problem is when I'm activating the Mouse Orbit With Zoom script if I move the player with the keys WASD and also rotate orbit the camera with the mouse the player lose focus. He does change his direction according to the mouse rotation but also lost focus And also for some reason I can make the camera rotation to be diagonal The reason Main Camera is not child of the player is that it's making the camera stuttering and rotating very fast on place. That is why I added the Camera Follow script. The Camera Follow script using System.Collections using System.Collections.Generic using UnityEngine public class CameraFollow MonoBehaviour public Transform player public Vector3 offset Update is called once per frame void Update() transform.position player.position offset The orbit script using UnityEngine using System.Collections AddComponentMenu( quot Camera Control Mouse Orbit with zoom quot ) public class MouseCameraOrbit MonoBehaviour public Transform target public float speed private void Update() if (Input.GetMouseButton(0)) transform.RotateAround(target.position, transform.up, Input.GetAxis( quot Mouse X quot ) speed) transform.RotateAround(target.transform.position, transform.right, Input.GetAxis( quot Mouse Y quot ) speed) My game is adventure game type and the main goal is to make player movement to be with the keys and also to be able to look around like orbiting with the mouse because only following the player will not show where to go , that is why I'm trying to add orbiting, but the orbiting part is just not working good.


Moving large group of units 1 by 1 takes too long, how can I improve this? I use use Unity's own NavMesh AI system and I think it works pretty well. The only problem I have is that when I move large groups of units, they will find a path one by one, but it takes a really long time as you can see in the video https gfycat.com blankhalfdartfrog To set destinations I use this public bool SetDestination(Vector3 point) if (SamplePosition(point)) agent.SetDestination(point) return true return false I know I could wait until they all have pathPending false, but that would mean the entire group moves with a huge delay. Is there some way I can improve or fix this issue? Edit It is quite simple to recreate (if you have some basic knowledge on Unity NavMesh) simply create a "click to move" script that moves a List of units to where you clicked using the code above (just fill the list in Start on each unit). Put down a few obstacles and you're done.


Level Modeling Workflows in Maya for Unity I'm wondering what the standard workflow for modeling static levels for Unity (or for that matter, other High Level engines) is? My somewhat limited knowledge tells me that the best process is modeling the entire static level in Maya, texturing, then baking AO and some static lighting into the scene, then importing the single level asset into unity to add dynamic objects. Is there another way that I should be doing this that is more efficient in a performance sense or from a workflow point of view? I know the question is somewhat open ended, but generally i'm asking what the standard workflow for level modeling is. Thanks!


Unity block chunk generation pattern I am trying to do something like Minecraft game in Unity. Currently I am trying to generate a chunk of blocks, given dimensions. I can successfully create a chunk of N x 0 x 0 sized chunk, but due to lack of logic, I have no idea on how to make triangles and vertices match for other blocks. Basically, what I mean is, I can generate something like this But can't do this My Block vertices and Triangles Vector3 cVerts new Vector3 (0, 0, 0), 0 new Vector3 (1, 0, 0), 1 new Vector3 (1, 1, 0), 2 new Vector3 (0, 1, 0), 3 new Vector3 (0, 1, 1), 4 new Vector3 (1, 1, 1), 5 new Vector3 (1, 0, 1), 6 new Vector3 (0, 0, 1), 7 int cTris 0, 2, 1, face front 0, 3, 2, 2, 3, 4, face top 2, 4, 5, 1, 2, 5, face right 1, 5, 6, 0, 7, 4, face left 0, 4, 3, 5, 4, 7, face back 5, 7, 6, 0, 6, 7, face bottom 0, 1, 6 Chunk creation method void CreateChunk() ... for (int x 0 x lt 100 x ) for(int y 0 y lt 10 y ) for (int z 0 z lt 1 z ) AddBlockAtPosition(new VectorInt(x, y, z), "Grass") ChunkMesh.vertices CurrentChunkVerts.ToArray() ChunkMesh.triangles CurrentChunkTris.ToArray() ChunkMesh.uv uvs.ToArray() ChunkMesh.RecalculateNormals() AddBlockAtPosition() method void AddBlockAtPosition(VectorInt pos, string name) int x pos.x, y pos.y, z pos.z create separate cube data CubeMesh cube new CubeMesh(vertices.ToArray(), triangles.ToArray(), uvs.ToArray()) I use MoveCube() to change each Block's vertex and triangle numbers, so they will "match" in a Chunk mesh, when they become part of it. cube.MoveCube(new Vector3(x, y, z), (x y z) 8) cube.MoveUV(new Vector2(x y z, x y z)) CurrentChunkVerts.AddRange(cube.Vertices()) CurrentChunkTris.AddRange(cube.Triangles()) CurrentChunkUV.AddRange(cube.UVs()) And most importantly, that's where my problems are, MoveCube() Class Cube private Vector3 vertices private int triangles ... public void MoveCube(Vector3 direction, int n) for(int i 0 i lt vertices.Length i ) vertices i direction for (int i 0 i lt triangles.Length i ) triangles i triangles i n I know that I am not the first to re create minecraft, I have found this tutorial https www.blockstory.net node 56 But for me as a beginner, some "simple" parts like these I have problems with are skipped. And other tutorials just generalize the idea, which isn't enough for me.


Making a cube follow my finger in Unity2d? I would like to make a cube follow my finger when i touch an iphone screen and drag in unity 2d.


Unity Scripting Runtime Version Option Missing I have been trying to open and run my couple months old project in Unity3D, and I'm getting about 500 errors. So idecided to reinstall Unity. On the tutorial for the project, it tells us to make sure the "Scripting Runtime Version" is set to 4.x equivalent. Only problem for me is I cannot see such an option in Unity5.5.4p4. How can I set .NET 4.x in Unity for good?


Need advice concerning the creation of open world game in Unity 3D I just wanted to ask for advice those being an expert in Unity 3d and overall in game industry about how it is possible to create an open world game by means of Unity 3D, that is, I already tried to combine several tiles of terrains, 4 to be exact, and their respective size is 500x500. However, once I started to add the fifth terrain to those terrains, Unity stopped working. Moreover, another problem that I faced was with light mapping in Unity, that is, the more terrain I add to the scene the more it is difficult to bake the light mapping. The question is if I am doing correctly by adding terrains to each other and how open world games are actually created. Yes, I heard of chunk loading but is it possible to code it on my own without using ready plugins. Lastly, Is it possible to combine tiles of terrains just manually without using any tools like Terrain Slicing kit or Gaia please I really need your help Thank you for your attention))).


Coins don't show up in game in Unity I have a 2D game I'm making with Unity, and I want the player to be able to collect coins that I place all over the game. I used the coin prefab with a 2D circle collider and an animation to make it spin. The problem is that only the first coin I put into the scene shows up in the game, and when I collect that one coin, the counter shows that all the others have been collected as well. Here's the script I attached to the player for the coins private uint tokens 0 void OnGUI() GUILayout.Label ("Tokens " tokens) void CollectToken(Collider2D tokenCollider) tokens Destroy (tokenCollider.gameObject) void OnTriggerEnter2D(Collider2D col) if (col.gameObject.CompareTag ("token")) CollectToken(col) This is my current setup for the object properties Thank you for any help!


Character on platform move slowly I'm having a problem similar to this link http answers.unity3d.com questions 1295955 character on a moving platform slows down.html But... My 2D character is on an elevator (which does not have any physics) and is being moved up and down through an animation (transform). But when my character is on the elevator, the colliders2D overlaps another, as my character's RigidBody2D stands still as I move the game object elevator (crossing each other). My solution was to try to attach my character as the child of the elevator (SetParent), and this solved the problem of overcoming the colliders, but it gave me a new problem. The new problem consists of a certain slowness in the movement of the character while it is on the elevator. I believe the problem is because the transform of my character is in motion while the elevator goes up and my rigidbody don't add any force. Do I need move the elevator with physics to stay movent? Or am I thinking the wrong way?" How to solve this problem? See the player movement script using UnityEngine using System.Collections public class Move MonoBehaviour public float speed public float jump public GameObject rayOrigin public float rayCheckDistance Rigidbody2D rb void Start () rb GetComponent lt Rigidbody2D gt () void FixedUpdate () float x Input.GetAxis ("Horizontal") if (Input.GetAxis ("Jump") gt 0) RaycastHit2D hit Physics2D.Raycast(rayOrigin.transform.position, Vector2.down, rayCheckDistance) if (hit.collider ! null) rb.AddForce (Vector2.up jump, ForceMode2D.Impulse) rb.velocity new Vector3 (x speed, rb.velocity.y, 0)


Fast zoom in and out in Unity Editor Is it possible to zoom out and zoom in in Unity Editor in Scene View faster than just with the help of scroll wheel on the mouse? I hope there are exist some shortcut for that. Am I right?


OnMouseOver not registering collisions I'm working on a UI heavy game and I'd like to add sound effects for when the player mouses over a UI button (using TMP, if that matters). I've tried OnMouseOver and its siblings OnMouseEnter and OnMouseStay, I've tried with and without 2D Box Colliders, but so far nothing I've tried seems to register that the mouse is over the button i.e. nothing happens. If a collision or Raycast hit were registered, all that I'm asking right now is for it to run the line Debug.Log( quot Collision detected quot ) I know that Unity is able to register hits on the UI element I'm testing on, because mousing over it engages the Sprite Swap function that's part of the Button component, which it would not do if it were not accepting Raycast hits. I'm sure there's some very simple solution to this, like a check box I haven't ticked, but I could really use some help here. Many thanks!


IndexOutOfRangeException Array index is out of range even though the inspector clues otherwise I am currently making a randomized infinite platform with GameObject already made platforms in 3 arrays. In the inspector everything is obviously running quite smoothly but I keep weirdly keep getting uncalled for errors like IndexOutOfRangeException Array index is out of range. Here is my code using System.Collections using System.Collections.Generic using UnityEngine public class BackFloorSetter MonoBehaviour public GameObject gameBackFloorsOne public GameObject gameBackFloorsTwo public GameObject gameBackFloorsFinal public Vector3 nextPosition public float unroundedFinalOrTwo public int finalOrTwo public float unroundedTwoFloor public int twoFloor public float unroundedFinalFloor public int finalFloor public GameObject currentSpawnFloor public float floorSpawnCounter public int counterGoal 5 void Start() nextPosition new Vector3(0, 0, 0) Instantiate(gameBackFloorsOne 0 , nextPosition, Quaternion.identity) void Update() floorSpawnCounter 1 Time.deltaTime if(floorSpawnCounter counterGoal) floorSpawner() counterGoal 5 unroundedFinalOrTwo Random.Range(0.6f, 2.4f) finalOrTwo Mathf.RoundToInt(unroundedFinalOrTwo) unroundedTwoFloor Random.Range( 0.6f, 3.4f) twoFloor Mathf.RoundToInt(unroundedTwoFloor) unroundedFinalFloor Random.Range( 0.6f, 4.4f) finalFloor Mathf.RoundToInt(unroundedFinalFloor) if (finalOrTwo 1) currentSpawnFloor gameBackFloorsTwo twoFloor if (finalOrTwo 2) currentSpawnFloor gameBackFloorsFinal finalFloor public void floorSpawner() nextPosition.x 232 Instantiate(currentSpawnFloor, nextPosition, Quaternion.identity) public void flatGroundSpawner() nextPosition.x 232 Instantiate(gameBackFloorsOne 0 , nextPosition, Quaternion.identity)


Mouse detect object without Collider? Is there any method for mouse or ray to detect object doesn't have collider ? If no, what also can I use ?


Unity3D Build Configuration for Deployment Publish Is there the option within Unity3D to specify build configurations? My goal is relatively simple when building for mobile stores (Play Store App Store) I want to make sure my app is pointing to the production services, rather than the test one I use in the editor testing on devices. It's controlled by a field on a MonoBehaviour currently, but we I need to remember to flip it from Test to Production before doing a build and publish.


Custom FPS Controller in Unity 5.6.6f2 not letting me look up or down Due to the FPS Controller seeming to be broken in Unity now, I started using a custom one by kinifi on GitHub. For some reason though I can't look up or down. I removed the Main Camera so it should of fixed it but no. Is there anything I can change in this script to allow me to look up and down. using System.Collections using System.Collections.Generic using UnityEngine RequireComponent(typeof(Rigidbody)) public class FPS MonoBehaviour private float speed 5.0f private float m MovX private float m MovY private Vector3 m moveHorizontal private Vector3 m movVertical private Vector3 m velocity private Rigidbody m Rigid private float m yRot private float m xRot private Vector3 m rotation private Vector3 m cameraRotation private float m lookSensitivity 3.0f private bool m cursorIsLocked true Header("The Camera the player looks through") public Camera m Camera Use this for initialization private void Start() m Rigid GetComponent lt Rigidbody gt () Update is called once per frame public void Update() m MovX Input.GetAxis("Horizontal") m MovY Input.GetAxis("Vertical") m moveHorizontal transform.right m MovX m movVertical transform.forward m MovY m velocity (m moveHorizontal m movVertical).normalized speed mouse movement m yRot Input.GetAxisRaw("Mouse X") m rotation new Vector3(0, m yRot, 0) m lookSensitivity m xRot Input.GetAxisRaw("Mouse Y") m cameraRotation new Vector3(m xRot, 0, 0) m lookSensitivity apply camera rotation move the actual player here if (m velocity ! Vector3.zero) m Rigid.MovePosition(m Rigid.position m velocity Time.fixedDeltaTime) if (m rotation ! Vector3.zero) rotate the camera of the player m Rigid.MoveRotation(m Rigid.rotation Quaternion.Euler(m rotation)) if (m Camera ! null) negate this value so it rotates like a FPS not like a plane m Camera.transform.Rotate( m cameraRotation) InternalLockUpdate() controls the locking and unlocking of the mouse private void InternalLockUpdate() if (Input.GetKeyUp(KeyCode.Escape)) m cursorIsLocked false else if (Input.GetMouseButtonUp(0)) m cursorIsLocked true if (m cursorIsLocked) UnlockCursor() else if (!m cursorIsLocked) LockCursor() private void UnlockCursor() Cursor.lockState CursorLockMode.Locked Cursor.visible false private void LockCursor() Cursor.lockState CursorLockMode.None Cursor.visible true


Unity move Vector3 position with transform How can I move a new Vector3 position with a Transform? Like the transform is the parent the vector. Example if I want to push the x position for example by 10 value and I rotate the transform its push in world coordinate but I want to push by the rotation too. void Update () temp transform.Find("Transform").position temp new Vector3(temp.x 10.0f, temp.y, temp.z) Debug.DrawLine(transform.Find("Transform").position, temp)


How to make Unity Layout switch while in Play mode I'm looking for a way to auto switch the Unity layout when I go to play mode. I want to Unity Editor layout automatically changes to my preset layout when I click on Play button and When I stop the game, It goes back to the default layout.


Attach movement to each list object How would i move every sphere that gets spawned every 2 seconds ? Basically i want every sphere to follow the previous spawned sphere or even all N 1 spheres should follow the first spawned sphere along a predefined path and they should keep rolling as a train of spheres. I am lost when i try to imprint movement to each sphere. using System.Collections using System.Collections.Generic using UnityEngine public class Spawner MonoBehaviour public GameObject prefabs public List lt GameObject gt listBalls new List lt GameObject gt () private GameObject x public int timer 0 private float movementSpeed 5f void Start() createBall() void Update() if (Time.time timer gt 0.8f) createBall() timer 2 listBalls listBalls.Count 1 .transform.position new Vector3(0, 0, movementSpeed Time.deltaTime) void createBall() x prefabs Random.Range(0, prefabs.Length) Instantiate(x, x.transform.position, Quaternion.identity) listBalls.Add(x) void moveBall(GameObject x, GameObject y) x.transform.position y.transform.position new Vector3(0,0, 1) Loop added but movement staggered void Update() if (Time.time timer gt 0.8f) createBall() timer 2 foreach (GameObject item in listBalls) item.transform.position new Vector3(0, 0, movementSpeed Time.deltaTime)


Where do components get added in Unity? In unity's GameObject class, there are a few default data members. When we add a component to the game object, light for example, where exactly does it get added? Does it become a part of the GameObject class?


animationClip.SampleAnimation() does not result in visible changes Here is the relevant code snippet public class AnimatedGameObject MonoBehaviour private float extentPlayed public AnimationClip Clip public GameObject AnimationTarget private void Update() if (this.extentPlayed gt 1f) return Debug.Log(this.extentPlayed) this.Clip.SampleAnimation(this.AnimationTarget, extentPlayed this.Clip.length) this.extentPlayed 0.005f In the Unity Editor, the game object assigned to AnimationTarget contains the animator component controlled by the controller that uses Clip. However, when I start the game, even though I can see that this.extentPlayed is being incremented every frame, no animation is taking place that I can see. I am aware that what I am currently trying to do in the Update() method can be achieved by calling SetBool(string name, bool value) on the animator, but the purpose of writing the Update() method this way is to gain familiarity with how the SampleAnimation() method works, so that I can perform more complicated manipulations when necessary. What changes should I make for the animation to take place?


Why can't I put a source image in my Image component? I can't put an image here as source image, and I have trouble figuring out why. What did I miss?


How do I move many "static relative to each other" objects around? I'm currently building an Elevator Bank simulator in Unity3d and I'm stuck on how to reduce the amount of objects it's going to generate when it's done. The simulator will consist of one player (for now) walking into a building, calling an elevator, picking a floor, going up down and getting out of the elevator again. To illustrate the problem, I'll sketch 2 scenario's. One where there's no problem whatsoever. One where I simply scale upwards and create a mess. But first, a list of what's inside the simulator (excluding the player). One hull of elevator shafts (3D .obj model). One elevator car per shaft (3D .obj model). One group of hall buttons per shaft per floor (one button for the top amp bottom floor, two for the rest). One group of control buttons per elevator car (door open, door closed, etc.). At least 3 buttons. One floor call button per elevator car per floor. Two doors per elevator car. Two doors per shaft per floor. A simple set up of 3 shafts and 4 floors will already create 75 objects of which 30 are moving. Take 20 floors, 2 rows of elevators, 3 cars per row and I'm over 600 objects already. Now. The Empire State building has 102 floors and 73 elevators. Which means multiple banks, a whole lot of floors, a whole lot of buttons and a whole lot of cars. Scaling my current set up to support that will create a mess at best and simply won't work at worst. Since this is an elevator simulator, the whole point of it is to make sure every elevator is active from starting the scene to ending the scene. So no tricks like only spawning what's in range of a camera, hibernating objects, object pooling and what not are out. Now, objects in the same elevator car are static relative to each other. If the car moves up, everything moves up the same amount. So I hope I can move them as a group. Except I have no clue how to do such a thing in Unity. Prefabs may be part of the solution, but that still won't link their movements together. I've considered linking them together like a Snake game, but the amount of objects involved is orders of magnitude more. Luckily, all moving objects (except for the player) will only move on one axis. Doors only slide open closed, elevator cars and their buttons go up and down. All rotations are fixed. How do I move so many objects around in a single scene without creating a mess of variables in a performance wise good way?


Adding a profile to a dialogue box I am trying to create dialogue boxes that contain the profile picture of the speaking character in them. As such, I want the profile pic to be attached to the object itself. If I understand this right, the following creates a variable space for profilePic that I then populate within the GUI. using UnityEngine.UI public class NPC Character SerializeField private Image profilePic Then over in my dialogue script I have the following using UnityEngine.UI This currently only allows for one sided conversations this can be later modified to add profile picture as well as several iterated conversations public class Dialogue MonoBehaviour SerializeField private UnityEngine.UI.Text dialogueText SerializeField private GameObject dialoguePanel SerializeField private UnityEngine.UI.Image profilePic private string dialogue private int dialogueIndex public void StartDialogue(string dialogue) dialogueIndex 0 this.dialogue dialogue dialoguePanel.SetActive(true) This is what actually affects the GUI dialogueText.text dialogue dialogueIndex this.profilePic profilePic The dialogue functions work. It should be taking the contents of this.profilePic and putting them into the UI.image profilePic component, right? The text works. The panel pops up. Just no picture. Anyone have any thoughts?


Artifacts on top of platform sprite only when moving I made a floating platform in Unity which has a propeller movement animation. I attached a script I wrote to the game object that adds slight vertical and horizontal movement using the game object transform.position. This is creating some weird artifacts at the top of the sprite, but only when the movement code is active. When I don't move the platform and just leave it still to animate there are no artifacts. Gameplay Sprite Import Settings Sprite Renderer Camera Settings Resolution


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


How do I set the opacity of a Button to 0? (Unity) I'm trying to hide a button when you click that button (I meant setting the opacity to 0, not disabling the game object of the button). What the button does is it loads a scene async. If I disable the game object I won't be able to load the scene async. Any way to set the opacity of the button? Sorry if the question is already asked as I wasn't able to find any questions related to this.


Does Unity own my game? I made my first game in unity, and I was wondering if I can sell it without owing anything to unity?


Custom Unity launcher localization I would like to localize Unity launcher using own texts. At the very least I would like to change "play!", "quit", "Graphics" and "Input" to own arbitrary labels. How can I achieve that?


What is Unity Quaternion range? I've read somewhere that a Quaternion in Unity ranges between 1,1 values. I mean the individual XYZW values. Ex new Quaternion(.1f,.2f, .3f, .4f) Is this true? More clearly I know they take float values therefore the theoretical limit is floating point value limitations, I'm asking the real rotation results. For instance when I look up Quaternion values while rotating a GameObject it is usually in the 1,1 limits. But I'm not sure if that's my case or not.


Is normal mapping cpu overhead or gpu overhead? In Unity3D Engine, I usually apply normal mapping using fragment shader. In this case, this normal mapping is cpu overhead or gpu overhead?


Not able to change Rigidbody 2d gravity scale I have been trying to change the gravity scale of my Rigidbody2d when I click on it. By default it is by 0 and when I click on it, it should change to 1, so that it falls down. I have a square with a boxcollider2d and a Rigidbody2d and a square with just a box collider. public bool gravity false public bool m isRunning false public SpriteRenderer m spriteRenderer private Rigidbody2D rb private void Update() if (gravity) rb.gravityScale 1 private void Start() m spriteRenderer this.GetComponent lt SpriteRenderer gt () rb GetComponent lt Rigidbody2D gt () private IEnumerator Changecolor() yield return new WaitForSeconds(1) int random Random.Range(1, 4) if (random 1) m spriteRenderer.color Color.blue else if (random 2) m spriteRenderer.color Color.red else if (random 3) m spriteRenderer.color Color.green else m spriteRenderer.color Color.yellow this.StartCoroutine("Changecolor", 3f) private void OnMouseDown() gravity true m isRunning !m isRunning if (m isRunning) StartCoroutine("Changecolor", 3f) else StopCoroutine("Changecolor")


Why does my Unity Android game get a small amount of lag when not being touched for some time? I have made a 3d version of space invaders. I made all the assets myself in Blender. I feel that it's a very basic game and my Galaxy Note 3 test device should handle it no problem. (Although it's a few years old now so perhaps some kind of shader issue or something that my phone not updated enough for ?) There are 55 enemies all with one mesh each. There's the flying saucer model and the player model. Then there's a plane for a background, and 4 defensive meshes (although I've tested without these and the result is the same). Basically, it all runs superbly (I have turned down much of the lighting and graphics quality etc, but have left basic shadows in). However I notice that if the player just lets the phone sit there in game without touching it, there is very slight (but noticeable) frame lag. All the enemies have a very short animation which moves its arms a small amount. I could post the code but its massively unorganized and really quite an embarrassment (HAHA!). Also I'm not sure what parts are relevant so it would be a huge post. Is there any known issues that can cause the lag only when not being touched? As I feel like some of my old projects might have had this happening too but they've been deleted now unfortunately so I can't really dabble with it. It works smooth as silk in the Unity Editor Android 'emulator' and as I say, if I actually play the game on my phone it's smooth too.


Disabled script works anyway I have a simple code that will be enabled when I kick, so I disable it right away but even though it is disabled, it works somehow. can it be because of his parent or something else I dont know of? this is the script Kick Test, i dont reach it from anywhere else private GameObject ball private Rigidbody2D rg2d public int power 30 void Start() ball GameObject.FindGameObjectWithTag("Ball") rg2d ball.GetComponent lt Rigidbody2D gt () this.enabled false private void OnTriggerEnter2D(Collider2D col) if(col.tag "Ball") Debug.Log("K CK") Vector2 pos (transform.position col.gameObject.transform.position).normalized rg2d.AddForce( pos power, ForceMode2D.Impulse)


Convert the animation inside FBX into Unity Recently i bought a package with an fbx and lots of animations. Since I want full control and change a couple of details, I want to convert them into the regular Unities Animation System. I cant convert them into the normal Unity Animations though. They are "read only". I can load them, copy paste them into my own "not read only" animation file. But somehow i cant change the file anymore after I pasted something inside. What am I doing wrong? Is that something "impossible"? Can you guys help?


How to ease toward a rotation limit, instead of stopping abruptly? I rotate my camera using a framerate independent exponential ease out blend like so x Input.GetAxis("Mouse X") xSpeed float target 0f I want to blend towards 0 float sharpness 0.05f the smaller this value, the longer it takes to settle down to the target value float referenceFramerate 90f the approximate framerate on my developer machine float blend 1f Mathf.Pow(1f sharpness, Time.deltaTime referenceFramerate) x Mathf.Lerp( x, target, blend) This works fine. Now my camera should be clipped at a certain rotation yaw. The new camera rotation yaw is calculated like this CurrentYaw x Mathf.Abs( CameraDefaultPos.z) if ( CurrentYaw gt 160f) CurrentYaw 160f else if ( CurrentYaw lt 120f) CurrentYaw 120f This clipping part of my code makes the camera stop abruptly at the maximum. How could the above Mathf.Lerp function be adopted to make it so that the x value would be damped more quickly when going towards the rotation limit?


Microphone channel not detected in Unity This is very specific to Unity. A few testers are reporting that their microphone output isn't being detected. The code below works for the vast majority of users, but certain microphones seem to be outputting on the wrong channel (R maybe)? AudioClip current microphone recording clip Microphone.Start(microphone name, true, 30, 16000) How can I capture and analyze output from several channels? I don't see any channels parameter for Microphone.Start


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


Unity, depth behind a transparent object Is there a way to know how far away is any object behind a transparent object in shader? Like making water fully transparent when close to shore.


Unity FPS Offline Multiplayer (MultiLan) Player Animation I am creating an FPS game in local multiplayer. One player creates the hot spot game, and the other one connects through WiFi network and plays the game. And i am doing this using unity MultiLan Package available in Unity Assets Store. when the player connect to the Game i play the player animation like walk , jump etc. But the problem is animation can play only which player who host the Game, not play to other player who join the Game in host network. That is Player Script. private MNetwork networkSrc public Btn Jump jumpScript public Btn DPad Btn DpadScript void Awake() if (GetComponent lt NetworkView gt ().isMine) trans transform contr trans.GetComponent lt CharacterController gt () if (jumpScript null) jumpScript GameObject.Find ("3 Jump").GetComponent lt Btn Jump gt () if (Btn DpadScript null) Btn DpadScript GameObject.Find ("6 D Pad").GetComponent lt Btn DPad gt () void Start() if (GetComponent lt NetworkView gt ().isMine) If it's my player search the networkManager component networkSrc GameObject.Find("MNetwork").GetComponent lt MNetwork gt () PlayerAnimatorComponent GameObject.Find ("Swat").GetComponent lt Animator gt () FPS Events.ChangeCharacterMotor(motor) void Update() if (!networkSrc.isPlayerExitGame) if (currentMotor null) FPS Events.ChangeCharacterMotor (motor) try currentMotor.Update () catch if (jumpScript.Player jump) if (Btn DpadScript.Player Run) RunAnimation () void RunAnimation() GetComponent lt NetworkView gt ().RPC ("SyncAnimation", RPCMode.All) RPC void SyncAnimation() if (Btn DpadScript.Player Run) PlayerAnimatorComponent.SetFloat ("Walk",2f,0.1f,Time.deltaTime) In this Script there is "Btn DpadScript" object of Virtual joystick Script name is "Btn DPad" for Player Movement. When player move then "Player Run" Boolean variable is true and play the Walk animation of player in SyncAnimation() method. But it is stuck to play animation in all player in same network. Any one can know how to play animation in all network player using MultiLan Package then tell me. I can't found in Google Search about player Animation in network using MultiLan Package. what should i do don't know any one can suggestion then i really appreciate thank you.


How To Deselect (Unfocus) All gameObjects in a Unity Scene View? When I'm done with moving and rotating gameObjects in a Unity scene, I want to deselect everything to not accidentally change it. How? In some applications ESC key does the trick, in others 'D' (deselect) comes to rescue. But I don't know any remedy in Unity. My workaround is that I click somewhere in the Project View (I don't like this approach because it brings up the inspector for that asset).


cant add script component So I'm just starting to try to learn unity development with C using this tutorial but I cant add the script to any game object and I get the following error Code of the script using System.Collections using System.Collections.Generic using UnityEngine public class NewBehaviourScript MonoBehaviour Start is called before the first frame update public Light myLight void Update() if (Input.GetKey("space")) myLight.enabled true else myLight.enabled false I know it's been answered before but I've done everything I read, I did my homework and I still cant get around this issue. I allready checked the name of the class and its the same as the file's name. I think it may be something regarding installation (?) I installed unity hub and it installed Unity and Microsoft Visual Studio by itself. Unity version 2019.3.3f1 MS Visual Studio version 16.4.5 MS Net Framework version 4.7.03062 I honestly dont know what else to do people! Please help!


How do I use UsePass in a shader in Unity when the pass does not have a name? I'm trying to use passes from a given built in shader in Unity. The docs say that the syntax is UsePass "Name". The problem is that built in shaders don't have names on their passes. How could I do that in this case? To be more specific, at the moment I need to use the Skybox shader passes. Here is one of the Subshaders in the internal Skybox.shader file SubShader Tags "Queue" "Background" "RenderType" "Background" Cull Off ZWrite Off Fog Mode Off Color Tint Pass SetTexture FrontTex combine texture primary, texture primary Pass SetTexture BackTex combine texture primary, texture primary Pass SetTexture LeftTex combine texture primary, texture primary Pass SetTexture RightTex combine texture primary, texture primary Pass SetTexture UpTex combine texture primary, texture primary Pass SetTexture DownTex combine texture primary, texture primary As can be seen there's no name in the passes. My shader is the following Shader "Custom Outline" Properties Color ("Main Color", Color) (.5,.5,.5,1) OutlineColor ("Outline Color", Color) (1,0,0,1) Outline ("Outline width", Range (0.0, 0.1)) .05 SpecColor ("Specular Color", Color) (0.5, 0.5, 0.5, 1) Shininess ("Shininess", Range (0.03, 1)) 0.078125 MainTex ("Base (RGB) Gloss (A)", 2D) "white" SubShader Tags "RenderType" "Opaque" Tags "RenderType" "Background" Pass Name "OUTLINE" Tags "LightMode" "Always" Outline pass logic (not important for the problem)... UsePass "RenderFX Skybox ..." WHAT SHOULD I DO HERE? UsePass "Bumped Specular FORWARD" The problematic line is at the end, as can be seen. The shader works for the Opaque case, using the "Bumped Specular FORWARD" pass (see the commented lines). The built in Bumped Specular shader is the following Shader "Bumped Specular" Properties Color ("Main Color", Color) (1,1,1,1) SpecColor ("Specular Color", Color) (0.5, 0.5, 0.5, 1) Shininess ("Shininess", Range (0.03, 1)) 0.078125 MainTex ("Base (RGB) Gloss (A)", 2D) "white" BumpMap ("Normalmap", 2D) "bump" SubShader Tags "RenderType" "Opaque" LOD 400 CGPROGRAM pragma surface surf BlinnPhong sampler2D MainTex sampler2D BumpMap fixed4 Color half Shininess struct Input float2 uv MainTex float2 uv BumpMap void surf (Input IN, inout SurfaceOutput o) fixed4 tex tex2D( MainTex, IN.uv MainTex) o.Albedo tex.rgb Color.rgb o.Gloss tex.a o.Alpha tex.a Color.a o.Specular Shininess o.Normal UnpackNormal(tex2D( BumpMap, IN.uv BumpMap)) ENDCG FallBack "Specular" Even when using the Bumped Specular I had to find the pass name by trial and error, seeing code snippets from older versions, etc. That's why I like to have code for everything... I could just read the code of the shader management system and figure it out. Anyway... any ideas?


How to move empty colliders? I have 2D background in unity on which I would like to add multiple circle, box colliders. Assets are not separated. I have drawn assets on background. How to move circle colliders with mouse or keyboard shortcut on the background? It's not very pleasant to define x,y position wherever needs to go for every collider.


Unity resizing particles dont mantain collisions properly I am trying to make particles for blood on death. This is what I got so far Which looks fine and all. But now I also wanted to make the blood particles turn smaller over their lifetime, so I checked "Size over lifetime" and this is what happens now See the problem? As they shrink, they seem to float a little, giving some space between the floor they are laying on. This behaviour is not really desired. How could I solve this?


Prevent feet from moving for a Unity character from a Mixamo animation So my question isn't about root motion, but rather just keeping the feet in place on the ground for a Mixamo animation... I tried to just delete the feet and toes in avatar configure, but nope... I am wondering if there is some sort of simple way to have an animation affect all but the feet?


How to make a static Material reference? I have a class Edge which may change to multiple colors materials in this case. I need to switch a Material on MeshRenderer. In order to do this, I'd need to make multiple prefabs public variables like class Edge Mono public Material red, blue, green public void SwitchColor(SomeColorEnum param) switch(param) change this.renderer.mat something This is a bad solution for this, cause I'd need at least 3 material references in each Edge object. Is there any way to make a material static, assign it from a prefab and then access it statically?


How to receive broadcast message in Unity? I am trying to get the broadcasted message in overridden method of NetworkDiscovery.OnReceivedBroadcast(). For that what I had done is below I create class which implements NetworkDiscovery where I override the method OnReceivedBroadcast() to capture the broadcast messages. In Unity Editor, I created an empty GameObject where I add the class in step 1 as component. Now in code, I started the custom NetworkDiscovery class as below Discovery.Initialize() Discovery.StartAsClient() Now, when I start the broadcast in server, I am not receiving any broadcast message in OnReceivedBroadcast(). Below is my custom NetworkDiscovery class. public class CustomNetworkDiscovery NetworkDiscovery Use this for initialization void Start() Update is called once per frame void Update() public override void OnReceivedBroadcast(string fromAddress, string data) base.OnReceivedBroadcast(fromAddress, data) One thing I noted is, If I use the NetworkDiscovery component directly in step 2 instead of using custom NetworkDiscovery class. I am able to see broadcast messages in it's default GUI. How can I receive the broadcast message in the inherited class? Any help will be appreciated. Thanks.


using an int to control events Let me explain I'm just looking for a way that I can link a number to a set of methods. I want to randomly generate a "difficulty" int, and pick out an event based on the number I get. IE, if I get an int of 3 I want that to point to a specific event. What's the best way to accomplish this? I was thinking of story the events in lists, but methods can't be in lists. I thought about making the methods into delegates and putting those in lists but that seems unnecessarily complicated. Also, in the future I think I'd want to put multiple events at each level which would sort of make putting them into array or lists difficult.


WebGL Open URL in new tab? How to open URL in new tab for WebGL? Tried Application.OpenURL("url"). But it's opens a tab in same window Thanks


Gradient fill color on circular sprite I have a white circle sprite. I know how to change its color to a solid fill color. using GetComponent lt Renderer gt ().material.color. But how would I give it a gradient fill color. I've been trying to do this with a shader. But so far the shader I've created doesn't take the circle sprite into account, simply its bounding box. It also looks a bit weird. here's my shader code Shader "Custom SpriteGradient" Properties PerRendererData MainTex ("Sprite Texture", 2D) "white" Color ("Left Color", Color) (1,1,1,1) Color2 ("Right Color", Color) (1,1,1,1) Scale ("Scale", Float) 1 SubShader Tags "Queue" "Background" "IgnoreProjector" "True" LOD 100 ZWrite On Pass CGPROGRAM pragma vertex vert pragma fragment frag include "UnityCG.cginc" fixed4 Color fixed4 Color2 fixed Scale struct v2f float4 pos SV POSITION fixed4 col COLOR v2f vert (appdata full v) v2f o o.pos mul (UNITY MATRIX MVP, v.vertex) o.col lerp( Color, Color2, v.texcoord.x ) return o float4 frag (v2f i) COLOR float4 c i.col c.a 1 return c ENDCG