How do I parent an object to a bone in the blender hierarchy? So, I'm trying to make a simple RPG game using Blender and Unity. I would like to have an empty object to be used as a weapon holding position parented to my right hand bone so that I can switch weapons in and out and they'll be able to animate along with my character by being the child of the empty position. The problem I am having is that I can't get the empty position to be a child of the specific right hand bone, only the armature. Is there a way to make this work? Also, if this isn't a good procedure to accomplish what I am trying to do, please enlighten me with the proper way, I'm kind of a noob, thanks.


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?


Revert a GameObject to a previous version Is there a way to use an old version of a scene.unity file to revert changes for specific GameObjects only? Occasionally Unity GameObjects can lose all their references in the Inspector (If a prefab instance, it keeps the prefabs defaults). I have the missing references committed in my previous git commit, and have not changed any scripts on that GameObjects. If I discard all my working changes to my scene.unity file I get my inspector references back OK. But is there a script or process which allows you to revert specific gameobjects only to HEAD. This would be useful when GameObjects lose their settings, and also when you want to revert only parts of your scene.


Are huge, static objects like environment transmitted from server to client in modern multiplayer games? I have an authoritative system, where when the player joins the match, it gets all the already spawned objects spawned on itself (the client). It looks like this Client sends the access token to the Server Client receives the acceptance from the Server Client switches scene to the game scene Server sends players, crates, objects you can interact with so the client can spawn and display them. But what about the ground object? For now, I have the exact same scene on the server and the client with one static plane acting as a floor. Currently I'm adding new stuff, trees, stairs and build things together. I thought we're good. But shouldn't the environment be synchronized too? Be networked somehow? Owned by the server? Let's take League of Legends It's a static environment, probably one combined mesh (stairs, grass, walls, shop). But is it really kept on the client or is it sent by the server during the loading screen?


How to Play YouTube Videos Within Asset Store for Unity On every computer I've ever tried to use Unity, the Asset Store seems incapable of showing the YouTube video previews of assets. It always claims my "browser" does not currently recognize any of the video formats available and recommends I click for a visit to a FAQ about HTML5 video. I would expect this to be built into Unity, yet it seems not to be. I can't find anything online about what the deal is. So how do I get the videos to work within the Asset Store within Unity??


Matte reflection effect in Unity? I'm trying to achieve that kind of scene but in real time using Unity. It's basically composed of some primitives, a skybox, and a plane. I'm intrigued on how to do this effect in particular The plane acts like a mirror, but tainted and matte (and it appears to be less blurry at the bottom of the buildings... but I'm not quite sure). I have found some shaders to create mirrors in Unity but nothing about the matte effect like in this picture. Could you guide me on how to achieve this kind of effect (knowing that I'm pretty lame when it comes to write shaders but I want to learn). Thanks.


"Your android setup is not correct" error on Unity showing up even after reinstalling OpenSSL (Using Facebook SDK) I want to build for Android and today one error popped up after building. Your Android setup is not correct. See Settings in Facebook menu. UnityEditor.HostView OnGUI() Important things about this problem The only error in the inspector I can see is OpenSSL not found. Make sure that OpenSSL is installed and that it is in your path. Even tho I have installed it and added it to my path When I open the inspector in Facebook Edit Settings, unity becomes very unresponsive This error has not popped up before today I still get a APK even if I get errors


How to implement a network proximity checker in Unity using LLAPI? I'm trying to implement a network proximity checker using my own functions in Unity, using LLAPI. How can I implemnet a network proximity checker, with similar functionalities than the ones in the HLAPI proximity checker?


How to activate GearVR Menu in my own Unity Apps? So in normal GearVr Apps, which you can download from the marketplace, you can activate the GearVr Menu to control brightness etc. with a long click on the back button. But this does not work for all of my apps which I made with Unity for the GearVr, is there something special I have to import into my project?


Unity3d UnityWebRequest EscapeURL standard does not match Swift url encoding. How to decode it? How should I decode escaped URL by unity in Swift? I am developing a game with Unity3d. Something MMORPG. With server implemented by me in Swift under Kitura framework A framework doesn't matter that much. It is more about swift and Unity itself. Let me describe the problem here. Unity UnityWebRequest.EscapeURL("First Last") Escapes string with encoding used in the application x www form urlencoded content type https www.w3.org TR html401 interact forms.html h 17.13.4.1 Which produce string First Last where maps to " " space. Swift import Foundation var str "First Last" print(str) print(str.removingPercentEncoding) The character used on this string isn't considered as a percentage encoding in the standard used by swift. It would be if the character escaped as this would be represented by 20. So my server and client ended up with different string values. Later on returned from one to the other weren't equal. Which ended up considering them as two different clients.


Spawn Array of GameObjects to Array of Transforms I have a question regarding spawning an array of GameObjects in Unity. What I want to happen is that when a big enemy dies, it will spawn enemies into their respective Transform positions (i.e., Enemy 1 will spawn in Position 1, Enemy 2 in position 2, and so on). I suppose I could go on with something like C public GameObject Enemies public Transform SpawnPoints void KillEnemy() GameObject enemy1 Instantiate(Enemies 0 , SpawnPoints 0 .position, SpawnPoints 0 .rotation GameObject enemy2 Instantiate(Enemies 1 , SpawnPoints 1 .position, SpawnPoints 1 .rotation GameObject enemy3 Instantiate(Enemies 2 , SpawnPoints 2 .position, SpawnPoints 2 .rotation Destroy(gameObject) But the problems are 1. I'm aware that the code is expensive to run, especially since I'm doing a 2D game and 2. It provides no flexibility, meaning if I want a different enemy to use the same code, then I won't be able to do stuff like adding more enemies to spawn (after the first one dies, of course). So yeah, I hope I get some help with this. Thanks!


Updating the position of a prefab in Unity for A pathfinding I am trying to use Aron Granberg A pathfinding project in my game. I am very new to Unity, so I am having some trouble figuring out how to instantiate multiple enemies from a prefab that will seek out my player. I am unable to set the player object from the scene as the target, since prefabs cannot take in scene objects. However, if I use the player prefab as the target, the enemies will only go toward the starting position of the player. Is there any way to update the prefab position as the player instance moves? Or is there a better way of doing this? I want this to be a top down shooter style game (2D) with constant enemy spawning, so it doesn't make sense to set the target for each individual enemy instance. Any help would be greatly appreciated. Thank you!


How to make an animation play when a button is pressed once? I have added an idle and jump animation to a character in unity. I can make the animation happen when the button is pressed. If the button is up middle at the animation the character goes to the idle position. But I want the whole animation happen in one press to the button and then go back to the idle position. My current script and Animator views are if (Input.GetKeyDown(KeyCode.Space)) Anim.SetBool("is jumping", true) ApplyInput(moveAxis, turnAxis) else if (Input.GetKeyUp(KeyCode.Space)) Anim.SetBool("is jumping", false)


Programmatically create a trigger within abnormally shaped room So I'm trying to create a trigger in each of my rooms. These rooms can be created by players. Basically, I need to know all the objects in a room. These rooms can be shaped in weird and wonderful ways. I'm struggling to figure out how to "fill" an area? The other problem is that some walls are curved. My current thinking is Loop over all the walls in a scene. Do 4 raycasts from each side of the wall and see if we hit other walls. If we do, we are likely in a room. From the offset, literally check each node adjacent to that until we fill the room. Once I have this though, Im not sure what to do with it. How do I create bounds that I can check for collisions with this data? Edit Adding an image for clarity. Red and blue should be 2 different rooms and I want to get all items in each of these rooms


How to use a Rigidbody on a game object after animation in Unity? How to use a Rigidbody on a game object after animation in Unity? I want to play an animation fully controlling the positioning of the elements, i.e. ignoring physics. And after an animation plays till the end I want physics to resume affecting the element. Right now to get the expected behavior I have to remove the Animator after an animation. I thought that maybe there is a neater way to do what I want, but I did not find it, so decided to ask here. UPDATE I just found a better way to achieve what I want. Instead of removing the Animator component I just disable it animator.enabled false It feels better. But still I am hoping for a neater solution.


How can I instantiate in the current rotation in Unity 2d? Backstory I'm currently working on a 2D sidescroller platform game as a hobby, and I just started recently. Followed a few tutorials and such I managed to wrote my own code for basic command like walk, jump, health and so on. However my basic code wasnt perforning as I would expect, I needed a more "Tight" feeling with the movements so I followed a suggestion to use a physics based controller (Prime31's PC2D, Acrocatic or even Corgi Engine...) Well, now the movements are what I feel is good, So I kind of dived in the scripts to add remove customize some code. Question I'm stuck now on a simple issue, I added these lines public Transform weaponMuzzle public GameObject projectile float fireRate 0.5f float nextFire 0 then in my Update() if (Input.GetButtonDown("Fire2")) animator.Play.Weapon() fireProjectile () and here is the problem I have void fireProjectile () if (Time.time gt nextFire) nextFire Time.time fireRate if ( motor.facingLeft) Instantiate (projectile, weaponMuzzle.position, Quaternion.Euler (new Vector3 (0,0,180f))) else if (! motor.facingLeft) Instantiate (projectile, weaponMuzzle.position, Quaternion.Euler (new Vector3 (0, 0, 0))) The prefabs are also physics based and they are fired with no problems, however they don't want to follow the current rotation of the player, they always go in the right X axis. First of all, the facingLeft on my code is what I understand is the reference to the character controller motor, I tried with motor.normalizedXMovement gt 0 and motor.normalizedXMovement lt 0 (normalizedXMovement 1 is full left and 1 is full right) this just make it that you can only fire while moving, not stopped and the problem still persists. I also tried with Quaternion.Identity instead of Euler and it's the same. For a full source code https github.com prime31 CharacterController2D I'm kinda lost and it would means a lot if you can help me out on this issue. Ps I already searched here and other related forums but cannot find the answer, this is not a repost.


Replacing assets in Unity real time but keeping the references intact I'm looking forward to adding mod support into my game by allowing users to easily replace some assets with their own versions. The way I want it to work if there's, say, a certain texture in some folder in my compiled game, I replace the texture with the same name in my resources, but I keep references intact. That means that the texture will be replaced for every material using this texture. I don't want to change materials themselves to reference the new texture, mainly because I'll have to keep a list of materials for each texture, and because materials might be replaced by potential modder as well. It's also important to note that I want to give people the ability to change basically anything (but scripts). Sounds, music, textures, meshes, materials, fonts, localization files, shaders, so the list of references might be absolutely changed upside down and that is absolutely not the solution.


Share a function between two passes inside CG Shader for unity3d I'm writing a shader in CG language for Unity3d. When making transparent object you need to create two similar passes in SubShader. First to render only back faces (with Cull Front) and second to render only front faces (with Cull Back). But the code for vertex and fragment function is the same. Is it possible not to double a code and declare some functions, that would be shared between passes? I want to have something like in my code example. Shader "cool shader" Properties ... SubShader CGPROGRAM need to declare vertexOutput somewhow here float4 sharedFragFoo(vertexOutput i) COLOR How to make smth like this? .... return float4(...) ENDCG pass CGPROGRAM pragma vertex vert pragma fragment frag vertexOutput vert(vertexInput v) vertexOutput o ... return o float4 frag(vertexOutput i) COLOR return sharedFragFoo(i) call the shared between passes function ENDCG pass CGPROGRAM pragma vertex vert pragma fragment frag vertexOutput vert(vertexInput v) vertexOutput o ... return o float4 frag(vertexOutput i) COLOR return sharedFragFoo(i) call the shared between passes function ENDCG


Unity adding camera constraint to prevent the player from seeing beyond the scene Like the title says, I'm after some kind of constraint for the camera to prevent the player from seeing beyond the scene and seeing the Skybox. I came across the code to add a Mathf.Clamp, but I can't get it to work. I'm currently trying to make a 2.5D platformer in which the camera follows the player (ahead), which leads to seeing beyond the scene to the far left and right. I already have an invisible wall in place to prevent the player from falling off, but I would love to also clamp the camera from going any further. This is the script I have at the moment using System.Collections using System.Collections.Generic using UnityEngine public class CameraController MonoBehaviour SerializeField GameObject player null SerializeField Range(0.1f, 2f) float followAhead 2f SerializeField Range(0.1f, 2f) float smoothing 1f public PlayerController playerController private float minPosition 9.37f private float maxPosition 4.68f private Vector3 cameraClamp const float m minY 2f Vector3 targetPosition Vector3 cameraOffset void Start() cameraOffset transform.position player.transform.position void Update() targetPosition (player.transform.position (player.transform.forward followAhead)) cameraOffset smoothedForward Vector3.MoveTowards(smoothedForward, playerController.GetTravelDirection(), 0.5f Time.deltaTime) targetPosition (player.transform.position (smoothedForward followAhead)) transform.position player.transform.position cameraOffset targetPosition.y Mathf.Min(targetPosition.y, m minY) transform.position Vector3.Lerp(transform.position, targetPosition, smoothing Time.deltaTime) cameraClamp.x Mathf.Clamp(transform.position.x, 9.37f, 4.68f)


Continuous translation in Unity I would like to apply a constant speed everlasting translation to a game object (e.g a background) in Unity. Without physics. What is the best way to achieve that?


How can i properly display 2D Pixel sprite's pixels without distortion while it's moving ? (in unity) Introduction to what i'm trying to do Hi, I'm trying to make a 2D Pixel Platformer Game in Unity. Before that i used godot and for some reasons (not about the engine) i switched to unity. And in Unity there are things need to handle by myself, and they were handled by the engine in godot (i guess), because godot is more suitable and compatible with 2D Pixel games (i guess). So i am not sure why the problem happens The Problem In the scene, my pixel sprite is playing his Idle animation (he's only breathing so you can think of that as head and the body moving 1px up and down repeatedly) While playing that simple animation, if my sprite is big enough on the screen, there is no problem and it looks pixel perfect animation is playing without distortion (or disruption idk what was the right word). But if the character looks smaller on the screen, i mean if i scale the character down or keep the scale same and make camera's angle of view bigger, so character looks smaller (not too small a regular platformer character size), What happens is character's eyes visibly goes thinner and thicker as the character plays his animation (head and the body moving 1px up and down repeatedly). Character's eye is 2 black pixels side by side thats it. While the animation playing it kinda distorts. Height changes. Yes I fixed it somehow but.. I fixed it, but idk how and seems like a temporary fix AND i don't think that is how it's supposed to be fixed because we wrote code, I'm okay with writing code for fixing it but first i want to know what was the problem and how to fix it in editor. aaand it just seems weird to write code for simply having a properly functioning pixel sprite animation. How did i fixed it ? just watched this video and added the same script to the camera i have no idea how it worked and why my animation problem was occuring at the first place. What I'm asking for Pleaaaase somebody explain all that to me, why is that happening what are the possible and proper fixes. i'm researching for days and i thought unity had a "big community a lot of tutorials too easy to learn" TL DR when playing animation pixel sprite character's some pixels distorts version Unity 2019.3.3f1 I imported sprite the right way (Filter mode Point(no filter) Compression none, Pixels per unit 16 (that option seems suspicious maybe the problem is about that pixels and units thingies)) I can provide more information about project or directly send you the whole project if you can't reproduce the error. I'm just too curious and want to learn how to have a proper 2D display setup and finally start the fun part coding mechanics etc. since a code about camera solved the issue the problem might be unity's camera settings because unity has no 2D special camera component while godot has Camera2D and Camera3D seperatly. These are just my guesses please teach me what you know.


Placing a gameobject with restrictions I am newbie in programming and I am making a tower defense game 2d. My problem is I want to make a restriction to place a tower only, if the mother tower is in place or within its range. I'm sorry if my explanation is a bit confusing. For example, you can oly place a certain tower within the range of the mother tower and only if that mother tower is placed. I don't exctly know if I have to create a function for this or create a range game object for the placement attached to the mother tower. Any help and tips would be appreciated, thank you. This is by the way unity C .


Unity Custom aspect ratio in build I have made a game that was supposed to be for mobile but now I need to build it for PC. I want the aspect ratio to be 2 3 but as you can see on the image that doesn't exist. How do I add a custom aspect ratio for the build?


Unity3D HTC Vive graphical bug when making builds Recently I noticed that my builds seem to have a weird graphical bug. This only occurs when I play a build. Running the game in VR in unity play mode doesn't show this bug. I am not sure what is causing this or what it is even called. I do remember in the old days windows having a similar bug where you could draw on your screen basically by dragging an interface. I have an older build where this glitch didn't occur and checked the settings I had then and now and nothing changed. Developing in VR is still fairly new to me so if it is anything basic I might not be aware of it. My Unity version is 2017.2.0f3 with the latest SteamVR version using the HTC Vive, which has been running on the same version as when the bug didn't occur. This link is a video of the bug occurring during the play mode in a build (in the menu the bug didn't occur strangely enough). This link is a video of it being run in play mode. This is what I would expect in a build as well. Just watching the first few seconds of both videos is plenty to understand the issue I am experiencing. Thanks in advance. Edit I have discovered that this issue is called ghosting. I hope this helps anyone.


Move gameObject in its facing direction I have the following four gameObjects, they have, respectively, the rotations 90, 0, 90, 180. I want them to move as denoted in the image below This is what I got so far public class Projecttile MonoBehaviour public float speed private void Update() transform.Translate(transform.up speed Time.deltaTime) The result of my code is the following Why does my code result in this outcome, and how can I make each gameObject move in the direction it's facing?


How to determine what direction an object should orbit around another I am creating a game in Unity with 2D. When a button is clicked a static object is attaching a hinge joint to a dynamic object, so the dynamic object orbits it. When the dynamic object gets attached, I am setting the dynamics objects transform.up vector to be pointing at the static object. Then, taking what ever the dynamic objects magnitude was and setting that as its velocity to the right. I do this because I want the dynamic object to orbit the planet at the same exact speed as when it wasn't orbiting. The problem I am having, is I don't know how to determine if the object should orbit clockwise or counter clockwise. It's easy for me to determine this when I look at an image, but I don't know how to via code. Here is an example Does anyone know how I can determine this?


How should I store and load structures for 2d tile based game? I am working on structure generation for my 2d tile based game. Structures can be anything from houses, castles, dungeons, mazes etc. Structures are pre defined, meaning I defined the width height of the structure and wrote every single tile that should be placed for each coordinate. Structure "template" public class Structure private int width private int height private int , element public Structure(int w, int h, int , e) width w height h element e Creating a new structure 0 air 1 wall 2 door Structure house new Structure(4, 4, 1, 1, 1, 1 , 1, 0, 0, 1 , 1, 0, 0, 1 , 1, 2, 1, 1 ) This works fine for small amounts of structures. However, having tens hundreds of structures in code is not only mess, but taking memory unnecessarily since structure generation gets called rarily. So how should I store that data? 1) Should I make a file for each structure and load from it? 2) Should I dump all structures in 1 file? 3) What file format should I use for this? 4) Does Unity provide some data containers that can be easily accessed and read from? 5) How is this usually done?


Unity Photon multiplayer check distance between two players How to get distance between two player in a photon multiplayer game. Condition is both the player is moving. I have tried something like this, in my player control script if (photonView.isMine) pos1 rigidBody.position else pos2 rigidBody.position Distance Vector3.Distance(pos1 pos2) But its not working. For a player the pos2 is always (0,0). Please help.


2D active ragdoll physics based procedural animation I'm trying to make a 2D quadraped robot stand and walk via physics. My robot looks like this. (art is not mine. Source is vapgames) It's rigged via Unity's 2D animation package and each joint bone has it's own collider rigidbody with the legs also having hingejoints connecting the lower part to the upper part and the upper part to the main body of the robot. I've also set up IK for both legs using the 2D IK package with the IK target being attached to their respective leg via fixedjoint and can be moved programmatically to move the legs with respect to IK. I want it to stand up, as at the moment is just falls and acts as a generic limp ragdoll. I've tried these methods Adding downward force to the legs via the IK targets Adding upward force to the torso Animating the IK targets to try and get the bot to stand up with animatePhysics enabled. All of these failed (downard force to legs did pretty much nothing, upward force to torso just made it float if there was no ground, animating the IK targets was too glitchy). I'm out of ideas on how to actually do this now. I've looked around for guides but there seems to be nothing good (I keep getting this suggested to me but it doesn't help. It's in 3D and the only thing that could help, spider legs, isn't finished and probably never will be) There's very little information on how to do this sort of stuff and even when I find people who know about active ragdolls they just say add force to the head (for a 3D active ragdoll), which I've already tried (see 2. on the list of what I've already tried) and don't explain anyt further. If anyone could help, that'd be great!


Unity Ragdoll moves away from parent So this is a weird one. I've looked it up but can't find anyone with similar issues. Basically I have a simple combat system and after the enemy health is zero I go through each rigidbody component in the enemy object and add a force to make it go flying on death. For some reason, the parent object isn't affected and stays still while the Skeleton goes flying. Does anybody know how to make the parent object follow the skeleton, or make the skeleton follow the parent because as of now they act as separate entities? I've tried just adding force to the parent but that only moves the parent object and none of the children. Would appreciate any advice! Thanks.


Unexpected scaling of UI elements after build Unity Web I have an unusual scaling of UI Elements after my build in unity for WebGL Game in Unity Engine Game in Itch.io Has anyone seen this kind of behaviour? any suggestions on what I should look into? Happy to provide more info on the matter. Thanks!


How to ignore one unity package in source control I've just installed the Unity quick search package. This is an editor extension which each developer should choose if they want installed or not. My problem is that because this was added as a package it also made changes to my project which would end up in our repository. The changes are Project root Assets Assets.index Assets.index.meta Packages manifest.json packages lock.json UserSettings QuickSearch.settings Questions Should this files be added to source control? How can I ignore the changes in manifest.json and packages lock.json without filters?


Is triangle count so much cheaper on hard surface models that on animated meshes? I have a human character that consists of 40k triangles. When I animated him, I noticed a huge impact on the frame rate. Then I created a 10k tris version of the same model and animated him, and the frame rate was significantly higher. I would like to ask if there is any formula or any other way to compare this situation with a high poly model of a hard surface model against a low poly version of a hard surface model. For example, I see some 3D model vendors that offer weapons for FPS games, and they call their weapons with 25k tris "lo poly". Am I missing something here? Is it really so cheap (for some reason that I haven't found out) to throw 25k of hard surface geometry to CPU or GPU, and it wouldn't make a noticable difference in comparision to a 3k tris hard surface model? I'm working with Unity and HDRP, if that is important for an estimation. Thank you.


Best way to store items with statistics in an mysql database? Im currently working on an multiplayer game. Therefore using MySql for my game to store different data ( For example players, resources and so on ). Lately i implemented items, players receive them by gathering resources for example, later they should also be able to craft them or even equip them if its a sword or an armor piece. My problem is that due to my small experience with MySql, i have no clue how to add different statistics ( Equipable, Damage, Different Effects and so on ) to the items. Not every item should have them ( For example "Wood" shouldnt have statistics ). How should i modify my tables ? Any help would be appreciated ! Thanks ! My current table structure looks like this ItemCategories ( ID, Name ) ItemTypes ( ID, Name, ItemCategories ID ) For more information, how i actually manage spawn those items in... here two more important tables. This table contains resources ( For Example "Basic Tree" ) and the item it drops when gathered. Resources( ID, Name, ItemTypes ID, gatheringTime, gatherAmount, spawnWeight) This table contains the items in the players inventory. PlayerInventory( ItemTypes ID, Player ID, amount)


Export normal map from unity? In unity I can create a normal map out of a black and white image (By changing the type to normal map and select create from grayscale) Im wondering if there is a way to export the normal map like it should look so I don't need to create it from grayscale when I use it in another project?


How to find 1 3 and 2 3 of the distance between two given points? I know how to find the middle of two given points var midpoint (pointA pointB) 2 where pointA and pointB are Vector2 I thought that var thirdBtnPoints (pointA pointB) 3 var twoThirdBtnPoints 2 (pointA pointB) 3 should give me 1 3 and 2 3 between the two points but it doesn't. I guess this might be more of a math question though, but how can I find 1 3 and 2 3 of the distance between two given points?


Unity is Single Thread by how do WWW with coroutine work Async When I used HttpWebRequest and HttpWebResponse classes for an API calling my game suddenly halt for some seconds but as i used same API calling through WWW with coroutine, it didn't halt. I heard that unity is single thread but why my game not halt as i used WWW with coroutine? and is i am getting right that HttpWebRequest and HttpWebResponse are not better than WWW?


How to retrive the original position of an axis to Vector3? float x Random.Range( 1f , 1f) magnitude float y Random.Range( 1f , 1f) magnitude transform.localPosition new Vector3(x, y, originalPos.z) Here I'm trying to retrive the original position of z(without any changes) to the vector3. But in visual studio 2017 is showing an error like this How to resolve this?


delaying enemy attacks I have an enemy attack script that when a raycast hits the player it deals damage to the player, however the enemy attacks at multiple times per second and I wish for the enemy to have to wait 1 second after it attacks the player before it can attack again. The script is here, the main focal point is the void update(). Any help is appreciated, let me know if I've missed out any needed details. ) public class DamagePlayer MonoBehaviour int attackDamage 10 SerializeField float agroRange SerializeField Transform castPoint Rigidbody2D rb2d bool isFacingLeft Start is called before the first frame update void Start() rb2d GetComponent lt Rigidbody2D gt () bool CanSeePlayer(float distance) bool val false float castDist distance if (isFacingLeft true) castDist distance Vector2 endPos castPoint.position Vector3.right castDist RaycastHit2D hit Physics2D.Linecast(castPoint.position, endPos, 1 lt lt LayerMask.NameToLayer( quot Action quot )) if (hit.collider ! null) if (hit.collider.gameObject.CompareTag( quot Player quot )) val true else val false Debug.DrawLine(castPoint.position, endPos, Color.red) else Debug.DrawLine(castPoint.position, endPos, Color.green) return val Update is called once per frame void Update() if (CanSeePlayer(agroRange)) PlayerHealth.currentHealth attackDamage Debug.Log( quot can see player quot ) else


Melee Range trigger collider does not detect object with Player tag In my 2D game, I have a Player which has a BoxCollider2D with isTrigger false a dynamic Rigidbody2D a Player script ...tagged as quot Player quot and in the quot Player quot Layer. Also I have an Enemy in the scene which has a BoxCollider2D with isTrigger true an EnemyMelee script ... tagged as quot Enemy quot and in the quot Enemy quot Layer. The Enemy has its own collider because when to handle taking damage or changing colors when shot by the Player's bullets. The Enemy has an empty child game object following it where it goes, called MeleeRange and it has a BoxCollider2D with isTrigger true a kinematic Rigidbody2D an EnemyMeleeAttack script ...tagged as quot MeleeRange quot and in the quot MeleeRange quot Layer. What I want is When Player is inside of the MeleeRange area, the EnemyMeleeAttack script will detect this and call the Coroutine from the EnemyMelee script. I want my Enemy to trigger its quot attackMove quot animation and attack my Player every 1.5 seconds. It has an exit time to the idle animation, and because the Player is still in the MeleeRange collision area, the attack will start again and return to idle again. The problem is MeleeRange simply cannot see the Player tag in the area. I put Debug.Log if it detects the player but nothing happened. EnemyMeleeAttack script public class EnemyMeleeAttack MonoBehaviour public EnemyMelee enemyMeleeScript void OnTriggerEnter2D(Collider2D coll) if(coll.tag quot Player quot ) Debug.Log( quot MeleeRange Collision Reached! quot ) enemyMeleeScript.anim.SetBool( quot isRunningBool quot , false) enemyMeleeScript.StartCoroutine(enemyMelee.attackStance()) EnemyMelee script public class EnemyMelee Enemy region Variables public bool inRange endregion region Attack public float attackTime public float timeBetweenAttacks endregion region Movement with AI public bool isRunningBool public AIPath aipathScript public EnemyMeleeAttack emeleeattackScript endregion public override void Start() base.Start() anim gameObject.GetComponent lt Animator gt () aipathScript gameObject.GetComponent lt AIPath gt () aipathScript.OnTargetReached() private void FixedUpdate() Code for if Enemy dies, disable all functions attached to Enemy. if (health lt 0) GetComponent lt AIPath gt ().enabled false StopCoroutine(attackStance()) DamageColorUpdate() Reference from A Pathfinding for following player and running animations when following occurs. if (aipathScript.reachedEndOfPath false) anim.SetBool( quot isRunningBool quot , true) inRange false else anim.SetBool( quot isRunningBool quot , false) inRange true StartCoroutine(attackStance()) public IEnumerator attackStance() if (Time.time gt attackTime) anim.SetBool( quot isRunningBool quot , false) player.GetComponent lt Player gt ().TakeDamage(damage) attackTime Time.time timeBetweenAttacks anim.SetTrigger( quot attackMove quot ) yield return null


AssetBundles for sprites, or download the images from my server? I need to host several sprites in my server, and then have Unity download and use them. I have tested two methods AssetBundles If I pack my sprites into an AssetBundle, the bundle is about 4MB. It works fine. Download the images If I download the image bytes from my server, you can use those bytes to create a Sprite. Curiously, this is much, much smaller than an AssetBundle (just like 1.5MB). Both methods work. It seems pretty obvious that the second one offers an advantage due to reduced memory size. My questions are Why is the second method so much smaller? Is there any reason I'd rather use AssetBundles?


Adjust postion only in X axis I have two game objects named A and B, just as follows I want to move object B to this virtual line without any rotation so that the destination is B' . What I have are transformation of object A and B. I'm brand new to Unity3D and its APIs, so I don't know how should I get this done.


Animation shown as playing in the animator, but it doesn't show in game (Unity 2D C ) I have an Animator on this gameObject. The Animator hits one state when some parameters are true, it can transition to this state from any state. The parameters are fine because i can see in the animator that the state is getting hit when i want it to. The blue progress bar is showing, but the animation doesn't play on the screen in the game, it just shows the state before it. I have tried changing exit time, apply root motion, update mode, static batching. Nothing works Help pls internet gods As requested here are some images, first this is my animator and the transition that is set up (I have also tried this with the same transition but from flies buzzing directly and the same behaviour happens) Also here is what the animation state looks like and the preview of it, showing that it works in scene (just not in game) And here's how it behaves in game, as you can see the blue bar is progressing (and this is going into the state at the correct time, after dealing 2 damage to the fly, isDead gets set to true). However the only animation that plays is the fly buzzing one. Here's my code using System.Collections using System.Collections.Generic using UnityEngine public class FlyCombatAndFollow MonoBehaviour Space Header("References ") public Animator animator public GameObject fly Space Header("Character attributes ") public int maxHealth 2 int currentHealth Start is called before the first frame update void Start() currentHealth maxHealth public void TakeDamage(int damage) currentHealth damage Play hurt animation animator.SetTrigger("IsHit") animator.SetInteger("Hit", damage) if (currentHealth lt 0) StartCoroutine(Die()) public IEnumerator Die() Debug.Log("Fly died") play death animation animator.SetBool("IsDead", true) yield return new WaitForSeconds(1.0f) Disable fly Destroy(fly)


OnCollisionEnter only triggering if colliding object starts inside collider Despite the absurdly high number of "OnCollisionEnter not working" threads around the internet, no one else seems to have had this specific problem. To start off with, I have a spherical "shield" object around my ship, which has a shader designed to give off impact effects when hit by an object. To trigger the shader impact effect, you need to give it the position from which do the effect. So, the easiest way to do this is to give the shield a Collider and, whenever OnCollisionEnter is called, it sends the contact.point details to the shader. That's not the difficult part. The part that isn't working is that OnCollisionEnter is not being called when the laser bolt fired at the shield actually collides with the shield. Both the shield and the laser bolt have Sphere colliders, both are not triggers. Only the shield has a rigidbody, which is not kinematic. void OnCollisionEnter (Collision collision) Debug.Log (Time.time) if (collision.transform.tag "Impact") Debug.Log ("go") Does the shader stuff That script is attached to the shield object. Not only is "go" never being logged, but neither is the Time, so OnCollisionEnter is not being called. The odd thing about this scenario is that, OnCollisionEnter will be called by objects that begin inside the shield's collider so if I start the laser bolt inside the shield, then the function gets called as usual. But when I start the laser outside the shield and Translate it into the shield, nothing happens. For the life of me, I can not work out what's going wrong with it.


RenderPipleinManager.DORenderLoop Internal() Taking Unusual Amount In profiler I am developing for WebGL and for optimization purposes I have converted to URP. After converting the tri count has dramatically improved but the problem is my FPS is not improving. I tried to profile and found that RenderPipleinManager.DORenderLoop Internal() is taking 13 . Is this normal? An initial search brought that it was a bug and fixed in a later unity version. But even after converting to the latest lts 2019.4.20, i am getting the same issue.


How do you allow joints in a character to fall freely based on gravity? I am building a game in Unity in which a character falls down on death. Is it possible to make the joints fall and bend based on gravity? That is to leave the joints fully dependent on gravity and colliders and not any skeletal animation.


How do I add a "pointer" to my UI menu? I'm sure there has to be a simple answer to this, but frankly I cannot find anything about it anywhere on the internet, so I'm asking here. How do I add a pointer like this hand to the side of the currently selected UI button in my game? I tried using Unity's built in UI system to do this, using the "sprite swap" feature that changes sprites based on whether or not the button is currently selected. I made an image for my "Play" button, and then an image for when the play button was selected that included a pointer as part of the image, but the image would either resize when the button was selected, or the image was moved to the right to accommodate Unity's centering mechanic on the UI. Perhaps this wasn't so wrong, and I'm just not using the UI system correctly. Does a feature like this have to be hard coded into the UI design?


Unity Script and game not syncing after player respawn I have a health system for my player that looks like this public int fallBoundary 10 public int Health public int numOfHearts public Image hearts public Sprite fullHeart public Sprite emptyHeart void Update() if(Health gt numOfHearts) Health script works, why does heart display not? Health numOfHearts for (int i 0 i lt hearts.Length i ) if (i lt Health) hearts i .sprite fullHeart else hearts i .sprite emptyHeart if (i lt numOfHearts) hearts i .enabled true else hearts i .enabled false Unfortunately, after respawn, the hearts do not sync anymore. My debugging showed, that the elements of hearts still did their job, resetted and got replaced correctly. However, in my game, nothing changes after the respawn (should reset to full health and change if player gets damaged). For the respawn, I am loading my prefab, which I also checked (everything is there). To avoid confusion my hearts never reset to 0, but stay at 1. Player Prefab that loads during respawn Hearts after respawn


timeScale 0 doesnt stop all prefabs in unity As expected timeScale 0 can be used for stopping the game or pausing but when i make timeScale equal to 0 some prefabs still move and they can shoot bullets but addforce doesnt effect to bullets and they stop there. I know i can fix the problem on handling code of my prefabs but they are a lot. is there a good way to do the trick in my game? thank you for helping


How to apply Image effect only on specific part of objects? I need a way to censore part of characters' bodies like Cyberpunk 2077.this is mean I want to apply Image effect only to specific parts of bodies that you can see in the below Image


Unity "Find" can only be called from the main thread, but moving variables to the Start() function causes other errors pragma strict var collided false var thrust float var pizza GameObject.Find("pizza small").GetComponent. lt Rigidbody2D gt () function Start() hand pizza collision detection function OnCollisionStay2D(coll Collision2D) if (coll.gameObject.tag "Pizza") collided true Debug.Log("Hand Pizza") function Update() Input if (Input.GetKey(KeyCode.W)) Debug.Log("Up") transform.position.y 0.2 if (collided true) Adding force to the pizza pizza.velocity Vector3(0,15,0) else if (Input.GetKey(KeyCode.A) Input.GetKey("left")) Debug.Log("Left") transform.position.x 0.1 else if (Input.GetKey(KeyCode.D) Input.GetKey("right")) Debug.Log("Right") transform.position.x 0.1 else if (Input.GetKey(KeyCode.S) Input.GetKey("down")) Debug.Log("Down") transform.position.y 0.1 else if (transform.position.y gt 3.5) transform.position.y 0.25 else collided false Moving the 3 initial variable declarations into Start() removes the "Find can only be called from the main thread" error, but then they cannot be used in the Update() function due to variable scope. If I declare them initially and then set their values inside of the start function, new errors arise. var pizza function Start() pizza GameObject.Find("pizza small").GetComponent. lt Rigidbody2D gt () If I do that, then when I use pizza.velocity Vector3(0,15,0) It states that velocity is not a member of "object". I have no idea how to fix this, as the program works with no changes to my initial code, but does still give the error. This could be causing problems, as the rigidbody2D of the "pizza small" is pulled toward any non preexisting colliders that I add.


How can I reset the mouse axes when respawning a player? I am making a simple parkour game in which the camera will follow the mouse based on the mouse input axis the sensitivity. This works great, but when I want to reset my character to the start I cant figure out how to reset the mouse axis to zero, thus preventing me from resetting the camera rotation. I have tried Input.ResetInputAxes() , but that seems to only reset the buttons. using System.Collections using System using System.Collections.Generic using UnityEngine public class Movement MonoBehaviour public CharacterController characterController public Transform Player, camera public Camera cam public float XSensitivity, YSensitivity public bool grounded, jumping public float forwardSpeed, horizontalSpeed, jumpPower, gravity, sprintModifier HideInInspector public float sideSpeed, lastPlayerPosX, lastPlayerPosZ, jumpSpeed, verticalRotation, horizontalRotation private float isSprinting 1 void Update() This is where I get the axes float mouseX Input.GetAxis( quot Mouse X quot ), mouseY Input.GetAxis( quot Mouse Y quot ) This is how I rotate the player and camera verticalRotation mouseY YSensitivity Player.transform.localRotation Quaternion.Euler(0, horizontalRotation, 0) horizontalRotation mouseX XSensitivity cam.transform.localRotation Quaternion.Euler(verticalRotation, horizontalRotation, 0) if (Input.GetMouseButtonDown(0)) Cursor.lockState CursorLockMode.Locked float horizontal Input.GetAxis( quot Horizontal quot ), forward Input.GetAxis( quot Vertical quot ) grounded characterController.isGrounded if (grounded) if (Input.GetKey( quot left shift quot )) isSprinting sprintModifier if (Input.GetKey( quot left shift quot ) false) isSprinting 1f jumping false jumpSpeed 0 sideSpeed .75f else jumpSpeed (gravity 25) Time.deltaTime if (Input.GetKey( quot space quot )) sideSpeed .25f if (Input.GetAxisRaw( quot Jump quot ) ! 0 amp amp !jumping) jumping true jumpSpeed jumpPower lastPlayerPosX Player.transform.position.x lastPlayerPosZ Player.transform.position.z Vector3 motion new Vector3(horizontal horizontalSpeed sideSpeed, jumpSpeed, forward forwardSpeed isSprinting) characterController.Move((Player.transform.rotation motion) Time.deltaTime) void OnTriggerEnter(Collider col) if (col.gameObject.name quot deathbarrier quot ) Resets player to starting position Player.transform.position new Vector3(20.5f, 2, 22.5f) Is supposed to reset all inputs (including mouse) Input.ResetInputAxes() Sets camera rotation to 0, but only for one frame before the stored mouse axes change it camera.transform.rotation Quaternion.Euler(0, 0, 0) Thanks for any tips!


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


Asset workflow for Blender models? As a coder, I don't have much experience in asset creation workflow. I'm trying to figure out the best way to work effectively with Unity Blender combo. I don't export to FBX, I prefer to work directly with Blender files, with no intermediate export step. I have parts of the map that I place in the scene walls, decorations, whole rooms, etc I keep them in one Blender file. I have models of collectibles, like treasures, keys and the like I keep them in another Blender file. I have models of characters, which I keep in another one. It has worked OK so far, however I feel like it's not the best way to work. While it makes sense in Blender, it gets messy in Unity. What is an effective way of working with this combo? Or with asset import in a larger project, in general? Should I export to FBX instead of using Blender files directly? I'd like to understand now how and why to adapt the workflow than have everyone involved being slowed down later.


When an animation involves movement, where is the movement better to implement? For context, I am using Blender and Unity. Regarding the question, as an example, in some games, when you get hit, your character tucks a bit and gets knocked back a few distance. The tucking animation I want to implement in Blender but how about the knockback distance? Do you move your model in Blender (tuck and knockback), or do you do the tuck animation only (tuck in place) and then handle the knockback in Unity (basically triggering the tuck animation and then moving the model backwards a bit). My question basically is, what's commonly done and if there's any specific reason, why?


Coloring a Voronoi Graph Intro I want to convert a Voronoi Graph made with this awesome library by jceipek on GitHub into something I can work on. So far so good, this user provides with a demo to start with and shows how to generate the VG. Question How do I convert the VG (made by edges and that dot in the middle) into something that I can work with? Such as, after you generate some noise and apply to it (height), you colour the polygons based on it. Thoughts Something comes to my mind about instantiating meshes and tiles based on the edges and the position of the dot as a start, but it won't work if I can't "detect" the polygon. Expected result Image from this blog about Voronoi Mapping link What I have It is drawn with Gizmos (for visual debugging in Unity) I want to know how to color my polygons as in the expected image above. So I thought about doing a mesh or individual tile (and color it based on height afterwards but that is sauce for another question if needed) Edit of my progress To further explain this question I provide the next image. The image shows that I could use that position data somehow and turn that random polygon shape into a "tile" that will have a colour (mesh?) and possible data in it (script). I hope this helps otherwise let me know in the comments.


How to Implement a Timer for my Prefab for Roll a Ball Game (C in Unity) I am trying to create a public float timer that senses when the particular prefab has not been there for a certain amount of time. Then, it will replace that particular object. The goal is to randomly spawn 10 of these cubes across the game board. Then when the player picks one up, it disappears. Then after say, 2 seconds, a new cube should be placed on the board. Right now the Player already moves around the board just fine, and can pick up the cubes. When the player picks up a Cube, a new cube is automatically placed on the board with no delay. This script will be attached to the cube prefab directly. Apologies for the appearance of the code in advance. using UnityEngine using System.Collections public class RandomPlacement MonoBehaviour public GameObject prefab private GameObject prefabClone public int count private GameObject getCount public float timer 2 Instantiate the Prefab somewhere between 10, 10 on the x, and z planes, with a height of 0.5 in y. void Update () getCount GameObject.FindGameObjectsWithTag("PickUp") count getCount.Length if (count lt 10) timer Time.deltaTime if (timer lt 0f) Vector3 position new Vector3(Random.Range( 9.0f, 9.0f), 1.0f, Random.Range( 10.0f, 9.0f)) prefabClone Instantiate(prefab, position, Quaternion.identity) as GameObject timer 2 The code for the collision between the pick up and ball is given by void OnTriggerEnter(Collider other) if (other.gameObject.CompareTag("PickUp")) other.gameObject.SetActive(false) The "Cube" prefabs are all given the tag "PickUp" This script is attached to the "Player"


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


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?


How do I convert distance covered from meters to kilometers, in Unity? I am developing a game in Unity where I have to find a distance in kilometers, to find a passenger's fare based on the covered distance. This is what I have tried private Vector3 previousPosition public float cumulatedDistance void Awake() initialize to the current position previousPosition transform.position Update is called once per frame void Update () cumulatedDistance (transform.position previousPosition).magnitude previousPosition transform.position How can I determine the distance covered, and convert it to kilometers?


Variable value in inspector is not updating automatically? Something weird is happening when I change a variable value in script and hit play the var value doesn't update I have to reset the script in inspector. Is this normal? Aren't the values suppose to update when we hit play? The Simple Code I used to test this var a int 0 function Start () print(a)


VertexColor shader is not working correctly in built application I want to change the vertex colors of my mesh. The light sources must not affect the objects with this shader, its lighting must be determined only by its vertices colors, so I turned the Lighting Off. I use this simple shader Shader "VertexColored Simple" Properties MainTex ("Base (RGB)", 2D) "white" SubShader Pass ColorMaterial AmbientAndDiffuse Lighting Off SetTexture MainTex Combine texture primary Fallback "VertexLit" And this script using UnityEngine using System.Collections public class BehaviourScript MonoBehaviour void Start() Color exclrs new Color 11 new Color32(25, 25, 25, 255), new Color32(50, 50, 50, 255), new Color32(75, 75, 75, 255), new Color32(150, 150, 150, 255), new Color32(200, 200, 200, 255), new Color32(255, 255, 255, 255), new Color32(200, 200, 200, 255), new Color32(150, 150, 150, 255), new Color32(75, 75, 75, 75), new Color32(50, 50, 50, 255), new Color32(25, 25, 25, 255), Mesh mesh GetComponent lt MeshFilter gt ().mesh Vector3 vertices mesh.vertices Vector3 normals mesh.normals Color colors mesh.colors for(int i 0 i lt vertices.Length i ) for(int j 0 j lt 11 j , i ) colors i exclrs j i mesh.colors colors When the game is launched, in editor I can see this This is EXACTLY what I wanted to achieve! But in built for PC(x86) version I see this Why the results from the editor and from the built .exe differs? What should I do to see my effect in built version? Maybe I need to use an another shader?


Trouble GamePad input on iOS but works perfect on Android I am having trouble getting input from on iOS devices (iPhone 6 Plus and iPad). Here is my code, if (Input.GetKey (KeyCode.JoystickButton14)) A chr show "A" if (Input.GetKey (KeyCode.JoystickButton13)) B chr show "B" ........................................... if (Input.GetKey (KeyCode.JoystickButton11)) Select chr show "SELECT" And in OnGUI() GUI.Label (new Rect(0,0,100,100), "Pressed Button " chr show, guiStyle) Code works perfect on Android device. I also have tried following if (Input.GetButton ("JSButton")) JSButton chr show "JS Button 14" Please Help Me!


Custom Camera View Fustrum in Unity Is it possible in Unity to make some sort of bounding box (with a running application) within the current viewpoint of the actual screen? Let me explain I'm working on a project which uses a projection for visual output, the screen I am projecting on is smaller than the actual projectors resolution. This means that the unused spaces around the actual working application, are black and visually hidden. Made an image for exra explanation As i'm new to Unity and still learning, I'm not sure if this is even possible because of the use of camera's and environment. I happen to know that it's possible in three.js. But if anyone could point me in the right direction or explain that it's impossible would be much appreciated because I'm not sure where to look anymore!


How can I get Unity to do letterbox pillarbox to maintain aspect ratio? I'd like my game to have the same aspect ratio at all cost, including keeping all UI elements fixed in the same place. I'm totally ok with losing screen space in the interest of fixing the aspect ratio.


Controlling Instantiation I have an problem where I instantiate a GameObject and it keeps on instantiating a million times over, even though I put the line of code under the start function. I am trying to have the player collide with the coin(then a point is added to your score) , then the coin deletes itself and then re instantiates at a random coordinate, but I cant get past the initial instantiation. using System.Collections using System.Collections.Generic using UnityEngine public class Coin MonoBehaviour public GameObject coins Vector2 randomPosition public UIScript UIScript Use this for initialization void Start () UIScript GameObject.FindWithTag("UI").GetComponent lt UIScript gt () randomPosition new Vector2(Random.Range( 8f, 8), Random.Range( 4f, 4f)) Instantiate(coins, randomPosition, Quaternion.identity) Update is called once per frame void Update () private void OnTriggerEnter2D(Collider2D coinCollision) switch(coinCollision.tag) case "Player" collisionWithPlayer() break private void collisionWithPlayer() UIScript.highScore UIScript.highScore 1 Object.Destroy(coins)


How to handle day and night in a 2D sprite game Do I need to draw, for example, a tree how it looks in the day (normal colors) and how it looks at night (colors aligned according to the moonlight)? Or does Unity have a function for that?


Draw a sphere with a custom material from script How can I spawn or draw a sphere with a custom material with a script? So far I've tried using Gizmos.DrawSphere, but I can't find a way to control the material used to draw it. I would like to draw it with a material with some specularity, around 0.5.


2DRaycast is shooting slightly in wrong directions I wanted just a simple 2DRaycast, which points from my character to my mousePointer. So I found the following code in the Internet, most people seem to use it like that. So I tried it, but it isn't working for me like it is supposed to do, check the screenshot below. The direction is kinda weird, so I tried some variants of the variables and tried with Normalize, which didn't solve the problem. Vector2 test new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y) Vector3 test1 (Camera.main.ScreenToWorldPoint (Input.mousePosition)) test.Normalize () RaycastHit2D hit Physics2D.Raycast (transform.position, test) Debug.DrawRay (transform.position, test, Color.red) I tested both variables, test and test1, same things happen, even with Normalize and without it. The following Screenshot shows, what happens (The red thing is the mouse pointer). Edit Solution Vector2 test new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y) Vector3 test1 (Camera.main.ScreenToWorldPoint (Input.mousePosition)) test.Normalize () RaycastHit2D hit Physics2D.Raycast (transform.position, test1 transform.position) Debug.DrawRay (transform.position, test1 transform.position, Color.red) I use now the second variable, because we need the Vector3 here, because we substract with Transform.position which is a Vector3.


How to debug fatal signal 11 code 2 in UnityMain? i have searched for the fatal signal caused by Render or GxDriver, FlashMuller in unity forum says it's google play the error 08 03 14 59 47.503 32020 32092 ? A libc Fatal signal 11 (SIGSEGV), code 2, fault addr 0xcbe8dffc in tid 32092 (UnityMain), pid 32020 (com.tuo3.alive) 08 03 14 59 47.533 32121 32121 ? A DEBUG Build fingerprint 'OnePlus OnePlus5T OnePlus5T 8.1.0 OPM1.171019.011 1807181208 user release keys' Revision '0' ABI 'arm' pid 32020, tid 32092, name UnityMain gt gt gt com.tuo3.alive lt lt lt 08 03 14 59 47.544 32121 32121 ? A DEBUG backtrace 00 pc 000575d0 system lib libc.so (je arena tcache fill small 71) 01 pc 00077919 system lib libc.so (je tcache alloc small hard 16) 02 pc 00058fc7 system lib libc.so (je arena palloc 1650) 03 pc 00069bd1 system lib libc.so (imemalign 1164) 04 pc 0006d373 system lib libc.so (je memalign 26) 05 pc 001d6f18 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (UnityDefaultAllocator lt LowLevelAllocator gt Allocate(unsigned int, int) 24) 06 pc 001da888 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (MemoryManager Allocate(unsigned int, unsigned int, MemLabelId const amp , AllocateOptions, char const , int) 852) 07 pc 001da254 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (malloc internal(unsigned int, unsigned int, MemLabelId const amp , AllocateOptions, char const , int) 128) 08 pc 00193bc8 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (core StringStorageDefault lt char gt assign(char const , unsigned int) 180) 09 pc 00a350bc data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so ( gnu cxx hashtable lt std pair lt core basic string lt char, core StringStorageDefault lt char gt gt const, ZipCentralDirectory PathDescriptor gt , core basic string lt char, core StringStorageDefault lt char gt gt , gnu cxx hash lt core basic string lt char, core StringStorageDefault lt char gt gt gt , std Select1st lt gnu cxx hash gt , std equal to lt core basic string lt char, core StringStorageDefault lt char gt gt gt , std allocator, lt ZipCentralDirectory 10 pc 00a34adc data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so ( ZZN19ZipCentralDirectory20readCentralDirectoryEvEN3 08 invokeERK15FileSystemEntryR12FileAccessorPKcRKN3zip4CDFDEPv 508) 11 pc 00a38160 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (zip CentralDirectory Enumerate(bool ( )(FileSystemEntry const amp , FileAccessor amp , char const , zip CDFD const amp , void ), void ) 804) 12 pc 00a348d0 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (ZipCentralDirectory readCentralDirectory() 20) 13 pc 00a26630 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (apkAddCentralDirectory 84) 14 pc 00a19074 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (Mount(char const ) 84) 15 pc 00a090dc data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (UnityInitApplication() 216) 16 pc 00a0a660 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (UnityPlayerLoop() 264) 17 pc 00a0cc68 data app com.tuo3.alive VZWALBY70nH dSDIQa rKA lib arm libunity.so (nativeRender( JNIEnv , jobject ) 228) 18 pc 000114cb data app com.tuo3.alive VZWALBY70nH dSDIQa rKA oat arm base.odex (offset 0x10000) More discussion 2


How to animate material alpha property via script? I am creating Animator OverrideController via script based on current controller assigned to animator component. I have created animation curve for position and it works. When i try to animate transparency (material color alpha) it does not work (it does not make any effect, however in Animation Dopesheet there is yellow line "Object name Material.Color.a (Missing!)"). Did I fail to properly access this property or is it the consequence that creating animation via script works only for legacy animations with Animation component? using System.Collections using System.Collections.Generic using UnityEngine public class AnimationScript MonoBehaviour void Start() AnimationClip clip new AnimationClip() AnimationCurve curve AnimationCurve.EaseInOut(0.0f, transform.position.x, 1.0f, transform.position.x) clip.SetCurve("", typeof(Transform), "localPosition.x", curve) curve AnimationCurve.Linear(0.0f, 1.0f, 1.0f, 0.0f) clip.SetCurve("", typeof(Material), " Color.a", curve) Animator anim GetComponent lt Animator gt () AnimatorOverrideController animatorOverrideController new AnimatorOverrideController(anim.runtimeAnimatorController) "loop" is the name of clip not name of state animatorOverrideController "loop" clip anim.runtimeAnimatorController animatorOverrideController However analogous code for legacy Animation component works void Start() Animation anim GetComponent lt Animation gt () AnimationCurve curve create a new AnimationClip AnimationClip clip new AnimationClip() clip.legacy true update the clip to a change color curve AnimationCurve.Linear(0.0f, 1.0f, 2.0f, 0.0f) clip.SetCurve("", typeof(Material), " Color.a", curve) now animate the GameObject anim.AddClip(clip, clip.name) anim.Play(clip.name) What am I missing and why is first script not working?


Implementing my own UI sprite class in Unity using shaders where and how to position the sprites For learning purposes, I am trying to implement my own UI classes in Unity "from scratch", in the GPU using shaders. I mean, I am trying to use simple 2D sprites either positioned via shaders or created within the geometry shaders. These sprites should be, of course, displayed above all else. I know how to create or translate the sprites within the shader. However, I am struggling with a couple of conceptual issues 1) where exactly, relative to the camera (or to the near frustum plane), should the UI sprites be positioned? I man, thinking of the Z axis as being the camera.forward, what is the correct default distance to display the sprites at (assuming that at that location, the sprite texture would be the closes to its correct 100 zoom scale). 2) for the correct positioning rotation, would it just be the case of, every frame, calculating in the shader such correct world position of the sprite in relation to the camera near frustum plane, and then making the sprite rotate towards the camera? Or is there a better way of doing that, i.e. disregarding world position at all and going directly for the screen position of the sprites within the shaders, since the final step of shaders is to paint the pixels in screen space? Thanks for your suggestions!


How can I restart an animation? The first time the player clicks a button, my animation plays properly. The problem is that when the player presses the button a second time, the animation does not play. Here is the code I'm using to control my animation public Animator anim public Animator animsfirst public Animator animssecond public Animator animsthird public Animator reanimsfirst public Animator reanimssecond public Animator reanimsthird public Animator closeinstruct public void instructionpanel() (instruction panel open animation) anim.enabled true when button click instruction panel open animsfirst.enabled true animssecond.enabled true animsthird.enabled true public void closeinstructionpanel() (instruction panel close animation) Debug.Log("animationrun") when button click instruction panel close reanimsfirst.Play("freverse") reanimssecond.Play("srevese") reanimsthird.Play("lreverse") closeinstruct.Play("clreverse") Here is the animator controller setup for the animsfirst object And for the reanimsfirst object How can I resolve this issue?


How do you deal with transparent fonts that you want to be white? I'm a bit of a total amateur, but I thought I would learn how to make a simple game during quarantine. However, I stumbled into a problem with fonts. I'm thinking about using the free font quot Pixelmania quot to show a score at the top of the screen. But the font is transparent! How do I make the inner part of the font white? Do I have to manually edit the font file myself? Or is there an easier way?


Is it possible to capture screenshots in headless (no graphics) mode in unity? I am trying to capture screenshots while running unity simulation in headless mode (no graphics), if anybody tried to do the same and it worked, please share how could you make it work.


Get object position on texture I'm rendering a 3D object to texture (2048x1600) and show this texture on a panel (1600x285) using a RawImage (2048x1600) component as child. This texture is rendered successfully on screen. This 3d object contains several mountpoints as empty objects. Now I want to show several sprites to visualize those mountpoints on the texture (panel) at their corresponding screen position (must not pixel perfect). I tried several camera transforms, but could not get the correct position values var main camera.WorldToScreenPoint(slot.mountpoint.position) Debug.Log("Maincam screenpos " main.ToString()) RectTransform rect this.GetComponentInParent lt RectTransform gt () Debug.Log("Rect size delta " rect.sizeDelta.ToString()) Vector2 viewPos camera.WorldToViewportPoint(slot.mountpoint.position) Debug.Log("Viewport pos " viewPos.ToString()) Vector2 localPos new Vector2(viewPos.x rect.sizeDelta.x, viewPos.y rect.sizeDelta.y) Debug.Log("Viewport pos local " localPos.ToString()) How I could realize this?


My character can jump even when its not grounded Here is the code using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMovementscript MonoBehaviour vars public CharacterController controller public float speed 12f Vector3 velocity public float gravity 9.81f public Transform groundCheck public float groundDistanace 0.4f public LayerMask groundMask public float jumpHeight 3f bool isGrounded Update is called once per frame void Update() isGrounded Physics.CheckSphere(groundCheck.position, groundDistanace, groundMask) if(isGrounded amp amp velocity.y lt 0) velocity.y 2f float x Input.GetAxis( quot Horizontal quot ) float z Input.GetAxis( quot Vertical quot ) Vector3 move transform.right x transform.forward z controller.Move(move speed Time.deltaTime) if(Input.GetButtonDown( quot Jump quot ) amp amp isGrounded) velocity.y Mathf.Sqrt(jumpHeight 2f gravity) velocity.y gravity Time.deltaTime controller.Move(velocity Time.deltaTime) character controller and etc


How to instantiate an object to a randomised Vector2 So I'm trying to make a little game where squares randomly spawn around a set area and you have to tap them. The game is 2D. I'm having trouble using my randomly generated x and y floats to instantiate a cube in the game. Here is my code pragma strict public var play false public var xpos float public var ypos float public var cube GameObject function Start () function Update () function Game () xpos Random.Range( 10f,10f) ypos Random.Range( 4.45f,4.45f) Instantiate(cube, new Vector2(xpos, ypos)) And here's the error! Assets gameController.js(18,20) BCE0023 No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.Rigidbody, UnityEngine.Vector2)' was found. Any help would be appreciated. Thanks! Alex


ScriptableObject's custom objects begin reset to default? I'm using ScriptableObjects as a way to serialize objects that I work with in an editor script. I save them as assets using AssetDatabase.CreateAsset and get them resetted It is saving correctly native c class objects like strings, primitives and arrays of primitives. The problem is that my ScriptableObject also contains objects of custom classes and structs of my code. These custom objects are being set to default() (ie. value types being set to 0 and reference types to null) every time the code is recompiled and when the editor is restarted (while the primitive variables still have the right saved value). Even with blittable structs the problem persists. Is that expected? Edit with some code to contextualize StructLayout(LayoutKind.Sequential, Pack 1) public struct MeshHeader public int numBones public int numVerts public class MyClass public string s1 get set public string s2 get set public class MySO ScriptableObject public int myInt OK public int myArr OK These 2 variables will have their value reset after any recompilation of the code public MeshHeader meshHeader This will become 0 0 public MyClass myClass This will become null public static void SaveMySO(MeshHeader h, MyClass c) var mySO ScriptableObject.CreateInstance lt MySO gt () mySO.myInt 10 mySO.myArr new int 2 9, 8 mySO.meshHeader h mySO.myClass c AssetDatabase.CreateAsset(mySO, quot Assets foo.asset quot ) public static MySO LoadMySO() return AssetDatabase.LoadAssetAtPath lt MySO gt ( quot Assets foo.asset quot ) When I call MySO.SaveMySO it will save the ScriptableObject. However if I run MySO.LoadMySO after any code recompilation between these two calls, it will have both meshHeader and myClass values set to default, which will be 0 and null respectively while still holding the right values for myInt and myArr.


Texture doesn't scale and repeat I wrote the script for automatic repetition of texture background. To save it I typed Cmd S. I dragged and dropped the script to Background in Hierarchy. When hit play button the texture doesn't scale and doesn't repeat itself. What is it that I am doing wrong? using System.Collections public class TiledBackground MonoBehaviour public int textureSize 32 void start() var newWidth Mathf.Ceil (Screen.width (textureSize PixelPerfectCamera.scale)) var newHeight Mathf.Ceil (Screen.height (textureSize PixelPerfectCamera.scale)) transform.localScale new Vector3(newWidth textureSize, newHeight textureSize, 1) GetComponent lt Renderer gt ().material.mainTextureScale new Vector3(newWidth, newHeight, 1) Expected Results Results that I'm getting are same as before. Script doesn't seem to work


Strange Light Angles in Unity I'm quite sure that I'm missing something very simple here, but I'm a complete Unity noob and I absolutely can't figure out what I'm seeing. I'm trying to light a sphere from both sides, perpendicular to the camera angle, to create an effect where each side of the sphere is illuminated but there's a strip of darkness down the center. Instead, I'm getting really weird angles from the two lights. My setup (I've quintuple checked all numbers)... A single sphere (textured like Mars) at position (0, 0, 0). An orthographic camera pointed at it from position (0, 0, 20) and rotation (0, 0, 0). Two Point lights at ( 5, 0, 0) and (5, 0, 0), with the same intensity and all other light settings. By my understanding, that should position each light equidistant from the sphere, exactly on either side from the camera's POV. Sort of like a capital " T " configuration. In theory their shine on the sphere should be mirrored on each side, complimentary angles toward the sphere from exactly horizontal. Instead, I'm getting this Left Light... Right Light... So, instead of being horizontal and mirrored, it appears as though the Right Light is significantly closer to the camera than the Left Light along the Z axis, and they both seem to be somewhat below the vertical center of the sphere (despite all elements having a Y value of zero). Even weirder, viewing it in the Scene panel from above, there's a spiral pattern of darkness when both lights are on, rather than a single dark band between them... Can someone help me out here? Does Unity handle perspective in a way I'm not getting, or have I messed up my arrangement of elements? And aside from eyeballing it, what positions should I use to create the effect I'm going for?


How can I distribute the source code of my project without the imported assets? I have a Unity project that uses some assets that I downloaded for free in the Unity asset store. I would like to make my project open source and distribute its source code in GitHub. But, I do not want to put the assets I downloaded in my GitHub, since they are not mine. Also, these assets take a lot of space in my repository. Can I arrange my project in such a way that any user who downloads it will be automatically sent to the Unity asset store to download the required assets? I found that it works well with TextMesh Pro I can remove the TextMesh Pro folder from my Assets folder, and then when I open the project in Unity, it prompts me to re import TextMesh Pro, and when the import is done, the game works well. Is it possible to achieve a similar effect with other assets?


Box collider pushes me out of it's area slowly, I can pass through it if moving quickly I am new to Unity. I Setup a character in unity2D with a rigidbody. I had the scale off my sprites set to 100 pixels per unit. At this scale, my rigidbody character stood on top of platforms and could not pass through walls containing box colliders. I decided, that to make things easier, I would change all sprites to 1 pixel per unit. After doing so, I scaled everything (variables, sizes, etc.) by 100. I confirmed that the box colliders on both the caharcters, floor, and walls, are all in the same places, relatively. The box colliders on the floors still work, but the wall box colliders behave differently. When I walk into a wall, the wall slowly pushes me in a direction (depending on whether or not my character has walked through half the wall or not). The wall should be stopping my motion completely. The code is very simple, but this is what I use to move if (Input.GetKey (KeyCode.D)) transform.Translate (Vector2.right moveOffset Time.deltaTime) transform.localScale new Vector3(1,1,1) anim.SetBool("moving",true) Do note that the moveOffset variable, was scaled by 100 after the change. Thanks in advanced!


Unity 2D Object following target instead of moving towards it I'm making a 2D game with Unity that's based on avoiding evading enemies. The problem i'm facing right now is i can't get the enemies to move towards the target player, but instead they follow it. So they never actually "attack" because they only follow it around and don't even come close to it. Also if the target player stops moving, they stop moving. I'm wondering if it could be something in my scene, since i've asked this question on multiple forum threads in the unity forums section and everyone seems to answer with the same lines of code. Extra information My enemy has a box collider on it with no rigidbody 2D. My player has a box collider on it with a rigidbody 2D. Kind regards. using UnityEngine using System.Collections public class BeeBehaviour MonoBehaviour public Transform target public float moveSpeed 3 void Start () target GameObject.Find("MainObject").transform void Update () Chase() void Chase () Vector3 targetDirection target.position transform.position transform.position targetDirection moveSpeed Time.deltaTime


How to orbit an object at certain speed in Unity? I want to move an object around a circle. So I have this code below static public int theta 0 void Update() Vector3 position this.transform.position position.x 0 50 Mathf.Cos (theta) Time.deltaTime position.y 0 50 Mathf.Sin (theta) Time.deltaTime this.transform.position position theta 1 The object orbits, but it orbits so fast!!! I want the object to rotate like 1 orbit per second only. How to do that? ANSWER TO THIS PROBLEM, THANKS! static public int theta 0 void Update() Vector3 position this.transform.position position.x 0 50 Mathf.Cos (theta) Time.deltaTime position.y 0 50 Mathf.Sin (theta) Time.deltaTime this.transform.position position theta 1 Time.deltaTime


Handmade Terrain vs. Terrain Engine in Unity? I'm planning a game right now, to be made in Unity, and I'm trying to decide how I'll approach the basic level construction. Essentially, my game takes place on an island in an infinite ocean, very similar to Wuhu Island My question concerns all the stuff heightmaps can't handle. To use Wuhu Island as an example, note the lighthouse cliff, and the nearby similarly jutting out cliff. The volcano itself is also empty, and there are some tunnels through it on the other side. I was thinking I would just model the entire island myself in Cinema 4D, but as I read more about the terrain system, it seems Unity has special optimized rendering systems in place for terrain objects. Would I be shooting myself in the foot performance wise if I just built my island entirely by hand? This will be for mobile, so the little stuff might well count. Am I even approaching this question correctly if not, how would you best go about creating (something very close to) Wuhu Island as a level in Unity? Is there any reason for me to not do it as one mesh? I have effectively zero experience with 3D game dev only rendered 3D video stills for other applications, so this is a learning process.


SocketException No connection could be made because the target machine actively refused it I am working on connecting a client to a server using socket connection. I have a button, when I click on the button, it's giving the below exception in Unity. "SocketException No connection could be made because the target machine actively refused it.". What will be the issue? Can anyboady help me out? Below is the code I have written for connecting to the server internal Boolean socketReady false NetworkStream theStream StreamWriter writer StreamReader reader try connect new TcpClient (host, port) theStream connect.GetStream () writer new StreamWriter (theStream) reader new StreamReader (theStream) return true socketReady true catch(ObjectDisposedException) return false


Locomotion system with irregular IK Im having some trouble with locomtions (Unity3D asset) IK feet placement. I wouldn't call it "very bad", but it definitely isn't as smooth as the Locomotion System Examples. The strangest behavior (that is probably linked to the problem) are the rendered foot markers that "guess" where the characters next step will be. In the demo, they are smooth and stable. However, in my project, they keep flickering, as if Locomotion changed its "guess" every frame, and sometimes, the automatic defined step is too close to the previous step, or sometimes, too distant, creating a very irregular pattern. The configuration is (apparently)Identical to the human example in the demo, so I guessing the problem is my model and or animation. Problem is, I can't figure out was it is S Has anyone experienced the same problem? I uploaded a video of the bug to help interpreting the issue (excuse the HORRIBLE quality, I was in a hurry).


Draw a perfect circle in UI This is the problem I have. I have created a shader that draws circle. But depending on the distance from the camera thickness changes. Is it possible to keep thickness constant?


Performance overhead on Non POT Texture in POT Atlas Using atlas, we can reduce memory and draw call. And the atlas is usally POT(Power of Two) Texture. And I know non POT texture have a lot of GPU and memory performance overhead. (link) I have many rendering objects and they have also their non POT textures. And I packed the images into one 1024 1024 POT atlas and applied them to the objects. (each textures is non pot, and the atlas is pot texture) In this case, Can I avoid non pot texture overhead? Are they treated as non pot texture or not internally?


Why can't I use the operator ' ' with Vector3s? I am trying to get a rectangle to move between two positions which I refer to as positionA and positionB. Both are of type Vector3. The rectangle moves just fine. However, when it reaches positionB it does not move in the opposite direction, like it should. I went back into the code to take a look. I came to the conclusion that as the object moved, the if statements in the code missed the frame in which the rects position was equal to positionB. I decided to modify the code to reverse direction if the rects position is greater than or equal to positionB. My code is not too long, so I will display it below using UnityEngine using System.Collections public class Rectangle MonoBehaviour private Vector3 positionA new Vector3( 0.97f, 4.28f) Start position private Vector3 positionB new Vector3(11.87f, 4.28f) End position private Transform rect tfm private bool atPosA false, atPosB false public Vector2 speed new Vector2(1f, 0f) private void Start() rect tfm gameObject.GetComponent lt Transform gt () rect tfm.position positionA atPosA true private void Update() NOTE Infinite loops can cause Unity to crash Move() private void Move() if ( atPosA) rect tfm.Translate(speed Time.deltaTime) if ( rect tfm.position positionB) atPosA false atPosB true if ( atPosB) rect tfm.Translate( speed Time.deltaTime) if ( rect tfm.position positionA) atPosA true atPosB false When I changed it, however, it warned me of the following error message Operator cannot be applied to operands of type Vector3 and Vector3. This confuses me for two reasons first, both values are of the same data type. Second, using the comparison operator( ) on the two values works without error. Why can't I use the operator gt with Vector3s?


What does the "DXGI Flip Model Swapchain" setting in Unity do exactly? I'm preparing a Standalone Unity game for Windows and Mac. There is a checkbox in Player Settings called "Use DXGI Flip Model Swapchain for D3D11", which seems disabled by default. Needless to say, I don't understand this setting at all. The Unity documentation has this Flip model ensures the best performance. Disable this to fallback to Windows 7 style BltBlt model. This setting affects only D3D11 graphics API on Windows 8.1 or greater. Note that even if the flip model is enabled, the BltBlt model will be used in exclusive fullscreen mode to reduce input latency. It doesn't exactly tell me what this is (I literally don't know what most of that means) but it almost seems like there is no reason not to have it enabled. Can someone explain the pros and cons of this setting? Under what scenarios would I want to enable disable it? Since disabling it fallbacks to the Windows 7 style, it almost gives the impression that enabling this might make the game less compatible on Windows 7?


How many directional lights in Unity In Unity, how many directional lights can be active at once? 1, 2, 4, or 8? I thought 2, but I have searched and cannot confirm.


Added tiles not loading in run time So I have a game object MapGenerator and 2 attached scripts MapGenerator.cs and Lexicon.cs. I need to be able to access a couple variables in Lexicon.cs from MapGenerator.cs, so I imported it with void Awake() GameObject gameObject new GameObject( quot Lexicon quot ) lexicon gameObject.AddComponent lt Lexicon gt () Now, this allows me to pull variables from Lexicon, and I am able to do that successfully for the most part. However, the public fields that are being set from Unity (tiles sprites) are not being pulled in. They just show up as null. Example scenario public class Lexicon MonoBehaviour public Tile thiccTile public Tile thiccTile2 public Tile thiccTile3 private string fact quot Yummy porchop quot private string favoritefact private Tile favoritetile public Lexicon() favoritetile thiccTile2 this guy is public and set in unity under components. favoritefact fact public Tile Favoritetile get return favoritetile set favoritetile value public string Favoritefact get return favoritefact set favoritefact value Start() UnityEngine.Debug.Log(lexicon.Favoritefact) quot Yummy porchop quot UnityEngine.Debug.Log(lexicon.Favoritetile) null My first thought was it was because I never explicitly call Lexicon(). However, since favoritefact works, im guessing the gameobject stuff is enough? Anyway, how can I fix this? EDIT This is where I set the values (Different variable names but you get the idea)


How to add tiles randomly? I made a set of 10 different "ocean" tiles, all interchangeable with one another, and I'd like to randomly attach these 10 different tiles together in different combinations over a large rectangular area what would be the best way to do so? I've thought of just adding each sprite into a script and then calling a for foreach loop to add it into my world but that seems extremely expensive since I'd be adding over 1000 sprites. I don't want to reduce the number of sprites I have to add, I'm just seeing if there's a typical way people do this sort of thing.


UNITY passing metalic map from Blender to Unity automatically? I have .blend file contains very basic material shader structure (no fancy nodes), just add some textures (diffuse, normal, roughness, metallic etc) . When i imported the .blend file as prefab in unity (and copy all necessary texture map to unity asset folder ) , the blender shader can pass albedo and normal maps (automatically) without problem. But it never be able to carry metallic map (or any other maps) Right now i have to rebuild the metallic map within unity manually. I'm just curious if unity can only recognize albedo and normal map from blender shader ? How about the other map ? How about metallic or smoothness roughness etc ?


Gun clipping through arm during third person animation I have been setting up a Blend Tree for motion animation in Unity. I'm using Root Motion for now. I parented the gun to the root of the player and then I use OnAnimatorIK to lock the two hands in position. The overall looks and feel is great by my standards. The only thing I am disappointed about is the butt of the gun clips through the character's upper arm when running. Is there a way to crop this in the game? I'd like to avoid going into a 3d Editor and making it two separate meshes which I could then I guess somehow disable. I'm hoping there is a better way to handle this situation. Also I wonder if the gun being parented to the Root player object is wise. I had tried parenting to the 'right hand' bone but this made the gun point upwards about 45 and looked silly.


I cant Instantiate a particle system for the duration of a subroutine I have a sub routine that lowers the timescale to 0.3 for 2 seconds. while in those two seconds i would like to spawn a trail of particles that follow the player. I can get the particles working if I attach them to the player in the editor but I'm having trouble spawning them at the start of the time slow down. The slow down subroutine works fine its just the particles that i cant spawn. Thanks, any help is appreciated. public GameObject particles public Transform playerParticles Start is called before the first frame update void Start() slowDownActivateNoise GetComponent lt AudioSource gt () void Update() if (hasCollided) if (!activated) StartCoroutine("SlowDownActive") public IEnumerator SlowDownActive() Debug.Log("subroutine Start") activated true Instantiate(particles, playerParticles.position, playerParticles.rotation) Time.timeScale 0.3f GetComponent lt Collider gt ().enabled false yield return new WaitForSeconds(2) GetComponent lt Collider gt ().enabled true Time.timeScale 1.0f hasCollided false activated false Debug.Log("subroutine end")


Controlling loop frequency in a Coroutine I want this coroutine to execute continuously and change the colors. But right now it just waits 1 second at the start and then loops the Coroutine very fast. So my question is how can I loop the Coroutine every 2 seconds. public class control MonoBehaviour public bool gravity false public bool m isRunning false public SpriteRenderer m spriteRenderer private Rigidbody2D rb private void Update() if (gravity) rb.gravityScale 1 StartCoroutine("Changecolor", 3f) private void Start() m spriteRenderer this.GetComponent lt SpriteRenderer gt () rb GetComponent lt Rigidbody2D gt () private IEnumerator Changecolor() lt this coroutine yield return new WaitForSeconds(1) int random Random.Range(1, 4) if (random 1) m spriteRenderer.color Color.blue else if (random 2) m spriteRenderer.color Color.red else if (random 3) m spriteRenderer.color Color.green else m spriteRenderer.color Color.yellow this.StartCoroutine("Changecolor", 3f) private void OnMouseDown() gravity true


How to store an array of prefabs together with configuration parameters I have attached the following script to a number of weapon prefabs public class WeaponScript MonoBehaviour public enum Direction Right, Straight, Left public Direction weaponDir void Start () prepareDirection (weaponDir) void prepareDirection(Direction dir) if (dir Direction.Straight) transform.localEulerAngles new Vector3 (0, 0, 0) else if(dir Direction.Left) transform.localEulerAngles new Vector3 (0, 0, 30) else if(dir Direction.Right) transform.localEulerAngles new Vector3 (0, 0, 30) I also added the following script to an empty game object SetupWeapon public class SetupWeaponsScript MonoBehaviour public GameObject weaponPrefabs public GameObject weapons void Start () weapons new GameObject weaponPrefabs.Length for (int i 0 i lt weaponPrefabs.Length i ) weapons i Instantiate(weaponPrefabs i ) as GameObject When I select my SetupWeapon object, I am able to populate the weaponPrefabs array with the weapon prefabs I want to use, but I can't directly alter their parameters in that same inspector view. I want to be able to override the direction of each weapon prefab in the list, rather than use the value that's stored on the prefab itself. How can I create the weaponsSetupScript in such a way that I can set the direction enum for each weapon entry at the same time that I set select the prefab in the editor? I believe it might have something to do with inheritance, just not too sure how to go about it though.