How to destroy object after animation I've made an object and when the player has pick it up, rise it up and stop it out of screen. But because you can see the shadow of that object, I will destroy it after the animation has played. But how can I do this whit Unity and C ? Just destroy is just like this Destroy(gameobject) and start an animation like this private Animator anim global variable anim GetComponent lt Animator gt () in start() methode anim.SetTrigger("Picked") in other methode


Make Unity Text Area to act like a logger I'm trying to create a text area in Unity using UI.Text that contains multi line text which should act like a log view, i.e the text area Vertical Overflow is set to Truncate and a new line of text is added to the text property every now and then but instead of the text being eventually cut of at the bottom when the text area is full I want the text to 'scroll' up so that the newest added line is always the last displayed at the bottom of the text area, e.g. Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 ... When Line 7 is logged Line 1 goes out of the text area at the top, when Line 8 is logged, Line 2 goes out, etc. Can this be done with UI.Text?


Will reseting a scene instead of reloading it improve performance? I made a 2D infinite runner. My game was approved for iOS and now pending release. However, on Android, performance is a nightmare. So I'm tweaking to optimize performance. As it stands now, there is game scene and game over scene. On game over scene, there is "Play Again" button that reloads the game scene. Now, if instead of having separate scene, if i handle the play again in same scene, will it be better than reloading the scene? What i could do is, have initial speed, position etc stored in array for example and when play again is clicked, set all gameobjects to the initial values. Will the performance be better with this? since gameobjects are now not getting destroyed and reloaded?


Are we supposed to be creating player prefab? This may seem like a dumb question, but I want a single player object for the entirety of my game. However when I load multiple levels obviously I need to reload the player so I would create a player prefab and instantiate him. However, it seems counterintuitive as prefabs are for objects you want to create multiple instances of easily, correct? Also, I need values to be carried over accross levels for my player object therefore I guess I would need a static global singleton to store the player objects. Hence the dilemna and confusion! Can anyone help me out here?


How can I limit the y rotation of a cinemachine POV camera based on the player's direction? I'm using Unity (2019.4.11.f1, HDRP). My goal is to create a first person POV camera. To this purpose, I tied a Cinemachine (2.7.3) Virtual Camera to the head of a third person player character (one from the Basic Locomotion demo of this asset). The Body of the camera is set to 'Hard Lock to Target', Aim to 'POV', and Recenter Target to 'Follow Target Forward'. This works fine. The camera has a Horizontal Axis Value Range ( to ), that limits the rotation of the camera, but I cannot figure out how to tie this to the rotation of the Follow component (the head of the avatar). When I walk my character around, the camera can only rotate within the set Value Range angle that has it's 0 point in one absolute direction (let's say north), independent of the player's orientation. It seems to use World Orientation, but I don't know and wasn't able to find out where to change that. Does anyone know how I can change this behaviour?


Navigate UI with Dpad from Xbox controller on Mac Unity ? So, according to some documentation I found, the Xbox controller on Mac does not return Dpad presses as vertical horizontal axes As you can see, the Dpad is only recognized as buttons 5, 6, 7, and 8, and not as horizontal vertical axes. For my character's movement, I just created code that returns 1 or 1 for axis depending on the button pressed. It works perfectly fine. But then I found another problem UI navigation. I can't navigate my menus with the Dpad on Mac because the the EventSystem is expecting navigation via horizontal vertical axes, which the Dpad is not providing. Is there any way I can turn these Dpad button presses into real horizontal vertical axes in Unity's Input system? Or is there something else I can do to make UI navigation happen on a Mac, with the Dpad?


Transform.position is being changed, but character is not moving back to it when told I'm trying to make a respawn point for my car to jump back to if it presses a button. I can see, using the Print() lines, that all the variables are correct and the methods are being triggered when expected. But the car doesn't go back to the spawnpoint like I want it to. The velocity part seems to take effect and work ok, but the rotation and position part does nothing. I tried several different variations of this code (ie. GetComponent lt gt and setting a public player variable (even though I am already in the player with this script)). Like I said I tried making a public Player and setting the transform p and r on that. I also tried GetComponentByParent lt Transform gt and setting like that. I've tried a few other variations of that too. And I get the same results. Here is the bit of code I think is relevant, if you actually need to see more please let me know. public void OnTriggerExit(Collider other) if (other.gameObject.tag "RespawnTrack") print("respawn point added upon Trigger Exit") recordedTransformAtRespawnTrack transform recordedVelocityAtRespawnTrack rb.velocity 0.25f print("rotation was X,Y,Z " recordedTransformAtRespawnTrack.rotation.x " , " recordedTransformAtRespawnTrack.rotation.y " , " recordedTransformAtRespawnTrack.rotation.z) print("position was X,Y,Z " recordedTransformAtRespawnTrack.position.x " , " recordedTransformAtRespawnTrack.position.y " , " recordedTransformAtRespawnTrack.position.z) public void CheckToRespawnCar() if (isRacing) if (CrossPlatformInputManager.GetButtonDown("Jump")) print("RESPAWN TRIGGERED BY PRESSING BUTTON") transform.position recordedTransformAtRespawnTrack.position transform.rotation recordedTransformAtRespawnTrack.rotation rb.velocity recordedVelocityAtRespawnTrack


On changing a voxel, don't recombine everything again, only modify the changed parts? I'm working on a voxel based game, where destructible structures are made out of cubes. (Some of them has 3000 voxels) I solved the framerate issues by combining them, but after making it able to handle multiple materials, calling the method causes a framerate drop. And it's annoying during runtime, because currently it recombines the whole structure when a voxel is changed (changed material, destroyed voxel, etc). One plan of mine is to decomposite the structures into smaller chunks, and only recombine the affected chunks instead of the whole structure. This increases drawcalls, but decreases framerate drops. By finding a good chunk size and chunk "making" heuristic, it would work I think. My other plan is to modify the combined mesh based on the affected voxels. For example when a voxel is destroyed, find its vertices in the combined mesh, and remove them. Or change those faces' material, etc. But I don't know how to do this. The bottleneck of my mesh combining algorithm is this private static Mesh CombineMeshes(MeshFilter meshFilters, List lt Material gt materials) Each material will have a mesh for it. var subMeshes new List lt Mesh gt () foreach (var material in materials) Make a combiner for each (sub)mesh that is mapped to the right material. var combiners new List lt CombineInstance gt () foreach (var meshFilter in meshFilters) The filter doesn't know what materials are involved, get the renderer. var renderer meshFilter.GetComponent lt MeshRenderer gt () lt (Easy optimization is possible here, give it a try!) Let's see if their materials are the one we want right now. var sharedMaterials renderer.sharedMaterials for (int i 0 i lt sharedMaterials.Length i ) var sharedMaterial sharedMaterials i if (sharedMaterial ! material sharedMaterial null) continue This submesh is the material we're looking for right now. CombineInstance ci new CombineInstance() ci.mesh meshFilter.sharedMesh ci.subMeshIndex 0 With zero it works with "i", every voxel in the structure will have every damagelayer. ci.transform meshFilter.transform.localToWorldMatrix combiners.Add(ci) Flatten into a single mesh. var mesh new Mesh() mesh.indexFormat UnityEngine.Rendering.IndexFormat.UInt32 mesh.CombineMeshes(combiners.ToArray(), true) subMeshes.Add(mesh) foreach (var meshFilter in meshFilters) meshFilter.GetComponent lt MeshRenderer gt ().enabled false The final mesh combine all the material specific meshes as independent submeshes. var finalCombiners new List lt CombineInstance gt () foreach (var mesh in subMeshes) CombineInstance ci new CombineInstance() ci.mesh mesh ci.subMeshIndex 0 ci.transform Matrix4x4.identity finalCombiners.Add(ci) var finalMesh new Mesh() finalMesh.indexFormat UnityEngine.Rendering.IndexFormat.UInt32 finalMesh.CombineMeshes(finalCombiners.ToArray(), false) return finalMesh Could you recommend something? Thanks!


Update dependent values of Serializable C classes on Inspector I have some data types' properties that depend on the input given into other attributes, but I haven't found in the Unity's API an elegant way to update them automagically on the Inspector. As an example, let's say I have a struct that has a divider value. Since I want to save division computations, I also have on the class a multiplicative inverse value that depends on the divider's, so I'd rather multiply instead of dividing. Example Code Snippet Serializable public struct SomeNumbers SerializeField private float divider private float multiplicativeInverse When the divider is set, the multiplicative inverse is also set. public float Divider get return divider set divider value multiplicativeInverse (1f divider) public float MultiplicativeInverse get return multiplicativeInverse private set multiplicativeInverse value Constructor. public SomeNumbers(float divider) this() Divider divider public class ExampleScript MonoBehaviour public float value public SomeNumbers numbers void Update() float result (value numbers.MultiplicativeInverse) Instead of (value numbers.divider)... Debug.Log("Result " result.ToString()) What I'd like, is that each time I change the divider's field, the value under the hood (this case the multiplicative inverse) also gets changed, as if I used the Divider's setter. Since the idea is to have an independent data type, the approach of using OnValidate on a class that contains this struct would not be applicable, since that would be a hard case. I could also set the Divider's setter on each class at Start Awake do that for me, but that would be prone to be forgotten. I know about Property Drawers , but I am not sure if that would be the right approach. I hope the question was clear enough, if not make me know so I correct it. Thanks in advance.


Need an option to send camera output as video or frames in Unity3d 2017 Tools I've used in Unity 5.x are breaking my 2017 scene... and I do not see a way to output video or frames from Cinemachine (although I am trying to understand all of its features). What is the best way in a mandatory C Unity 2017 workflow to capture camera output within Unity not a screen grab? No postprocessing needed... just frames! In the past I have used Renderator Pro and VR Rocks, neither of which seem at the moment to support 2017 using deprecated code. SOLUTION ROCK VR Does indeed work with Unity 2017... although not exactly the way I have modified it for 5.x.... but going back to stock import of resources and rebuilding works well.


How to check if grounded with rigidbody Does anyone have a better way to make an object with a rigidbody check for ground and then jump, right now I wrote a script where a raycast is cast downwards and it checks for distance but then I discovered that a player can still jump when close to the ground and when I decrease the distance amount on raycast then the jumping works a few times (5 or 6) and then stops working, so I had to increase the distance a bit and add a delay so the player can't jump for some time after a jump. But I think there might be a better way of doing it. So does anyone have suggestions on how can I improve my script or what other method I can use to make a character with a rigidbody to check if grounded and jump?


Controlling noise density I'm trying to fake terrain blending by using an opacity mask on my road mesh to reveal the grass underneath. I'm currently multiplying some Perlin noise by a Rectangle node displaying my texture at 80 width which is giving me the following Obviously this doesn't look great for reasons that should be apparent. The blotches are unnaturally spaced and they abruptly end with a sharp line at the end of the texture. What I would like to do is generate noise that looks more along the lines of this Is there a way to apply some sort of gradient to my noise to achieve this? I know I can just use the texture itself but I would like to be able to adjust properties like the extent of the noise during runtime.


Import blender camera with key frames to unity? I am wondering if I can take a camera tracked camera from blender and import it into unity. Is there any way to do this? Please let me know! Thanks in advance.


Unity order issue with TilemapRenderer.Render I'm using unity, with 2D Tilemaps (I'm doing something like an RPG) I want to have a Tile which should be rendered with a random sprite. When I use a tile like a tree that is bigger than the tile size and RandomTile, the draw order seems to get confused. Even if the sort order on the Tilemap Renderer is set appropriately, some of the tiles are drawing on top of the other tiles with no consistent pattern. After stepping through with the Frame Debugger, it looks like all tiles with the same sprite are drawn at the same Draw Dynamic event under TilemapRenderer.Render. I'm using the following script using System using System.Collections using System.Collections.Generic if UNITY EDITOR using UnityEditor endif using UnityEngine namespace UnityEngine.Tilemaps Serializable public class RandomTile Tile SerializeField public Sprite m Sprites public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData) base.GetTileData(location, tileMap, ref tileData) if ((m Sprites ! null) amp amp (m Sprites.Length gt 0)) long hash location.x hash (hash 0xabcd1234) (hash lt lt 15) hash (hash 0x0987efab) (hash gt gt 11) hash location.y hash (hash 0x46ac12fd) (hash lt lt 7) hash (hash 0xbe9730af) (hash lt lt 11) Random.InitState((int)hash) tileData.sprite m Sprites (int) (m Sprites.Length Random.value) if UNITY EDITOR MenuItem("Assets Create Random Tile") public static void CreateRandomTile() string path EditorUtility.SaveFilePanelInProject("Save Random Tile", "New Random Tile", "asset", "Save Random Tile", "Assets") if (path "") return AssetDatabase.CreateAsset(ScriptableObject.CreateInstance lt RandomTile gt (), path) endif if UNITY EDITOR CustomEditor(typeof(RandomTile)) public class RandomTileEditor Editor private RandomTile tile get return (target as RandomTile) public override void OnInspectorGUI() EditorGUI.BeginChangeCheck() int count EditorGUILayout.DelayedIntField("Number of Sprites", tile.m Sprites ! null ? tile.m Sprites.Length 0) if (count lt 0) count 0 if (tile.m Sprites null tile.m Sprites.Length ! count) Array.Resize lt Sprite gt (ref tile.m Sprites, count) if (count 0) return EditorGUILayout.LabelField("Place random sprites.") EditorGUILayout.Space() for (int i 0 i lt count i ) tile.m Sprites i (Sprite) EditorGUILayout.ObjectField("Sprite " (i 1), tile.m Sprites i , typeof(Sprite), false, null) if (EditorGUI.EndChangeCheck()) EditorUtility.SetDirty(tile) endif Is there any way to fix it?


Having the same camera in all scenes I have 100 scenes, each scene has a camera, but I want only the camera from scene 1 to exist in each scene that I appear in. I use the function DontDestroyOnLoad() to make the camera exist in each scene but I always find my self with another camera that I don't want. Any ideas? thank you in advance.


Visual Studio not recognizing Unity's new Input system I'm attempting to learn Unity's new input system, but when I try to add using UnityEngine.InputSystem to my code it gets a red squiggly line under it. It doesn't cause any compiler errors, but it's very annoying. How do I get Visual Studio to recognize this so Intellisense will work again?


How can I turn off the sound from another scene? I attached music file to my first scene and thanks to following javascipt code, sound continues without stopping in other scenes. public static var object SingletonMusic null function Awake() if( object null ) object this DontDestroyOnLoad(this) else if( this ! object ) Destroy( gameObject ) My problem is that I want to turn off the sound from the button in the another scene (setting scene) so that I added a new button to my setting scene and attached the following javascript code to the button that I have created. Javascript code var objects AudioSource SingletonMusic.object.GetComponent(AudioSource) if( objects.isPlaying ) objects.Pause() else objects.Play() However, it gives following errors If I start the game from Setting scene I get this error If I start the game from first scene and then, go to Setting scene I get this error


How to manage ammo when firing and reloading I have this script and I need to fix one thing which is count correctly the number of bullets I have. public GameObject ebullet public Transform Bullet position, target public int ammo 200 public int ammo Hold 600 public bool reload false public bool readyToShoot Update is called once per frame void Update() if (ammo 0) ammo Hold ammo Hold 200 ammo 200 if (reload true amp amp ammo Hold gt 0) ammo Hold ammo Hold ammo reload false if (readyToShoot true) Quaternion rotation Quaternion.LookRotation(target.position transform.position) transform.rotation Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime 5.0f) GameObject bullets Instantiate(ebullet) as GameObject bullets.transform.position Bullet position.transform.position 1 Rigidbody rb bullets.GetComponent lt Rigidbody gt () rb.velocity transform.forward 100 Destroy(bullets, 2f) ammo else print("Don't Shoot") end update


How can I load multiple scenes in background? I want to queue the loading of multiple scenes in background and show all of them at the same time when all complete their loading. The only idea I have by reading the docs is to root all objects in every scene I want to load this way in a single GameObject that is disabled by default and when all my LoadSceneAsync finishes its work, I can them activate each scene root GameObject. Without doing that, I have all related scenes being loaded and being showed in the screen at different times and this is just not acceptable. I'm creating this question because I believe there must be a better way to accomplish that rather than rooting all the scene into a single game object.


.blend scenes are not showing texture in Unity I am new to Unity and Blender. I am getting a problem when importing .blend files into Unity in Unity scenes the textures created in Blender are not showing. But there are no problems with color. How can I fix this problem?


How to draw a NavMesh Path to a destination without traversing the path in Unity3d? I have a set of pre determined destinations. When the user chooses any one of those destinations, the path to the destination should be drawn, similiar to google maps. I am trying to do this in unity, but not able to figure out just how.


gpu rotate a texture2d or rendertexture How does one gpu rotate a Texture2D or RenderTexture using Unity c ? Or, is that possible? I think it might be something like this... I'm also trying to understand how gpu scale seems to work here? Internal unility that renders the source texture into the RTT the scaling method itself. static void gpu scale(Texture2D src, int width, int height, FilterMode fmode FilterMode.Trilinear) We need the source texture in VRAM because we render with it src.filterMode fmode src.Apply(true) Using RTT for best quality and performance. Thanks, Unity 5 RenderTexture rtt new RenderTexture(width, height, 32) Set the RTT in order to render to it Graphics.SetRenderTarget(rtt) Setup 2D matrix in range 0..1, so nobody needs to care about sized GL.LoadPixelMatrix(0, 1, 1, 0) Then clear amp draw the texture to fill the entire RTT. GL.Clear(true, true, new Color(0, 0, 0, 0)) Graphics.DrawTexture(new Rect(0, 0, 1, 1), src) Edit The input image is rotated 90 degrees ccw to fit in the left part (replacing the beige with pink dots) of this texture (no alpha is needed). If you want some numbers, it's a rect from 0,0 to new Vector2(794, 1024)


CS0118 framerate is a field but a type was expected I'm making a mobile game in Unity and I'm trying to write a script that will set the game to either 30 or 60 frames per second based on a public bool, but I am getting error CS0118 on line 12 with fps.framerate is a 'field' but a 'type' was expected. I am pretty new to Unity so I need help with this? using System.Collections using System.Collections.Generic using UnityEngine public class fps MonoBehaviour public fps framerate Use this for initialization void Start () framerate GameObject.Find("gameSettings").GetComponent lt framerate gt () lt error CS0118 if (framerate true) Application.targetFrameRate 60 else Application.targetFrameRate 30


Is it possible to import UV maps in Unity3D without manually importing the associated texture? When i import an object from Maya with a defined UV map i have to manually import the texture (image) and assign it to the material. Is there a way to keep the materials texture reference from Maya when importing into Unity?


Develop a Wii U game without official dev kit I was looking for unity for Wii U game development. But it seems that I need the approval of Nintendo to have the software (and special hardware) (ref https wiiu developers.nintendo.com). Is there a way to have the software and to replace the hard with an emulator ? I just want to make a game for fun, I can't afford the official SDK (Rumors says it about 5000) If it is possible, I would love to have some ressources (I couldn't find anything...) Thanks )


Bad quality of the sprite in Unity I need to import a few sprites (background platform and sky) into my game scene but it seems that their quality after importing into Unity is too bad (they are blurred). The original resolution of this two images is big enough (2048 X 400 for background) and they are looking very nice in standard Windows image viewer. Here are the settings for these two textures maxSize 2048 Format truecolor TextureType Sprite(2d) nGUI FilterMode point I am using Unity2D 4.5 Target resolution of my project is 1280 800. Can anyone help me to solve these problem? As you can see the grass on foreground looks very bloory (1 picture) Texture settings (2 picture) Original image (3 picture)


Move car at same speed I want to move car on each game play run with same speed. At present I was getting each time different velocity. I want to fix that. Here is game play area on which I was moving car At present I was moving car in infinite motion without any kind of control. When it collide with wall, it will its direction based on collision calculation. Here is my source code that I was using to move car void Start () direction new Vector2 (Random.Range ( 1f, 1f), Random.Range ( 1f, 1f)) void FixedUpdate () float angle Mathf.Atan2 (direction.y, direction.x) Mathf.Rad2Deg float targetRot Mathf.LerpAngle (myRigidbody.rotation, (angle 90f), 0.1f) myRigidbody.MoveRotation (targetRot) myRigidbody.velocity direction speed myRigidbody.MovePosition (myRigidbody.position direction Time.deltaTime speed) Debug.Log("vel mag " myRigidbody.velocity.magnitude) void OnCollisionEnter2D (Collision2D other) ContactPoint2D contact contact other.contacts 0 direction 2 (Vector3.Dot(direction, Vector3.Normalize(contact.normal))) Vector3.Normalize(contact.normal) direction Following formula v' 2 (v . n) n v direction 1 Dont know why I had to multiply by 1 but it's inversed otherwisae Vector2 reflectedVelocity Vector2.Reflect(direction, contact.normal) direction reflectedVelocity At present on each run of car, I was getting different velocity that I have checked via debug statement. So my target is to move car with same speed always.


How to change transform.position code to Rigidbody.AddForce? Vector2 vec new Vector2(horizontal, vertical) vec Vector2.ClampMagnitude(vec, 1) Vector3 camF cam.transform.forward Vector3 camR cam.transform.right camF.y 0 camR.y 0 camF camF.normalized camR camR.normalized transform.position (camF vec.y camR vec.x) Time.deltaTime MoveSpeed That's how i do my movement, but i need to change it to Rigidbody.AddForce 'cause the way that i use right now makes my character doesn't collide with objects perfectly. Note What i mean with "perfectly" is, if you walk to the corner of walls, you can pass through it and that's the thing that i want to prevent.


Stuttering movement when approaching boundary I'm trying to limit my movement in the y axis by checking if the position will be within the boundaries after the Translate. If it is, only then do I translate the Player. public class Player MonoBehaviour private float speed 5.0f private float bottomY 4.37f void Start () transform.position new Vector3(0, 4, 0) void Update () Movement() void Movement () vertical movement Vector3 yTranslateVector Vector3.up Input.GetAxis("Vertical") speed Time.deltaTime float newYPos (transform.position yTranslateVector).y if (newYPos gt bottomY amp amp newYPos lt 0) transform.Translate(yTranslateVector) horizontal movement Vector3 xTranslateVector Vector3.right Input.GetAxis("Horizontal") speed Time.deltaTime transform.Translate(xTranslateVector) However, when I do this, the Player kind of pauses when approaching the boundary and then stutters forward towards the absolute limit upon releasing the key. I tried putting the Movement function in the Update and FixedUpdate method, but neither made any difference. Can anyone give me any insight into this?


Canvas not visible in my GearVR Project with Vuforia (Unity) I created a simple AR project with vuforia and my Samsung GearVR, like described here https developer.vuforia.com library articles Solution Integrating Gear VR and the AR VR Sample in Unity 5 3 and above . This works fine so far. Now I want to add some canvas elements, I don't want them to move, just fixed canvas elements. I tried to place my canvas on different positions in the scene Root Child of CameraRig Child of LeftCamera Child of TrackableParent Child of an ImageTarget in TrackableParent But for all of these cases the canvas is not visible. I know, this question is really specific, but maybe someone with knowledge in this specific thing can help me. This is my Canvas


Which size do I need to use in Blender to import to Unity I want to create a cube with different textures in Blender. But if I import the model to Unity 2017 the cube has not the same size as a cube with scale x,y and z 1 from Unity's default components. Which size do I need for my cube in Blender so it has the same size as a default cube in Unity?


Unity Tilemap one way collisions How can we get one way collisions using Tilemaps in Unity? There doesn't seem to be much online regarding this topic yet. From this link https answers.unity.com questions 1471156 how to make one way platforms using a tilemap.html, I got that we should use a Tilemap Collider 2D for collisions and not use a Composite Collider 2D. Finally, we need a Platform Effector 2D with One Way enabled. However, the resulting tiles all behave like normal tiles in that collisions occur along all edges. Here's what the inspector looks like for the tile map in question. The scene setup looks like this It looks like the tiles in the scene all have collision edges all the way around. What needs to be done to allow for one way platforms? Thanks! EDIT Here is the setup of the character Here is a view of what it looks like in game When jumping, the character unfortunately collides with the block above and is unable to pass through.


Drawing a dynamic indicator for a field of view My goal is to draw a dynamic indicator for a cube, which represents the field of view. The ideal indicator would look the same as in Metal Gear Solid(the blue ones) From what I have gathered, I need an angle and a length for the indicator as such for a 50 FoV Now my issue is what method should I use to draw the indicator? A procedural mesh or is there a less demanding way of doing this?


Unity HDRP transparent material back face rendering front face culling I try to render an object with 2 different transparent materials. One should only render the back faces (higher opacity more color) and one only the front faces (lower opacity less color). The purpose is to show another object inside the mesh better, while keeping the more saturated color on the back faces. I tried to only render the back faces using a shader graph, but it seems to be impossible to only render back faces with TRANSPARENT material. With opaque materials, it was not a problem to isolate the back faces. Is there a way to only render back faces of a transparent material, and overlap them with another material that only renders front faces? (btw. this is the model, I need it for. The bones should pretty much preserve their details color, while the jello is a rich green (screenshot from blender)) Any help is very appreciated! Thank you!


Unity or MonoTouch with XNATouch MonoGame? same price After figuring out the pricing of monoTouch and Unity, I've found that the pricing will be the same ( 800). With XnaTouch MonoGame for monoTouch I am able to port my games to droid apple. I am just curious if anyone has tried both XnaTouch and Unity and which one they prefer. I do mostly 2D games (if Unity had a 2d Engine I would be all over that) so xnaTouch seems that it might be better, but Unity seems better for more advance professional (more companies are using it, so if I ever wanted to do this for more than just myself I have more options, which I've thought about) (I also read somewhere that monoTouch is against the new apple term of agreement?)


How to rotate a 3D character on top of a plane with an isometric picture on it How to calculate the angles of the 3d charater so that it fits into the isometric environment projektet on a 2d plane? Also, how do you calculate the rotation of my character? What I want to achieve Describing the scenario


Level Selector with possible future levels? Unity I have a level select screen which is a simple grid layout of my levels. The level data comes from a scriptable object for each level. The problem I have is what is the best method for populating the grid of levels that use the scriptable object and is able to add more levels to the grid layout if let's say I add an asset bundle in the future? My thought was that I use a levelDB which holds a list of all of the scriptable objects. Then when an asset bundle is used then it adds the content to the levelDB. The UI would then just use this levelDB to populate the screen. NOTE I have very little to no knowledge of how asset bundles work and what you can, and cannot do with them.


How to decompose a 4x4 TRS transformation matrix with negative scale? As the title says I need to decompose 4x4 TRS transformation matrices and extract the proper scale vectors and the proper rotation vectors (or rotation quaternions). I know how to extract those information when the upper 3x3 matrix determinant is not negative. The problem is that those matrices can have that negative determinant and as far as I could understand, this negative determinant indicates a flip or mirrored transformation. What do I have to do to extract the proper values for scale and rotation in those cases?


Render problems (black, purple and blue effects) in old GPU and Unity3D 5.6 project on Unity 2018 Well, I have a PC that has a GPU from 2009, and now I have some problems with a fork. The project was on Unity 5 (2015) and I have upgraded it to Unity 2018.1.0, without any problems. But some times, when I updated scripts or changed something in the scene the problem appeared. Is a rendering problem that only occurs in DirectX 10 (my GPU is a GeForce 9600 that supports up to DX 9.0c, so I don't underatand how this is capable of running DX 10). Because, if I run with force opengl all runs fine. I can go back, but the problem is in the Library folder, because if I use "Assets Reimport all" or I remove this folder, the problem dissapeared (before, not now). This is the problem https i.gyazo.com eb9199b8590fddf416a8323331e20856.mp4 Researching I have worsened it https i.gyazo.com dbc5d5f19a845ec77e54d64e3cba85cc.mp4 https i.gyazo.com 939c8fdf5fd4d68e434958e93e68da14.mp4 As you can see, sometimes the problem is blue and purple, and other times is completely black. The last problem remembers me to https forum.unity.com threads black textures on some devices android versions.195328 I have builded the project and there isn't any problem, so the problem is somewhere in the Editor or with a UNITY EDITOR preprocessor directive. I don't know what I have to do to fix this. Is like this is very random. Any help?


Shadow Glitch on Mesh Stitches I use LWRP, one Directional Light and Hard Shadows with 1024 resolution. When I imported this super simple mesh from blender this happened What is this weird line on the stitch of the mesh and how do I fix it? I tried using Soft Shadows with higher quality but it did not help.


URP PostProcessing doesn't work? I'm trying to get postprocessing work again after updated to URP. But it does not work !! Could anyone help me with any solution or clue ?


UI and line renderer layer order when using screen space camera I'm using a canvas with screen space camera because I needed a line renderer that could work for my UI. However, I need that line to render behind Image elements on my canvas and I'm not seeing any way to accomplish that. Every UI element on my canvas behaves like its z 90 and "order in layer" 0 but those aren't really configurable values for a UI object. My line renderer, if z 90, must have a layer order 0, or a z value lt 90. In both cases, it shows on top of my UI. I essentially have a canvas with a background image, which must be behind everything else, a line renderer (used to connect "dots"), and circle shaped Images which must be on top. Here's my hierarchy Canvas Background (Panel, no image, color) GameBoard LineRenderer (Layer default, order 0) Circle Clone(1) Circle Clone(2) etc... What's bizarre is that if I turned off (active false) the Background object, and my LineRenderer is z 90, order 0, it works fine. It appears behind my UI elements correctly. Yet if this object is active, my LineRenderer appears on top of of the elements, despite no z order changes.


Increasing spawn difficulty I'm trying to increase the difficulty of the game over time. I'm using InvokeRepeating to spawn enemies and in the update function I calculate the next spawn time using the following code public Vector2 secondsBetweenSpawnsMinMax float nextSpawnTime void Update() if (Time.deltaTime gt nextSpawnTime) float secondsBetweenSpawns Mathf.Lerp(secondsBetweenSpawnsMinMax.y, secondsBetweenSpawnsMinMax.x, Mathf.Clamp01(Time.time 60)) nextSpawnTime Time.deltaTime secondsBetweenSpawns public void StartNewGame() InvokeRepeating("Spawn", 0.1f, nextSpawnTime) public void Spawn() Vector3 enemySpawnPos spawnPoint.position Instantiate(enemy, enemySpawnPos, Quaternion.identity) I'm fixing the secondsBetweenSpawnsMinMax.y to 3 and secondsBetweenSpawnsMinMax.x to 1. The issue I'm facing is that the nextSpawnTime doesn't change. It starts at 3 and stays at that value when it should go down to 1. I'm not sure what's wrong with the code here.


How do you upgrade your Unity license from Plus to Pro? If I buy a Plus license for Unity for only one month, can I upgrade that license from Plus to Pro in the next month? Or I am in am annual commitment to renew only the Plus license? If I need to upgrade from Plus license to Pro license a month after publication, what do I do?


Unity VS debugging only with UnityVS? Hi, this one thing isn't clear to me Is it possible, to debug C of Unity 4.3 with Visual Studio 2013 without any plugin? If no, what or how else should I debug then?


Unity3d Colliders not working on my characters I have create 2 characters in maya and imported them in Unity3d. I am able to move and animate them in unity but the characters are not colliding with each others. I have tried all major colliders capsule, box and mesh. I am kind of stuck in it !


How can I set the radius the object will rotate around the target? using System.Collections using System.Collections.Generic using UnityEngine public class TargetBehaviour MonoBehaviour Add this script to Cube(2) Header("Add your turret") public GameObject Turret to get the position in worldspace to which this gameObject will rotate around. Header("The axis by which it will rotate around") public Vector3 axis by which axis it will rotate. x,y or z. Header("Angle covered per update") public float angle or the speed of rotation. public float upperLimit, lowerLimit, delay upperLimit amp lowerLimit heighest amp lowest height private float height, prevHeight, time height height it is trying to reach(randomly generated) prevHeight stores last value of height delay in radomness Update is called once per frame void Update() Gets the position of your 'Turret' and rotates this gameObject around it by the 'axis' provided at speed 'angle' in degrees per update transform.RotateAround(Turret.transform.position, axis.normalized, angle) time Time.deltaTime Sets value of 'height' randomly within 'upperLimit' amp 'lowerLimit' after delay if (time gt delay) prevHeight height height Random.Range(lowerLimit, upperLimit) time 0 Mathf.Lerp changes height from 'prevHeight' to 'height' gradually (smooth transition) transform.position new Vector3(transform.position.x, Mathf.Lerp(prevHeight, height, time), transform.position.z) Now it's rotating in a constant radius. I set the variable axis to 0,1,0 But if I want the object to rotate around the turret very close to it or very far ? I want to add a radius variable so I can change and set the radius.


How to check metadata stored in FBX files? Is there a way to check and edit metadata information stored in FBX files? I'm using 3ds Max's fbx exporter. Can this be done with it or is there any other tool for that? For example adding name, contact info, tags or anything that provides ownership of the file.


Unity3d "random" transform position values on editor Run into some strange behavior on editor position values. https youtu.be DUBpbOUkbfo As you can see we have two cube object with colliders on both and rigidbody on parent. After start play mode parent object editor values sets to some random numbers while transform.localPosition and transform.position is still (0,0,0). This somehow related to parent child physics hierarchy but can't understand how.


Move enemies over the network without sending their positions I am trying to move enemies on two clients without sharing their positions. I use this startingPosition GetRandomDir() Random.Range(1f, 10f) To have the same movement on clients and server, I set the same seed to get the same directions with Unity Random. I set it with the system datetime now ticks on server and clients Random.InitState(newTicks) I am getting the same movements on the server and on the clients until a enemy starts looking for a player and chasing that player. When this happens, the enemy on one client is not at the same position on the other client. One enemy is targeting a player on one client, but on the other client he hasn't targeted that player yet. The enemy keeps wandering creating a different position on one client than on the server or other clients for example. Is there a better way to synchronize the enemy movement ? My idea was not to send the positions of the enemies from the server to the clients but rather have the clients move their enemies themselves. I would also like to know what to search for on Google to get help with this problem networking ai movement doesn't help, synchronize movement over the network without sending position does not return the results I would like either. What I think is strange and I don't understand is that the same code is executed on both the client and the server. The players and the enemies are at the same positions. Yet the enemy will choose to chase a player on the server and not to chase a player on the client. Resulting on the client to view the enemy at a different position than the position of the enemy on the server.


Is there a way to use the UnityEngine.UI with SteamVR and the Vive? I recently got into developing VR games using the Vive as my standard platform. Now I would like to design some UnityEngine.UI elements that would be interactable via the built in pointer scripts that come with the SteamVR module from the Unity Asset Store. However, I can't seem to find any kind of built in method for allowing interaction between the pointers and buttons, scroll bars, etc. I have also been unable to write anything myself that would do the trick, it's almost as if the Unity UI is just not designed to interact in a VR environment at all. Does anyone have a method for using the UnityEngine.UI in a VR environment? If so, can you please point me in the right direction?


Unity Seamless Terrain I am programmatically generating terrain using unity's terrain object and assigning height maps to it via the terrainData, the problem is that there are seams even when using the GroupingId(which is used for auto connect). I even tried creating a terrain object in the editor with neighbours, and modified their terrain data via script, seams still there. I have also tried SetConnectivityDirty after applying terrainData. Most people who have reported this seemed(lol) to have issues with their normals at the edges, I cant see that being the issue here, but if it is, how do i approach solving it given I am using unity terrains. If there is no good answer I will have to resort to custom meshes and lose all the nice terrain tool functionality. Edit Here is how I'm setting heights. var terrain GameObject.Find("test").GetComponent lt Terrain gt () var terrainData terrain.terrainData var noiseMap Tool Generators.GenerateNoiseMap(chunkSize, seed, scale, octaves, persistance, lacunarity, 0f, 0f) terrainData.SetHeights(0, 0, noiseMap) Then the actual noise generation is just a 2D array of heights, i have been using a simplified version with only 1 pass for testing. public static float , GenerateNoiseMap(int chunkSize, int seed, float scale, int octaves, float persistance, float lacunarity, float offsetX, float offsetY) float , noiseMap new float chunkSize, chunkSize for (int y 0 y lt chunkSize y ) for (int x 0 x lt chunkSize x ) float noiseHeight 0 float sampleX (x offsetX) scale float sampleY (y offsetY) scale noiseHeight Mathf.PerlinNoise(sampleX, sampleY) noiseMap y, x noiseHeight return noiseMap


Is Update() called on the very first frame in Unity? I'm calling Time.frameCount inside Update() and then immediately Debug.Break() to pause the simulation before Update() is finished. This of course happens (supposedly) on the very first frame, and yet Time.frameCount returns 1, as if one frame had already been rendered by at that point. Also, I'm calling Time.deltaTime the same way, on the first frame inside Update(), and it returns a value too, as if a previous frame had been rendered and took X milliseconds. Considering Time.deltaTime returns the value of the "time it took to complete the last frame", and I'm calling it on the first frame and it's returning a value, is there an "invisible" first frame that Update() doesn't run on? I couldn't find any reference to this specific issue on the Unity docs.


Unity Best Practise to apply Uniform Acceleration (regardless of direction) I have read a lot of other topics both on here, on the Unity forums and from Google searches that answer thing that are similar but not quite the same as my question. My question I have a Unity project with a sphere, the sphere starts at a certain initial speed and I want the sphere to accelerate uniformly over time to reach its maximum speed, regardless of bounces and interactions. Obviously an interaction will cause the Velocity to change, but I don't want the Speed to change. I started off looking for a speed LERP, but come up with the below code. I have negated and turned off all drag and friction settings on the gameobject. My current code is thus (C ) using UnityEngine using System.Collections public class Ball MonoBehaviour public float accelerationSpeed 10f public float maximumSpeed 25f public float initialSpeed 10f private Rigidbody rb private bool ballInPlay false Use this for initialization void Awake () rb gameObject.GetComponent lt Rigidbody gt () ...other functions that don't relate to this question... void FixedUpdate () Gradually increase ball speed if (ballInPlay true amp amp rb.velocity.magnitude lt maximumSpeed) rb.AddForce(rb.velocity.normalized accelerationSpeed, ForceMode.Acceleration) This code takes 3 4 seconds to accelerate the ball up to the maximum speed, and it seems to adequately bounce the ball off rigidbodies, as I want. However, I will in time be having more things interacting with the ball including explosions and other actual Force values (such as Wind), so taking this into account is this code the best way of applying a constant acceleration to a game object, regardless of its other behaviours and influences? While the above may work I'm also looking for best practise as far as possible (and memory processor efficiency if that's applicable). While obviously there are going to be unknowns (as it's excessive to show you my whole project, just for this qustion), some guidance on best methods of approach to solving this as well as improving efficiency would be appreciated. Many Thanks. EDIT To clarify my exact question Is the code above best practise when applying uniform acceleration to the gameobject while dealing with the influence of additional Rigidbody.AddForce functions on the gameobject.


Math question How to move extrude a cube's face in Unity? The short question is What's the math to move the face of a cube? I.e. how to stretch (or shrink) a cube in the direction of one of its faces? Here's a picture The camera shows a cube (left). When the user clicks and drags on one of the faces (yellow), the face (it's vertices) should follow the mouse and as a result expand (or shrink) the cube in the given direction (like the right cuboid in the picture above). Please note that this should be done ingame, by moving the vertices, not by scaling the object. Now, I already have the selected face and all the vertices of its four corners. Further, the distance how far it should be moved is also known. The question is, what needs to be done with the vertices to pull the face out (or push it in)? Whats the math? Your help is very much welcome. Thank you.


Navigate UI with Dpad from Xbox controller on Mac Unity ? So, according to some documentation I found, the Xbox controller on Mac does not return Dpad presses as vertical horizontal axes As you can see, the Dpad is only recognized as buttons 5, 6, 7, and 8, and not as horizontal vertical axes. For my character's movement, I just created code that returns 1 or 1 for axis depending on the button pressed. It works perfectly fine. But then I found another problem UI navigation. I can't navigate my menus with the Dpad on Mac because the the EventSystem is expecting navigation via horizontal vertical axes, which the Dpad is not providing. Is there any way I can turn these Dpad button presses into real horizontal vertical axes in Unity's Input system? Or is there something else I can do to make UI navigation happen on a Mac, with the Dpad?


How can I search for players in the same wifi in Unity? I am creating a game in Unity and I would like to create an ability for players to join the game that others have created on the same wifi. I would like it to be as effortless as possible(e.g. players don't have to find out their wifi, etc). The game is cross platform you could have one player on PC, other on Android device, etc. Now I know that there is a game that has similar mechanism to what I would like to achieve SpaceTeam. Basically you select whether you use BT or wifi, and wait for other players to join. How can I do this in Unity, or something similar that satisfies my needs?


Help with 3D Double Jumping in Unity I'm having some trouble with vertical movement. I'm trying to add double jumping but none of the scenarios online seem to be working, and I can only ever manage to get a single jump. Here's my code using UnityEngine using System.Collections public class Moving MonoBehaviour public float speed CharacterController controller public float speed 6.0F public float jumpSpeed 8.0F public float gravity 20.0F public bool candoublejump true public int jumptime 0 private Vector3 moveDirection Vector3.zero Use this for initialization void Start () controller GetComponent lt CharacterController gt () void FixedUpdate() if (controller.isGrounded) moveDirection new Vector3 (Input.GetAxis ("Horizontal") 2000, 0, Input.GetAxis ("Vertical") 2000) moveDirection transform.TransformDirection (moveDirection) moveDirection speed if (Input.GetButton ("Jump")) if (controller.isGrounded) moveDirection.y 0 moveDirection.y jumpSpeed candoublejump true else if (candoublejump) candoublejump false moveDirection.y jumpSpeed moveDirection.y gravity Time.deltaTime controller.Move(moveDirection Time.deltaTime) Is there something wrong with my keyboard maybe? My theory is that it's checking for the double jump in the split second after you did the first one, which isn't helpful because you're still holding the jump button.


Serialize classes in unity c Is there some best practices to serialize objects to file on mobile devices in Unity using C . I've tried to search it myself, but found only this link. However, it looks like here they are trying to cache AssetBundles. I'm new to Unity, but I have some experience in iOS (swift) development. Here we have opportunity to cache some objects(variables) in local storage, to avoid overusing network. So I wanted to create some static class (for example Storage), which caches variables to file permanently and return them by some key.


Unity Creating a panel that stretches using anchors Relative newbie to Unity so please excuse any oversights. I have a component (canvas panel) that I'm wanting to add a panel to, so that when the parent component's height changes, the child panel's height changes to match. I've achieved this manually using the inspector (see top half of attached pic) to set the anchor points at min(0.5, 0) and max(0.5, 1) (pivot is unchanged at (0.5,0.5)). I want to create that stretching panel in scripting, and have the following code that results in the bottom half of the attached pic where the rect transform's anchors aren't set at all. GameObject panel2 GameObject.Find("Panel2") GameObject divider new GameObject("RunTimeLine") divider.layer LayerMask.NameToLayer("UI") divider.transform.SetParent(panel2.transform) CanvasRenderer c divider.AddComponent lt CanvasRenderer gt () RectTransform rt (RectTransform)divider.AddComponent lt RectTransform gt () Image img divider.AddComponent lt Image gt () img.color Color.red rt.localPosition new Vector2(0f, 0f) rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 20) rt.anchorMin.Set(0.5f, 0) rt.anchorMax.Set(0.5f, 1) Any suggestions? I've also tried setting the min max offsets and pivot but haven't been able to create what I've got manually in the inspector.


(2D) Detect mouse click on object with no script attached I'm creating a 2D project which does not have a character. So i created an empty gameobject and attached the script to it. In the script, i have declared other objects which are in the scene like this public GameObject obj1,obj2,obj3 How can I know if obj1 or obj2 or obj3 was clicked? Is raycasting the only solution?


Attached objects to public Text removed on play mode (Unity) As you can see when I play the game the 'touch anywhere to start' object goes away. How do I fix this? I have added all the relevant code


Adding force to a 3d object in a 2d scene I have a 3d game object placed in a 2d scene (top down view) in Unity. I want to add force to the object to move it in the direction it's facing. I attached a RigidBody2D component to it and when I use the AddForce() method, it's not working as I want it to i.e. it's moving on only one plane x or y but not in the facing direction. Please help me. Edit The game is my version of Asteroids. The ship is 3d and the asteroids are 2d. The scene is in 2d. I fixed the 'y' and 'z' rotation of the ship. Now how do I add force to the ship in the direction its facing ? The Update method void Update() float rotationInput Input.GetAxis ("Rotate") if (rotationInput ! 0) float rotationAmount RotateDegreesPerSecond Time.deltaTime if (rotationInput lt 0) rotationAmount 1 ship.transform.Rotate (Vector3.down, rotationAmount) Vector3 currentRotation ship.transform.eulerAngles currentRotation.x Mathf.Deg2Rad thrustDirection new Vector3 (Mathf.Sin(currentRotation.x) 1, Mathf.Cos(currentRotation.x), Mathf.Cos(currentRotation.x)) The FixedUpdate method void FixedUpdate() if (Input.GetAxis ("Thrust") gt 0) print (thrustDirection) ship.AddRelativeForce (ThrustForce thrustDirection, ForceMode.Force) Thanks in advance.


How to display all the previous strings except the current strings from the list? I would like to create some sort of log to display previous strings for my game, but I still cannot figure out how to properly displaying them. I am using a button to run this method every time player clicks it. public void AddLog() foreach (string logEvent in DisplayDialogueList) logTextList.text logText logText logEvent logText " n n" This method supposed to be displaying all the previous strings that has been displayed before inside DisplayDialogueList but I can't limit the displays only for the previous strings, and it will always display all the strings from the list. I have tried the .Skip method to detect the current index of the list that are currently being displayed but it does not refresh the list, meaning if I loop to skip the first index from the list, it will always skips the first index even the current index to be displayed is second index and so on. I also having trouble to skip the last index on the list since C Unity does not support .SkipLast. Any help would be appreciated. EDIT Sorry for the confusion, this is how I managed to distinguish which is the current string to be displayed, it runs on button click public void Display() Checks to see which element from the list has the same index number as the current index if((index textIndex) amp amp !(DisplayDialogueList.Count lt index)) Displays the string from the list that has passed the argument above textList.text DisplayDialogueList textIndex index 1 textIndex index Everytime the button is clicked, the index number will be increased, so it will matches with the string with the same index from the list and displays it. UPDATE Ok I managed to skip the current displayed index and last index (thanks to the answer below) but this happens apparently The Hello, my name is Mira text is in the first index of the list. How do I make sure that text won't be displayed again after the back button is clicked, which run the AddLog()? The updated code is below if(!(index gt DisplayDialogueList.Count)) firstIndex DisplayDialogueList.First() lastIndex DisplayDialogueList.Last() foreach (string logEvent in DisplayDialogueList) if(logEvent ! lastIndex amp amp !(firstIndex currentIndex)) logTextList.text logText logText logEvent logText " n n"


I am having this error in unity and i don't know what's causing it I don't know how it happen this is an endless runner game The road is 15 on x and 100 on z. This is happening in android road is a cube with png image as texture it is distorted and turn blue every 2 sec.


Unity3D position of 2D objects with size of Object I'm making a 2D project in Unity3D. I want to place an image in the right upper corner. I've got this working, but ofcourse the image is falling of the screen for a part (and completely when I change the screenrotation). This is the code I've got for it posImage new Vector2(Screen.width imgGear.transform.localScale.x, Screen.height imgGear.transform.lossyScale.y ) As you can see in the code I've tried to adapt the position with the size of the object, using localScale 1.0f and lossyscale 0.9...f doesn't really do much as it will be changed with 1 unit. Is their a way to get the real width and height of the objects?


Rotating according to ground normal on Unity 3D I know there are already some threads about this, but my problem isn't exactly with the algorithm itself. I was able to use RayCast and get the ground normal, using it to store the rotation necessary to align to the ground in a quaternion using slopeRotation Quaternion.FromToRotation (transform.up, hit.normal) Where hit.normal is the normal of the ground. After this, I check whether the player is moving (the user is moving the joystick axis) or standing still. If it's standing still, I align it with the ground using transform.rotation Quaternion.Slerp(transform.rotation,slopeRotation transform.rotation,10 Time.deltaTime) When the player is moving, I rotate using transform.rotation Quaternion.Slerp (transform.rotation,slopeRotation camRotation movementRotation , 10 Time.deltaTime) Where camRotation is simply the rotation of the MainCamera(a third person one) on the Y axis and movementRotation is the rotation of the joystick axis, also on the Y axis, calculated using movementRotation Quaternion.LookRotation (new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"))) camRotation Quaternion.Euler (0, cam.transform.rotation.eulerAngles.y, 0) Although the code above makes sense in my head, it doesn't work as expected, as seen in the picture below As you can see, it works fine when you're standing still, which means that the ground normal and the slopeRotation are correctly calculated. When the player moves though, the combination of all the quaternions seems to cause some kind of problem that makes the player slightly deviate from the correct rotation. It might be worth noting that camRotation and moveRotation also work completely fine on their own, so the player moves correctly according to both the rotation of the camera and of the joystick, both on the floor and on ramps.


What are some strategies for handling a zoomed out grid of sprites? I'm writing a grid based 2D game in Unity3D that would ideally use grid sizes of around 200x200 or so, with multiple zoom levels, including all the way out. When I tried render a 200x200 grid at the most zoomed out level where everything is visible, Unity crapped out saying that there were too many vertices to attempt to draw. This makes sense, as it's trying to render 40,000 sprites. I was wondering, how do games like Dwarf Fortress and OpenTTD manage so many sprites at once on the screen when the map is zoomed out all the way? Are there any general strategies for handling the rendering of a large number of sprites such as this?


World coordinates on vertical grid game for different aspect ratios (Unity) new to game development and unity so hopefully someone can help. I want to make a 2D portrait mobile game that will have a grid of constant size where units can move on in Unity. This should support different aspect ratios. To do that I was thinking to cut sections at the top and bottom of the screen for smaller aspect ratios. Additionally, I would like the coordinate system to be natural to the grid, so coordinate (0,0) would be the bottom left tile in the grid, (1,0) would be the tile to the right of that,... To illustrate this concept I drew something quickly I tried with a script that resizes the size of the orthographic camera to fit the content horizontally. Problem I had with that is that I couldn't get a good coordinate system on the grid after the camera gets resized depending on the aspect ratio since the number of horizontal world units varies depending on the aspect ratio. Any thoughts on what would be the best way to do this? Thanks!


Switching between world and battle scene with no or minimum loading? I am making a strategy game where the player roams a grid map. When the player encounter enemy on the map he is transferred to a quot battle quot scene where two armies are fighting in turn based battle. Imagine Heroes 3 like game. My question is Should I load the battle scene in additive mode and temporary hide the quot world map quot and when the battle is finished to just show the quot world map quot and hide the quot battle quot scene? Or i should unload the world scene and load the battle scene, and when the battle is over gt unload the battle scene and load the world scene ? I think the 1st approach will give me less loading time between the two scenes, but will require more RAM ? Second approach is standard one, but i will have loading between the scenes ? My idea is to have no or minimal loading between battle and world scenes. What do you guys thing ? Did you know what is the best practice in this case ? By the way, i am using Unity as a engine.


Applying Animation to specific parts of a humanoid model I have imported a humanoid character from AutoDesk Character Generator into Unity. Once you specify that you want the character for Unity, a humanoid skeleton in integrated, in order to use MecAnim. I also have a plug in that applies the user's motion data to this character and animates it. Because the plug in is free and open source, I am trying to apply the motion data to different MecAnim bones, to see if I can do so. By the way, by "motion data" I am referring to 2 arrays one that contains positions and one that contains orientations of a number of joints and bones. So, I can access these Vector3 and Quaternion data... Is it enough to just apply, for example, the left foot's orientations to the right foot, or do I need to also do it with positions, in order to inter change the animations motions movements of these 2 limbs? This is the method I have written so far public void swapLimbsPosRot(Vector3 positionsArray, Quaternion rotationsArray) Vector3 tempPos positionsArray 16 positionsArray 16 positionsArray 20 positionsArray 20 tempPos Quaternion tempRot rotationsArray 16 rotationsArray 16 rotationsArray 20 rotationsArray 20 tempRot But it doesn't work, because when I apply it to my array of transforms before updating, severe jitters show there is a fighting going on between MecAnim and my motion capture device' incoming motion data, but for now I am just wondering If you wanted to swap the animations movements motions of 2 similar MecAnim parts, what would you do? What would you swap? How would you go about it? p.s. Of course, first I tried swapping the mecanim bones (right amp left feet) but that turned out silly, as the "actual" feet of my MecAnim character had been swapped! Some code, showing how the swapping and updating are done now, hoping someone could please help me find the cause of the jitters. void Update() Vector3 latestPositions Quaternion latestOrientations if (mvnActors.getLatestPose(out latestPositions, out latestOrientations)) If this variable is set to true, then do the swapping. if (swapLimbs) swapLimbsPosRot(latestOrientations) Update both the pose and the model, using the delayed data. updateMvnActor(currentPose, latestPositions, latestOrientations) updateModel(currentPose, targetModel) Swap the rotations of different mimicking limbs e.g. LeftHand 16 amp RightHand 20 public void swapLimbsPosRot(Quaternion rotationsArray) float tempRotY rotationsArray 16 .y rotationsArray 16 .y rotationsArray 20 .y rotationsArray 20 .y tempRotY float tempRotZ rotationsArray 16 .z rotationsArray 16 .z rotationsArray 20 .z rotationsArray 20 .z tempRotZ The motion data that comes in is always the latest positions and orientations from the device, so Update modify them and then apply them to the character to animate it. So, for example, in my Update, I get the latest pose (i.e. the latest positions and orientations) and then I swap the orientations of left and right hands, but the jitters are severe...


Distinguish between HTC Vive controller grip buttons in Unity In Unity, I can check for grip button presses via the SteamVR API like so if(controller.GetPressDown(SteamVR Controller.ButtonMask.Grip)) ... This results in either true or false so I can only check if any grip button was pressed but not specifically which one. For Unity's Input API the documentation states 1 The grip trigger differs between platforms The HTC Vive controllers each have two grip buttons but both map to the same axis. The value for these buttons is 0.0 when not pressed and 1.0 when pressed (intermediate values between 0.0 and 1.0 are not possible). Source https docs.unity3d.com Manual OpenVRControllers.html In this case it is again not possible to differ between the two grip buttons. Is there any way in Unity to check which one of the grip buttons of a HTC Vive controller is pressed?


How do I make my plane appear 3D like in the "Roll a ball" tutorial? I am following the first tutorial on the Unity website, which details making a 'Roll a ball' game. I am stuck at a point where I need to make a 3D plane object it looks flat, to me, and unlike how it looks like in the tutorial. How do I make my plane look 3D? This is what I see This is what I see in the tutorial


Change item rotation axis in inventory item visualization I'm learning unity and i'm trying now make an inventory, i made a simple interface, and now i'm trying to make a item visualization. I look for some codes from web and i found this one using UnityEngine public class TurnObject MonoBehaviour protected Vector3 posLastFame public Camera UICam Update is called once per frame void Update() if(Input.GetMouseButtonDown(0)) posLastFame Input.mousePosition if (Input.GetMouseButton(0)) var delta Input.mousePosition posLastFame posLastFame Input.mousePosition var axis Quaternion.AngleAxis( 90f, Vector3.forward) delta transform.rotation Quaternion.AngleAxis(delta.magnitude 0.1f, axis) transform.rotation I know some code, but I'm not good with geometrics. In this code when I move my mouse horizontal way, my object turn in the Y axis. And that's good. But when I move my mouse vertical the object move in the X axis instead of Z axis. Is there a way in this code for change this? I really have difficulty to understanding geometrics in Unity.


Unity using WWW to download image from web. Not working from my own website, but does from other urls I have this script attached to a RawImage file in my games UI public class DownloadImage MonoBehaviour string url "http megabrogames.rf.gd pic.jpg" string url "https i.imgur.com xBSyvRx.jpg" IEnumerator Start () WWW www new WWW(url) yield return www GetComponent lt RawImage gt ().texture www.texture Both jpg files are the same. One I uploaded to Imgur, this works. The other is on my own website. The url to my website works fine, I have checked in on two computers and several browsers. All I get is the red question mark. But if I uncomment the other one instead it all works perfectly. My problem is that I have hard coded the url into the game, and I want to change the image each week. It has to be the same URL for that to work, but i think with Imgur it will auto assign whatever url it feels like. thanks for any help


How to test if procedurally generated level for infinite runner can be passed? I have a 2D infinite runner platformer game built in Unity 5, where the level procedurally generates itself. I need to check if it is possible to pass the holes on the level. How could I do that?


How to output to the Oculus and a 2D screen? We'd like to present an Oculus game to a large group of people. Not everyone will have an Oculus headset, so we'd like to output to both the Oculus and a second display. The problem is that the project uses an Oculus plugin to render its output, so all they output is two distorted circles, which doesn't display well when not wearing the Oculus headset. I thought of making a second Unity client (the "audience" client, running on the same computer as the Oculus application) that receives the output texture of an "audience" camera from the client running the Oculus version. My question is Can I use the network to send the output of a camera to the "audience" client so I can set it up for the second display, bypassing the Oculus plugin? How would I get the input on the "audience" client to map it to the screen?


Unity3D Making timescale freeze and resume So, I'm trying to make it where when a popup(Ui panel and text) appears, the game's time(timescale) would freeze. Then when the user enters input and clicks enter button, the popup would disappear and time would resume. How could I make time follow this?


objects disappear before time I created a little pool in order to better manage my enemies, to which, an enemySpawner object calls to retrieve a clone and show it on screen public class ObjectPool MonoBehaviour public static ObjectPool current public GameObject objectForPool public int poolAmmount 20 public bool growth true List lt GameObject gt objectsForPool void Awake() current this Use this for initialization void Start () objectsForPool new List lt GameObject gt () for (int i 0 i lt poolAmmount i ) GameObject obj Instantiate(objectForPool) obj.SetActive(false) objectsForPool.Add(obj) public GameObject GetPooledObject() for (int i 0 i lt objectsForPool.Count i ) if (!objectsForPool i .activeInHierarchy) return objectsForPool i if (growth) GameObject obj Instantiate(objectForPool) objectsForPool.Add(obj) return obj return null Update is called once per frame void Update () The call(EnemySpawner update) void Update () transform.position new Vector3(transform.position.x (speed Time.deltaTime), 0, transform.position.z) if (transform.position.x lt boundary.xMin transform.position.x gt boundary.xMax) speed 1 if (Time.time gt nextSpawn) nextSpawn Time.time spawnRate GameObject clone GetComponent lt ObjectPool gt ().GetPooledObject() if (clone null clone.activeInHierarchy) return clone.GetComponent lt EnemyMovement gt ().SetPlayerShip(playerShip) clone.transform.position transform.position clone.transform.rotation transform.rotation clone.GetComponent lt Health gt ().RestoreHealth() clone.SetActive(true) The problem here is, that my enemies are being deactivated on mid trajectory https youtu.be ZGHC6wwGX1E I know my issue is in my pooling, but I can't figure out what I'm doing wrong


Renderer.material assignment not working I have a fairly simple question I am trying to change an object's material via code with the line rend.material NewMat where rend is of type Renderer (MeshRenderer to be specific) and NewMat is of type Material. Both variables are public and assigned in the inspector and both are not null. When I now try to assign the material, nothing happens. I don't event get any error. When I look into the inspector I can see that under Materials on my MeshRenderer the material doesn't even change. The line Debug.Log(rend.material NewMat) outputs false. What am I doing wrong?


Is coroutine as good as a delay() function I'm new to Unity and I was learning the usage of coroutines. Is calling a coroutine as good as a delay() function? Does Unity have a delay() function?


How to make player instantly move to the right or left when entering a box collider I have a box collider and right now when I walk into it it says "you can't go there yet" I would like it for it to also move the player like 3 steps to the right or something. How would I do thatr?


Having trouble defining a FindMyTag I'm not a coder, im an artist, so this stuff doesn't make a ton of sense to me. I know enough to know I don't know enough, and i'm old enough to know my brain doesn't 'get' code... that said for context of what level of help I need ) ... I'm trying to get an AI path based on an object tag. When I instantiate the object this script is on, it should look for 'mytag' on another object in the scene, and set that as 'target' public class pickAItarget VersionedMonoBehaviour lt summary gt The object that the AI should move to lt summary gt private Transform target public string mytag IAstarAI ai void Start() Debug.Log(GameObject.FindWithTag("mytag")) GetComponent lt pickAItarget gt ().target GameObject.FindWithTag("mytag").transform The script compiles fine and im able to put in the tag I want to find in the inspector but when the object instantiates I get UnityEngine.GameObject.FindWithTag (System.String tag) (at C buildslave unity build Runtime Export Scripting GameObject.bindings.cs 195) Pathfinding.pickAItarget.Start () (at Assets Scripts pickAItarget.cs 26) I feel like I HAVE defined mytag, but obviously I don't understand something.


How to create video from camera? I have a 3d scene and a camera I want to create video file from camera pre set movements. If it is possible, running application by command line (without needed to "show" at video, my camera) . Is it possible in Unity ? If yes what's the best approach ? Thanks


Why do my character's feet slide when I auto configure a humanoid rig in Unity3D? I've downloaded an FBX animation of someone walking from the "Walking" section here. I imported that and also a humanoid character and specified the Rig for both as Humanoid (auto create). The original animation has very solid foot placement, but whenever I apply it to any character in Unity the feet slide around as if it were walking on ice. Here is a video demonstrating my issue. Is there something about the way I am getting Unity to auto rig my character that would cause this problem? It happens no matter which 3D character I use. Thanks


Room lighting in Unity I am trying to make a plain white room in Unity. I used six planes for the walls, but I can't figure out how to get the lighting to not look so harsh and uneven. The top picture is my best attempt using two directional lights, and the bottom picture is the look that I am trying to replicate. It is from a demo scene in the Google VR SDK 1.50 for Unity. It uses only a single point light, but when I turn it off in the scene view, it doesn't change the appearance of the room at all. How can I make my room look more like the Google VR demo? EDIT I made a big improvement by changing all my walls to be static so that they receive indirect lighting, and adding a single point light above the roof.


Why use Time.deltaTime in Lerping functions? To my understanding, a Lerp function interpolates between two values (a and b) using a third value (t) between 0 and 1. At t 0, the value a is returned, at t 1, the value b is returned. At 0.5 the value halfway between a and b is returned. (The following picture is a smoothstep, usually a cubic interpolation) I have been browsing the forums and on this answer I found the following line of code transform.rotation Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime) I thought to myself, "what a fool, he has no idea" but since it had 40 upvotes I gave it a try and sure enough, it worked! float t Time.deltaTime transform.rotation Quaternion.Slerp(transform.rotation, toRotation, t) Debug.Log(t) I got random values between 0.01 and 0.02 for t. Shouldn't the function interpolate accordingly? Why do these values stack? What is it about lerp that I do not understand?


Unity Load Lightmaps at Runtime I'm a bit of a novice to lighting, but I think what I want to do is possible, so please bear with me. Due to the nature of my game, I've taken an approach where a singular scene game is where all of the gameplay occurs. For each level, I'm arranging all the GameObjects and Terrain in a secondary scene (named testbed) to my liking. Once I've got it to my liking, I save that to a prefab, which in turn is saved to an AssetBundle. I also generate the lighting at this point, which I can see appear in my project under a Assets Scenes testbed folder. At runtime, a script in the game scene reads the appropriate AssetBundle, and then loads amp positions all of my objects and characters. Everything about this works, except for updating the lighting. My approach is to store references to the lighting textures that have been output into the aforementioned testbed folder via a ScriptableObject (after trying and failing to use the LightingData object that appearred in this same folder) Then, when I'm loading my level up into the game scene, this block is executed public void LoadLighting(LevelKey key) var data levelMap.metaData.Find(it gt it.key key) var directions data.lightData.directions var lights data.lightData.lights var lightmaps new LightmapData directions.Length for (int i 0 i lt directions.Length amp amp i lt lights.Length i ) var lightmapData new LightmapData() lightmapData.lightmapDir directions i lightmapData.lightmapColor lights i lightmaps i lightmapData LightmapSettings.lightmaps lightmaps Based on a lot of searching, this should cause something to happen, but I can't detect any change in the scene. Does what I'm trying make any sense? Should I just scrap this and make dozens of different scenes (which I'm trying to avoid) instead? Really any advice here is appreciated.


How can I find if a GameObject is not exist in the Hierarchy? var selections Selection.objects.OfType lt GameObject gt ().ToList() if (selections.Count gt 0) tempSelections selections for (var i selections.Count 1 i gt 0 i) var selected selections i transformSelection.Add(selected.transform) TransformSaver.SaveTransform(transformSelection.ToArray()) transformSelection new List lt Transform gt () for (var i tempSelections.Count 1 i gt 0 i) var selected tempSelections i if (GameObject.Find(selected.name) null) GUI.enabled true else GUI.enabled false if (GUILayout.Button("Undo last selection if deleted")) transformsCount TransformSaver.LoadTransform().Length PlayerPrefs.DeleteKey("transform") For testing I'm deleting one of the GameObjects in the tempSelections List But then I'm getting exception in the editor on the line if (GameObject.Find(selected.name) null) Since the GameObject have been deleted it can't access the GameObject. MissingReferenceException The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.


Audio slider doesn't change value For some reason, my slider and audio resets back to 0 when I stop and play the game after I changed the value. Here is the code, I can't spot anything wrong with it using UnityEngine using System.Collections using UnityEngine.UI public class MainAudio MonoBehaviour public Slider slider void Awake() PlayerPrefs.Save () GetComponent lt AudioSource gt ().volume PlayerPrefs.GetFloat ("CurVol") if (slider) slider.value GetComponent lt AudioSource gt ().volume public void VolumeControl(float volumeControl) GetComponent lt AudioSource gt ().volume volumeControl PlayerPrefs.SetFloat ("CurVol", GetComponent lt AudioSource gt ().volume) PlayerPrefs.Save ()


fading from one scene to another not working I am using the following code to fade from one scene to another, but it doesn't fade. It just loads the next scene without fading. I suspect there's something wrong with the image I'm using. I used a black .png image with dimensions 425 344 that I downloaded from Google. How can I solve this issue? Fading.cs (I added this to an empty game object) public Texture2D fadeOutTexture public float fadeSpeed 0.8f private int drawDepth 1000 private float alpha 1.0f private int fadeDir 1 void onGUI () alpha fadeDir fadeSpeed Time.deltaTime alpha Mathf.Clamp01(alpha) GUI.color new Color (GUI.color.g, GUI.color.b, alpha) GUI.depth drawDepth GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), fadeOutTexture) public float BeginFade (int direction) fadeDir direction return (fadeSpeed) void onLevelWasLoaded() BeginFade ( 1) In the script of the trigger object IEnumerator gameScene2() float fadeTime GameObject.Find ("FadeObject").GetComponent lt Fading gt ().BeginFade(1) yield return new WaitForSeconds(fadeTime) Application.LoadLevel("Scene2") These are the image settings for the black .png image


why is my (from example) shader appearing as black? I have the following (very simple) shader pragma kernel CSMain RWTexture2D lt float4 gt Result numthreads(8,8,1) void CSMain (uint3 id SV DispatchThreadID) Result id.xy float4(1,0,0,1) Here is the dispatcher code using UnityEngine using System.Collections public class SkyShaderDispatcher MonoBehaviour public ComputeShader shader public RenderTexture output void Start() RenderTexture output new RenderTexture(256,256,24) output.enableRandomWrite true output.Create() void Update() RunShader() void RunShader() int kernelHandle shader.FindKernel("CSMain") shader.SetTexture(kernelHandle, "Result", output) shader.Dispatch(kernelHandle, 256 8, 256 8, 1) which is the default red shader (it makes the texture red). However, when I put the texture in a material and give that to an object, then that results in the object being black. Anyone seeing what I'm doing wrong? As the shader is the default example right now it should work suggesting that maybe something is wrong with the texture? Edit Trying to fit the same code on a skybox also fails. I have changed the dispatcher code into using UnityEngine using System.Collections public class launchClouds MonoBehaviour public ComputeShader shader private RenderTexture output void Start() void Update() RunShader() void RunShader() int kernelHandle shader.FindKernel("CSMain") RenderTexture output new RenderTexture(256,256,24) output.enableRandomWrite true output.Create() Material mat gameObject.GetComponent lt Skybox gt ().material mat.SetTexture(" FrontTex",output) mat.SetTexture(" BackTex",output) mat.SetTexture(" LeftTex",output) mat.SetTexture(" RightTex",output) mat.SetTexture(" UpTex",output) mat.SetTexture(" DownTex",output) shader.SetTexture(kernelHandle, "Result", output) shader.Dispatch(kernelHandle, 256 8, 256 8, 1) but that turns the sky black rather then making the sky red. This is using unity 5 32 bits with DirectX11.


Unity3D Efficiently loading chunks in an infinite voxel engine I'm developing a voxel engine in C using Unity and I'm currently trying to implement infinite terrain, so I took a look at other Unity voxel engines that have infinite terrain. I've seen three different ways of doing it Using a dictionary to store the chunks and store the block data in another dictionary Using a dictionary to store the chunks and store the block data on every chunk Using a fixed size array and shifting it every time the player moves The engines using approach 1 and 2 were pretty slow at chunk loading. The engines using approach 3 were faster but produced lag every time the player entered a new chunk. I've already tried to implement it using approach 1, but my chunk loading speed got slower by about 10 times, so it was really unplayable. How is it done in efficient or popular voxel engines like Minecraft or VoxelFarm? Do you have experience with voxel rendering and know a better approach? Thanks in advance!


Move Camera is an order so that the background doesn't move fast I have created a game where I am moving my player on a platform. The car moves fine on the platform and the camera follows the car as well. My problem is that I wanted my background to move slowly. I am using a perspective camera and I am moving camera away to create a zoom out effect when my player jumps. Do you suggest I should move my background towards right so that it creates a simple slow effect? As currently it moves very fast. here is my video demonstration https www.youtube.com watch?v xO mEXo6mNA


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?


Stencil inside Stencil? (Multiple masks on same object) So please take a look at what I want to achieve The Red and Blue part is the object I want to mask. The thing is that it will be masked by the green area, and only after that it will be masked by the cyan area, which shall act like a scrollview. Currently I use stencil shader and the first mask works, but I don't know how to apply the second mask. Also, I don't want to use the built in UI mask system for this. All the objects in the scene are sprites. The thing is that I would like to achieve a hierarchy masking system, where the kids are masked by a parent. Could you please give me a tip about what I should do in this case?


OnCollisionEnter2D not working I am fairly new to Unity2D and am making a 2D platformer to get used to the engine. I am trying to create a platform that moves when the player jumps on it, however, on the script for the platform the OnCollisionEnter2D method is just not being called. This is the script public class ThrustPlatform MonoBehaviour SerializeField float thrustSpeed SerializeField float thrustDistance Animator thrustAnim Rigidbody2D rb private bool thrust false private Vector2 startPos private Vector2 targetPos void Start() thrustAnim GetComponent lt Animator gt () rb GetComponent lt Rigidbody2D gt () startPos transform.position float targetX startPos.x thrustDistance targetPos new Vector2(targetX, startPos.y) private void OnCollisionEnter2D(Collider2D coll) Debug.Log( quot COLLISION quot ) thrust true private void FixedUpdate() if(thrust) rb.velocity new Vector2(thrustSpeed, 0) The player and platform are on layers that can collide with each other in the collision matrix, the player still lands on the platform, and the player has a dynamic rigid body and the platform a kinematic rigid body. As far as I am aware kinematic rigid bodies detect collisions from dynamic rigid body, I have watched tutorials where this works. Even if I change the platform rigid body to dynamic there is no detection. I have also tried using continuous collision detection on both rigid bodies but still it is not calling. If I change it to a trigger and use OnTriggerEnter2D however, the Debug line appears. This is the rigidbody for the platform. This is the rigidbody details for the player. I am very confused as to why this isn't working and I can't find a solution anywhere else (unless I am missing something very obvious).


Scale NonUniformScale is not applied to entity I'm just learning the new Unity ecs and trying to change the size (scale) of an entity. Everything works fine, I can change the rotation, the position but not the scale. I'm wondering why. I did various tutorials, I tried Scale, NonUniformScale, LocalToWorld, CompositScale but nothing works. Maybe some of the methods are deprecated. Here is what I have tried so far. I have multiple prefabs (planes) which are spawned correctly and each of them having a transform component. Now I want to change the scaling of all the planes. For that I use a JobComponentSystem. In the following pice of code the rotation works fine, but not the scaling. I tried LocalToWorld. public void Execute(ref Rotation rotation, ref LocalToWorld scale) rotation.Value math.mul(rotation.Value, quaternion.RotateZ(math.radians(0))) scale.Value float4x4.Scale(2, 4, 5) I tried NonUniformScale public void Execute(ref Rotation rotation, ref NonUniformScale scale) rotation.Value math.mul(rotation.Value, quaternion.RotateZ(math.radians(0))) scale.Value new float3(2, 1, 4) I tried Scale. public void Execute(ref Rotation rotation, ref Scale scale) rotation.Value math.mul(rotation.Value, quaternion.RotateZ(math.radians(0))) scale.Value 5 None of these is working. What did I wrong (the scale just stays at 10,1,10) or what is the current propper way of doing that?


Unity multiplayer (online) How to connect to a 'Client Host' without using Unity Paid Service I'm slightly annoyed with the official Unity guides here, because I have been following through some, and they have indeed helped me create a local network mulitplayer situation. However, at no point did they mention that using these methods (ie. UnityEngine.Networking NetworkManager NetworkManagerHUD NetworkIdentity) will require me to pay Unity for Pro, and a monthly server usage fee, if I wanted to play via internet. I've set up my own Rust server in the past and it was very simple. I just installed a Rust Dedicated Server on my desktop PC (which I have fibre internet connection) and ran the server. I could then have 20 people playing with me and we didn't notice any slow down or lag or any problems with it. (Rust is made in Unity I believe) I've tried searching lots on this matter, and there are many many differing voices of how I can do this (many out of date, and many explicitly stating its impossible without hiring a server) I disagree, and think I can make my desktop run the server, BUT I haven't a clue if I'm correct and also how I would be able to make it. Unity docs seem to be trying to hide this solution if it exists (perhaps I'm being paranoid). I have the NetworkManagerHUD all working and can play locally as I say. So, it appears that the NetworkManager allows a user to start my game in 'Client host' mode, it also allows another instance elsewhere to click "Connect Client" and has a space for IP address. Would I even need a dedicated server if a player has clicked to start as 'Client Host'? assuming I don't, how can I then connect to this host from another machine? Does typing the client hosts external IP allow this? Sadly, I don't have anybody to help me test this right now. If a dedicated server version is the preferable way to go, could anybody please help me in the direction of how to start creating this? For info The game at this stage is a very simple FPS shooter. The NetworkManager is assigning the 'isLocalPlayer' flag correctly to one instance of the player object. I see in the Editor Hierarchy that it is handling the game overall and has two player objects once I have logged in with two instances locally.


SceneManager.LoadScene doesn't seem to be working in Unity IDE I'm in the start screen scene of my game and I'm trying to load the actual game. I use the following code public void LoadGame() SceneManager.LoadScene ("Main", LoadSceneMode.Single) I set this method to be called when a button in the UI is clicked. When testing in the game in the unity IDE, clicking the button doesn't do anything. Is my code wrong, is the IDE screwing up, or will clicking the button never do anything in the ide?


Unlit Node Shadow Shader Graph How to make unlit node cast shadows? Is is possible with the current state of Shader Graph in LWRP? In this great article Toon Shader OP grabs pass from VertexLit shader. Is something similar achievable with Shader Graph?


Rigidbody player controller on moving platforms So basically, I was trying to make moving platforms. When I finished my prototype, I noticed that the movement on the platform is very wobbly https www.youtube.com watch?v hmBumsrlHGA amp feature emb logo To snap the player onto the platform, I am just making it a child of the platform. Anyway, I don't know what is causing this issue and was wondering if I can get any help. Thank you in advance Here, the controller code private void Movement() Extra gravity rb.AddForce(Vector3.down Time.deltaTime 10) Find actual velocity relative to where player is looking Vector2 mag FindVelRelativeToLook() float xMag mag.x, yMag mag.y Counteract sliding and sloppy movement CounterMovement(x, y, mag) If holding jump amp amp ready to jump, then jump if (readyToJump amp amp jumping) Jump() Set max speed float maxSpeed this.maxSpeed if (sprinting) this.maxSpeed 25 else this.maxSpeed 15 if(sprinting amp amp y lt 0) this.maxSpeed 15 If sliding down a ramp, add force down so player stays grounded and also builds speed if (crouching amp amp grounded amp amp readyToJump) rb.AddForce(Vector3.down Time.deltaTime 3000) return If speed is larger than maxspeed, cancel out the input so you don't go over max speed if (x gt 0 amp amp xMag gt maxSpeed) x 0 if (x lt 0 amp amp xMag lt maxSpeed) x 0 if (y gt 0 amp amp yMag gt maxSpeed) y 0 if (y lt 0 amp amp yMag lt maxSpeed) y 0 Some multipliers float multiplier 1f, multiplierV 1f Movement in air if (!grounded) multiplier 0.5f multiplierV 0.5f Movement while sliding if (grounded amp amp crouching) multiplierV 0.5f multiplier 0.5f Apply forces to move player rb.AddForce(orientation.transform.forward y moveSpeed Time.deltaTime multiplier multiplierV) rb.AddForce(orientation.transform.right x moveSpeed Time.deltaTime multiplier)


What's the difference between UnityEngine.Random and System.Random? What's the different between this int randomNumber UnityEngine.Random.Range(0, 10) and this on top of the class private System.Random rnd new System.Random() inside a methode of the same class int randomNumber rnd.Next(0, 10) I know System.Random must always be initialized on the top of your class what's by UnityEngine.Random is not needed. I know also that System.Random works with a intern "clock" and the "random" number is based on that. My question is now are there some other difference between UnityEngine.Random and System.Random and witch code is better to use for an Unity project?


Unity normal maps look wrong (URP, iOS) We're building an AR enabled app with Vuforia and Unity 2019.3, using the Universal Render Pipeline. Trouble is, on iOS our models that have normal maps in their materials look totally bad, as you can see. This is how it's supposed to look (ignore the differences in the orange background item) If we remove the normal maps, the models look fine, but since the normal maps add a lot of detail and depth to the scene, we'd rather not ditch them. We've tried to change the import settings of the normal maps, changing the compression formats and such, but that didn't make a difference. Here's an image of the material settings Is there another solution to fix this? On Android, there's no problem, by the way.


How to make local keyboard input move only the local player, not everyone in networked multiplayer? I am working on Unity Networking and following this Tanks Networking tutorial https www.youtube.com watch?v V6wEvT6G92M Problem is that the keyboard inputs move all the tanks in the scene. It is not detecting the local tank. And when I run the game all tanks shows the same movement but it is not giving any error. I have followed all steps in the tutorial and searched all solutions on the google. This step in Tutorial is at 11 48. Implemented Code is using System.Collections using System.Collections.Generic using UnityEngine using UnityStandardAssets.CrossPlatformInput using UnityEngine.Networking public class TankController NetworkBehaviour Use this for initialization Header("Movement Variables") SerializeField float movementSpeed 5.0f SerializeField float turnSpeed 45.0f Header("Camera Position Variables") SerializeField float cameraDistance 16f SerializeField float cameraHeight 16f Rigidbody localRigidBody Transform mainCamera Vector3 cameraOffset void Start () if (!isLocalPlayer) Destroy(this) return localRigidBody GetComponent lt Rigidbody gt () cameraOffset new Vector3(0f, cameraHeight, cameraDistance) mainCamera Camera.main.transform MoveCamera() Update is called once per frame void FixedUpdate () float turnAmount CrossPlatformInputManager.GetAxis("HorizontalUI") float moveAmount CrossPlatformInputManager.GetAxis("VerticalUI") Vector3 deltaTranslation transform.position transform.forward movementSpeed moveAmount Time.deltaTime localRigidBody.MovePosition(deltaTranslation) Quaternion deltaRotation Quaternion.Euler(turnSpeed new Vector3(0, turnAmount, 0) Time.deltaTime) localRigidBody.MoveRotation(localRigidBody.rotation deltaRotation) MoveCamera() void MoveCamera() mainCamera.position transform.position mainCamera.rotation transform.rotation mainCamera.Translate(cameraOffset) mainCamera.LookAt(transform) I have also checked the auto create player in the spawn info as suggested in some solutions.


taking a static animation and making it move unity3d Say you have an animation of a bird flapping its wing. Some animations actually moves the Avatar either forward, backwards or to the side. My question is, is it possible to take that flapping animation and change the animation to make it move forward within the unity editor? Please note that i am not an animator which means that i do not have the skills to edit the animation in a 3rd party program. So this question revolves around what you can do in Unity3d


How do i move a 2D object with angle and speed variables in unity? I want to move an object with a certain angle and speed, is there a was to set this as an initial velocity so that it is still possible for the object to collide and bounce of other objects using its rigid body?