What controls the platform override codes in AudioClip (and maybe other Assets) .meta files? My game needs to use Unity 2019.3 for the console versions, and 2020.3 for the mobile ports. The Console Project is the master project. Virtually any changes done to it are replicated to the Mobile project. I would like to setup import overrides for Android (e.g. the compression quality for my soundtracks). To be consistent, I perform this change in my Console Project using the quot Override for Android quot checkbox (which affects the .meta file), and then replicate the change to the Mobile Project (a program checks for differences between both projects and applies most changes). Ideally, the Mobile Project will now reflect the compression quality I want for said soundtracks, but it actually doesn't in fact, the quot Override for Android quot checkbox does not appear to be checked in the Mobile Project, despite having a .meta file identical to the Console Project. I digged into the .meta files, and noticed that when I use quot Override for Android quot in my Console Project, the .meta file adds an entry code 27 platformSettingOverrides 27 loadType 2 sampleRateSetting 0 sampleRateOverride 44100 compressionFormat 1 quality 0.5 conversionMode 0 But, when I go to my Mobile Project and check the checkbox, it adds an entry coded 7 platformSettingOverrides 7 loadType 2 sampleRateSetting 0 sampleRateOverride 44100 compressionFormat 1 quality 0.5 conversionMode 0 I don't understand this inconsistency. Does anyone have any insight on the exact conditions rules Unity uses for the platform codes in the .meta files? I can only think of a few dubious reasons Maybe they changed from 2019 to 2020. My Console Project actually supports more platforms than the Mobile Project (the consoles, obviously), so maybe they quot pushed quot the Android code from 7 to 27. It is not the end of the world I could make a script that duplicates the settings of 27 into 7... But only if this behaviour is predictable or consistent. So my question is, what is Unity's logic behind the choice of these platform codes? Note so far I've only found this behaviour on AudioClip files. With Textures, I see that it actually uses the name of the platform in the .meta file, so the settings do work thankfully, but it is even more puzzling because now I don't understand why Textures and AudioClips use different conventions to begin with... What other Asset Type has numeric conventions?


How to use AssetBundles with Unity WebGL I have a Unity WebGL project that tries to load AssetBundles, but I get an error Unable to open archive file http localhost 50212 StreamingAssets Bundles language english The code that creates the AssetBundles using UnityEditor using System.IO using UnityEngine public class JC Bundler Editor MenuItem("Assets Build AssetBundles") static void BuildAllAssetBundles() string path Path.Combine(Application.streamingAssetsPath, JC Bundles.Directory) if (!Directory.Exists(path)) Directory.CreateDirectory(path) BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget) AssetDatabase.Refresh() I can see the AssetBundles do get created and it works on other Windows Standalone and Android platforms. The code that read the AssetBundle public void PrepareLanguageAssets(SystemLanguage language, UnityAction onDone, UnityAction onFail) StartCoroutine(LoadBundle("language " language, bundle gt if (bundle null) onFail() else if (languageBundle) languageBundle.Unload(true) languageBundle bundle onDone() )) public void LoadLanguageAsset lt T gt (String name, UnityAction lt T gt callback) where T UnityEngine.Object StartCoroutine(LoadAsset(languageBundle, name, callback)) IEnumerator LoadAsset lt T gt (AssetBundle bundle, string objectNameToLoad, UnityAction lt T gt callback) where T UnityEngine.Object AssetBundleRequest asset bundle.LoadAssetAsync lt T gt (objectNameToLoad) yield return asset callback(asset.asset as T) So when I switch my Unity Editor Platform to WebGL and do a "Build And Run" with the same project I see the above mentioned error. How can I load AssetBundles in WebGL?


Inconsistent CapsuleCast Collision behavior when a GameObject is selected My gameobject has a CapsuleCollider and I use CapsuleCast to check for horizontal collisions when moving horizontally so the gameobject won't pass thru obstacles. It works 100 of the time except when I select the gameobject in Hierarchy. When I have the gameobject selected, whenever I try to bump a wall continuously, it shakes jitters until it eventually goes thru the wall. But this only happens when I have the object selected in Hierarchy. If I click on the scene so that the object is not selected and do the exact same thing (bump a wall continuously), there is no shaking jitter and it doesn't pass thru the wall no matter how long I bump it. This passing in the wall when selected is also consistent. Hundred percent of the time it will pass thru when I have it selected (and does the shaking) and also hundred percent of the time it doesn't if I don't have the object selected. Shouldn't selecting an object don't have any effect on this? Please give me some ideas of why.


Lat, Lon and elevation Conversation into unity coordinates I have came across a very vague project problem and its feasibility report or communication procedures I have to define. And here is the current scenario I have two applications One is built on Unity3d (which is under my control) The second is also an application (which i don't know, and not under my control ) but it is related to a map service app. Now the actual thing I want to do is that If a user click in the map application than, the touch should be recognize in the unity application too. Suppose I have able to communicate with both applications and the map application providing me the latitude, longitude and elevation information on click. Now the question is how do I convert its lat, lon and elev into my project work space unity coordinates?. I found 3D coordinates on a sphere to Latitude and Longitude, and its about sphere. I don't have sphere I have an environment where different models are placed precisely according to map (there is no dummy models, all are accurate) and the map projection is based on snake grid.


InvalidOperationException in build only, when trying to select object in a dynamically loaded scene using Linq Here is the relevant code private void Awake() StartCoroutine(LoadScenes()) private IEnumerator LoadScenes() this.sceneLoad1 SceneManager.LoadSceneAsync(Scene1, LoadSceneMode.Additive) while (!this.sceneLoad.isDone) Debug.Log("Loading scene 1...") yield return null this.sceneLoad2 SceneManager.LoadSceneAsync(Scene2, LoadSceneMode.Additive) while (!this.sceneLoad.isDone) Debug.Log("Loading scene 2...") yield return null private void Start() SceneManager.GetSceneByName(Scene1) .GetRootGameObjects() .Where(root gt root.GetComponent lt God gt () ! null) .Select(root gt root.GetComponent lt God gt ()) .Single() .SpreadGospel() (Scene1 and Scene2 are const strings.) The program works fine when running in the Unity editor. However, when I make a development build, I see the follow error message InvalidOperationException Operation is not valid due to the current state of the object at System.Linq.Enumerable.Single God (IEnumerable 1 source) 0x00057 in Users builduser buildslave mono build mcs class System.Core System.Linq Enumerable.cs 1968 at MySolution.GodInitializer.SpreadGospel () 0x00001 in D repos MySolution SourceCode SourceCode GodInitializer.cs 100 at MySolution.GodInitializer.Start () 0x00012 in D repos MySolution SourceCode SourceCode GodInitializer.cs 77 ... which indicates that the scene wasn't fully loaded before I tried to access the God singleton. What changes should I make to fix the problem?


Saving Information in Byte sorry for the unhelpful title. I'm trying to understand how to convert information to bytes so that I can save it using Google's Saved Games feature that comes with Play Services, as explained here. https codelabs.developers.google.com codelabs playservices unity index.html?index .. 2F.. 2Findex 9 I've mostly copy pasted the code but it's not really working out for me. However, my initial question is about bytes. So it looks like Google stores game information in bytes . The example only shows a single int being converted to byte and then being saved. What if I wanted to save multiple integers in Google's Saved Game services? I'm not exactly sure what this byte array is in the first place and how everything can be converted to bytes. If anybody has any good resources or examples, it would be much appreciated! Thank you


Draw "rasterize" irregular circle onto a 2D grid I'm using the midpoint circle algorithm to choose cells on a 2D grid which outline a circle. However, I need to incorporate some random noise so that I get an irregular circle, and this method won't work anymore given how it works. Another stack exchange answer describes an equation (the "pink noise" example) I'd like to try but I'm not sure on the best approach to implement it. I can replicate the equation via code, but I'll need to start choosing grid cells coordinates differently and I'm not sure the best solution. How can I "rasterize" an irregular circle like this?


How to add Facebook Data Storage to Mobile Game? I was wondering how I would add the option for players to sign into their Facebook profiles on my mobile game and then have Facebook store their game save data, so they can recover it on any device when they sign into Facebook. Other Facebook features would include seeing their friends on the Facebook leaderboards, inviting their friends to the game and challenging their friends to beat their scores. I would hate for the Player's data to be lost, so the Facebook data save part is very important. A good reference to this feature is the Hungry Shark mobile game. I wasn't sure how this works. My programming friend and I are creating the game together, but he doesn't know how to do this and I don't know how to program. Once I figure out exactly what has to be done, I would like to hire a programmer who knows how to add this feature. Thank you!


Import Unity 2D objects in Libgdx I'm using Libgdx to do some simple home projects. I'm trying to make a simple 2D game with Box2d using R.U.B.E as editor. I create a 2d terrain in R.U.B.E now I want to create the terrain texture. I see this tool for Unity https www.assetstore.unity3d.com en ! content 15761 This type of tool is exactly what I need for terrains. What I want to know is not related with this specific tool, but I wan't to know if I can import Unity 2d objects generated by tools related to Unity in my Libgdx 2d games?


How can I more efficiently paint grass onto a large terrain object in Unity? I'm trying to paint a grass onto a large terrain and I want it to cover the entire terrain. Since the brush size can't go past 100 it would seem that I'm stuck painting the entire thing with a small brush relative to the terrain size. How can I more efficiently paint grass onto a large terrain object?


Second Animation is not working after Collision? I want to show an accident of Character with car. so I wrote this code and in update function I wrote this... if (Once) Criminal.GetComponent lt Animation gt ().Play ("Running") after collision This animation will work Criminal.GetComponent lt BezierMover gt ().enabled true TrafficCar.GetComponent lt BezierMover gt ().enabled true void OnCollisionEnter (Collision col) if (col.gameObject.tag "Vehicle") if (!Criminal.GetComponent lt Animation gt ().IsPlaying ("Stumbling")) Criminal.GetComponent lt Animation gt ().Play ("Stumbling") Animation for Accident Criminal.GetComponent lt BezierMover gt ().enabled false to Deactivate the AI Script. TrafficCar.GetComponent lt BezierMover gt ().enabled false to Deactivate the Trrafic cars Path Script. Once true but after first animation second animation should work but this is not happening..


Mesh made in Blender is correct in Unity3D as a rendered mesh, but "empty" as a collider? I created a simple stair "block" in Blender, and it's rendered correctly, but when I tick "Generate Colliders" and try to use it in a Mesh Collider, there is nothing. (Ps. I need the real mesh as a collider, not just that generated convex one) Maybe a good clue is that my other objects' generated colliders are smaller than the rendered meshes themselves. Maybe this one is scaled to zero? After triangulating And via Unity's automatic triangulation (the original, non triangulated blender model)


Instantiated Object returns Null outside Start method I'm attempting to access an instantiated 'goalTemp' GameObject from a different function inside the same script. I'm getting the information in the Start method, assigning the GameObject find get component script code to a variable. When I'm printing the results outside the Start method, it returns null, even though the 'goal' variable is public. void Start() GameObject goalTemp (GameObject)Instantiate(goal,respawnGoalLocation CreateLevel.currentLevel 1 ,Quaternion.identity) goal goalTemp.gameObject public void Explode() Debug.Log(goal) Instantiate(rockParticle, goal.transform.position, goal.transform.rotation) Instantiate(explosionParticle, goal.transform.position, goal.transform.rotation) What am I doing wrong here? Thanks for your time!


How can I keep vertex order the same on every Instantiate()? While trying to resolve another question, I have discovered that if I Instantiate() from a prefab, the order of the mesh vertices (and therefore triangles) is inconsistent between instances. This is apparent, for example, if I RaycastHit.triangleIndex the same location on the mesh on different runs of the game. The same location returns the same triangle index during one run of the game, but a different triangle index in the next run. If instead I add the model to the scene in the editor, and then run the game, the same location returns the same triangle index in every run of the game. If I duplicate the model through the scene editor, the duplicate also returns the same triangle index. This is the behaviour I am aiming for. However, I would obviously prefer to Instantiate at runtime. (This would allow me flexibility on when and how many models to instantiate, and in the long run I want to add other models too. The alternative is to add the model to the scene and create a large number of "offscreen" duplicates, which seems prone to inefficiencies on multiple fronts.) Is it possible to use Instantiate and maintain a consistent vertex triangle order between instances and between runs of the game?


How can I have a Mecanim animation with displacement and physics? I have 3D wolf models from my animator with displacement (i.e the wolf transforms with animation, not in place). I have added rigid bodies to the models. I am facing following issues while executing them in my project When I turn on IsKinematic on my rigid body (i.e disable physics) the animations work perfectly, with displacement. But I need to have physics enabled on my wolf because it doesn't detect collision when physics is disabled and gravity doesn't have any impact. When turn off IsKinematic (i.e enable physics), the animations don't work the wolf start wobbling and flying in the air. How can I resolve this?


Show Camera Inside Object Bounds I'm making a mobile game, and I want have secondary camera that shows another part of the scene within a box. I'm able to do this easily enough by setting the camera's viewport settings, but the issue I'm having is when you change the screen size, the camera size changes with the screen no longer looking like it shows in the box (The box doesn't expand contract with the device's screen size). Is there a way to set the camera's size an position relative to a game object? This is what I'm trying to do


Programmatically generated mesh vertex colors not showing up in Unity? I'm sorry if this is an obvious thing to solve but I just can't figure it out...did I miss something...I've generated a mesh and during vertices generation I've also set its colors (and colors32 just in case) by reading those values from a ply file, and afterwards I've added a number of vertex color shaders but none of them will show the vertex point colors in play mode, it's either solid black or just like I added no material to the mesh (which I've tried doing manually in play mode too). Did I miss something please?


How do I duplicate the functionality of ugui's onClick (button component) in inspector (Unity)? I'm trying to create the same functionality that occurs when you are working with a button in uGui in Unity. I know that I have to create a custom inspector, but i'm not sure where to go from there. Essentially the functionality allows you to drag and drop a script to it's on click portion in the inspector, and then it gives you a list of functions for that script to select. This may sound a little confusing, so here are a few pictures demonstrating the functionality i'm trying to replicate. As you can see above the functionality allows you to drag in a script, select a function to link, and do this for as many or as little scripts as you want by pressing the or buttons on the bottom right. Thanks for any help in advance!


Is there no UI culling for unity? I don't understand, am I missing something? I have hundreds of moving images on screen that only need to render and do their logic physics when they are in the canvas. Otherwise they can just deactivate to save on performance and there is a very big fps difference when they are deactivated vs activated outside the canvas. RectMask2D on the canvas does barely anything. Checking the bounds for hundreds of UI elements seems like madness. So what are you supposed to do?


Problems exporting meshes to Unity 5 After creating a tree (Scots Pine) in SpeedTree Cinema v7.1.1 I exported it as a .FBX ascii file to Unity 5 and I encountered a problem the leaf material, while viewing it in Unity 5, can only be seen when I view the tree from the top, but when I view the tree from the bottom or the side, the leaves dissapear, they're not visible anymore, but on the other side, I can view the leaves of the tree from any angle in SpeedTree Cinema v7.1.1. I don't know if the problem is one of the following The way I export the tree (.FBX ascii) The way the texture is saved (.tga, .jpg, .png) The material settings (in SpeedTree or Unity) So you can better understand, i'll show the following images Description of images is below (Image 1.) Here are the setting of how I export the tree and you can also see the clearly see the leaves from all angles. (Image 2.) Here is my tree (the tall one, Scots Pine) and you can't see the leaves from underneath and the material displayed on the right belongs to the leaves of my tree (the tall one, Scots Pine). The tree to its side(the small one) is how I would like the leaves to look ( i didn't make the small tree). (Image 3.) In here you can see the leaves of my tree (tall one, Scots Pine) from the top, and next to my tree is another one (not my tree) which is how i would like my trees leaves to look. The material displayed on the right are from the small tree (not my tree). Any help is appreciated, thank you.


Unity settings overlapping other settings error In my unity game, I am using the amazing unity asset aura volumetric lighting and when I add its script into my camera this happens Yeah... I can't see anyone else who got these settings overlapping each other on the stack exchange or anywhere else. Not only does it overlap but I can actually change its settings and the camera settings if I click in the right areas! I restarted unity but it still doesn't fix anything. Please help. Thanks in advance!


Detect which tile in a tile palette a player is colliding with I have a megaman style platformer that I've been working on for a while now. I'd like to have my scene set up so that when a player interacts with certain tiles, it will have some sort of effect on the player. This could easily be achieved with creating individual sprites for the aforementioned interactables, but I'd ideally like to be able to have a portion of my script handle it so that everything besides the player and enemies would be tilemaps. For instance, I have a tile that would act as a treadmill that moves the player along in one direction. Another tile would be bouncy, and another would deal damage. I have the game set up right now to detect when the player is touching a tile, but I have no way of being able to tell which tile the player is touching. Is there a way to be able to compare programmatically which tile from a tile palette my player's hitbox is currently touching?


How do I create a single tile in Unity 2019 I going through the "Ruby's Adventure 2D Beginner" tutorial, chapter 4, section 3 with Unity 2019.11. In the tutorial you create a folder for tiles and you are then supposed to right click in the asset folder and select "Create Tile" from the menu. There's even a screenshot showing the menu where the option is right below the sprite sections. However, in version 2019.11 of unity, there is no such option ) I checked the documentation, and for 2019.3 and 2020.1 the manual states that this should be possible via the assets menu (there's no docs for 2019.11 specifically), but my Unity editor doesn't have the option. It seems unlikely that the option is just missing from my version, so I'm guessing something about my project setup is wrong. Is there anything special I need to set up to have the project support tiles? Edit I found the feature in the 2018 LTS version. I'm new to Unity, so maybe out of date documentation is the norm.


Algorithm for creating mesh from 2D image silhouette I'm looking for an algorithm that can take a 2D image, approximate it's shape and then generate a low poly mesh. Basically, the same what Unity does with sprites when you select tight mesh instead of a rect mesh. I'd be very thankful for any links that would put me on track to begin my research. Thanks!


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


Children of canvas objects do not register OnMouseUpAsButton Objects I create inside my canvas do not register the OnMouseUpAsButton() event. I tried doing it on an empty project and it doesn't work so I guess I'm misunderstanding how something works. That being said, objects inside game world register event properly. I tried reading documentation but I still don't get why this is happening. My code (the only code used in the project) using UnityEngine using System.Collections public class test click MonoBehaviour void OnMouseUpAsButton() Debug.Log("Mouse up test click") public void Thisworks() Debug.Log("yes") void Start () void Update () My project objects I have spent the last 12 work hours searching for causes of this problem so I'm sure it is something absolutely obvious yet I just can't see it.


"The Object you want to Instantiate is null" But it works, can I ignore the error? This has never happened to me so I'm a bit confused. GameObject someObject Instantiate (Resources.Load ("Prefabs Items " someName)) as GameObject This throws an error but the object is actually instantiated and everything works as intended. The error doesn't stop the program no matter how many times I reproduce this. Can I ignore this error or is there some problem that I'm not seeing?


How to build only specified assets into assetbundle in unity I have searched through the few results pertaining to this particular question, but haven't found any results that work. A simple rundown of what i am looking for is to be able to make a single asset bundle of specified assets in order to be able to make an automated process for what the mod system i am making for the project i am working on. there are two ways I can think of that would be able to do this build specified resources and assets into an assetbundle build everything in a specified folder into an asset bundle all of what i have been able to find regarding this either wouldn't allow me to make the automated process i need or builds the all of the assetbundles and they have to be defined manually before hand. Any resources or suggestions to this issue would be greatly appreciated.


Can I have a fixed angle sprite with a non fixed angle CircleCollider2D? In Unity2D, can I have a fixed angle sprite with a non fixed angle CircleCollider2D? I would like to move my character using the circle physics (without fixed angle), but display him always as if he wasn't rotated (as if he had fixed angle). I thought I could just let the collider rotate, and then rotate back the sprite in the LateUpdate, however since the collider's center isn't 0,0, it "rotates sideway" and doesn't end up in the "original" position. My knowledge on matrices and quaterions is null, and trigonometry is only slightly above zero, so I'm a bit at a loss... how can I achieve the desired effect? In order to prevent a X Y problem, I want to do that since with box colliders sometimes the characters got stuck if a platform had even just 1 pixel step, the character couldn't walk over it. Also, slopes were a big problem. Changing the collider to a Circle was the obvious consequence I also tried to detect and add a small vertical speed but it didn't work very well and was becoming a mess.


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


Unity Physics.Raycast give false positive while using layer mask I'm very new to Unity so please excuse my question if this sounds very basic to you. I'm following various tutorials and I have a small question regarding Physics.Raycast if (Input.GetButton("Fire1")) check ground hit first RaycastHit hit if (Physics.Raycast(ray, out hit, LayerMask.GetMask("Ground"))) Debug.Log(" PlayerMotion Hit" hit.collider.name " " hit.point) agent.SetDestination(hit.point) Here, even tough I expressively set the layer mask to "Ground", I still get a hit with the Player game object itself (the ground hit is working fine). I thought ok maybe I put the "Ground" layer as well on the player by mistake but I checked several times and it's not the case. I'm attaching a gif so you can see what's the issue exactly There's an easy by checking the collider.name but I still find it odd that the Raycast gives me a false positive with the player hit. Any idea what's going on ?


Simulate shake, tilt and multi touch in Unity WebGl app I am developing a multi platform game in Unity. It works great on Android and also on WebGL (haven't yet checked iOS). My problem is that in some of the levels I need to use mobile specific actions like shake, tilt and multi touch. Is there any way to simulate this in a WebGL app? Examples of what I need Tilt to move an object without touching the object. The idea is to quot sail quot the object from the top of the screen into a basket at the bottom avoiding some obstacle on the way. Tilt to cause an object to move across the screen Shake to cause something to break. Multi touch to select two objects at the same time.


Change Text Inside A button, inside a Canvas, inside a GameObject Access all the texts inside of hierchy? .... Gameobject tile int count 1f float posX 0 float posY 0 .... GameObject blueTile (GameObject)Instantiate(Resources.Load("block blue")) tile (GameObject)Instantiate(blueTile, transform) for loop ... ... tile.GetComponent().GetComponentInChildren().text count.ToString() tile.transform.position new Vector2((float)posX, (float)posY) count As you can see by the image. My line of thinking goes like this I used to create Flash AS3 Applications and Games. I have used a number of API's and they usually have a lot in common. Unity, however, is very different and I may have not grasped the key concepts. I want to access my PreFab, named in Assets Resources (the root path) "block blue" All I wan to do is set up a row and columns of a box with a number inside of it. Before you go and ask, why the complicated mix of Objects? Well, Adobe had MovieClip and use of layers and also use of a timeline. Unity doesn't seem to have this in setting up a Scene (the Stage in Flash). So, I set up a block that looks like this (right of main image 66) It's a Canvas, to hold a Button, the button has a text. To move the Canvas, I put the Canvas inside a GameObject. This, to me, is like a MovieClip in Flash API. GameObject ButtonLight, Button TextBlack, Text I need to access TextBlack and also Text. Pretty easy right? I've been at this for 4 days, many many hours. EDIT It seems that it is working, somewhat. Looking at the reference photo and the Hierarchy reference, it looks like the blackText behind the blueText is changing as expected. But I cannot access the top BlueText. The Blue Text is also a child of type Text, but it's a second (layer?) copy of the text inside of the Button. So, it's getting the first Child Text, but how to access the second Text?


Unity XR Spectator Camera I would like to have a VR camera (for the player) but also have another camera (spectator). I am using Unity 2019.4.8f1 on the Universal Render Pipeline I have only been able to find outdated articles https blogs.unity3d.com 2017 12 12 spectating vr https unity3d.college 2017 05 08 unity3d spectator mode vr https forum.unity.com threads using a second cam while still rendering the vr camera for the vr headset.659434 Thanks!


How can I integrate someone well into my project? I am working alone, since over one year on a decent sized project... to speed up things i wanted to incorporate some friends into development, unfortunately i never did something like this before and so i dont know where to start. What is important to work as a team ? What should he know, see and understand ? And what shouldnt he be aware of ? And most important, how would you integrate someone into your project ?


Unity2D Isometric layering I'm developing an Isometric Game but I have problem apply the right layer for make, for example, a wall behind or in front of the Player depending on the Player position. I'm able of getting works in an orthogonal map relating the y axis value of an object with his layer but in an isometric map, the y axis is not aligned with the editor one. Anyone can help me understand how to manage this?


Render Occluded pixels to gray color In 3d space, objects can be occluded by another objects. By depth testing, the occluded faces are skipped rendering. Only the nearest(smallest) depth value pixels are drawn. But, sometime we need to render the occluded object or pixels for game play. To differentiate the occluded object's pixels from foreground pixels, some game use gray color to render the pixels. This is the sample images for the case. I guess this can be achieved by some sort of shader. How can I make this effects in Unity 3D Engine? Any hints or idea plz.


Is there a wall building tool in unity3d? I'm currently building a maze game in unity 3d and after building a few levels by placing and repositioning cubes by hand as walls, I think, that it would be nice if there was a tool to place walls, which are cubes with constant height and width, but have different length and rotations on the y axis, by joints you click to place a joint, and a wall goes in straight lines beetwen joints. So is there a tool like that?


How to enable and disable scripts on a Game Object? This worked briefly yesterday, I believe I did something to mess this up. All my inputs that I put in are correct therefor, it must be the code. I want to switch players. While the red cube's script is enabled and can move under the movement script I want the blue cubes movement script to be disabled and vice versus. Can you give me some insight into what I'm doing wrong? Please and thank you!! using UnityEngine using System.Collections public class PlayerMovementScript MonoBehaviour public float speed 2f public float height 2f public Component playerMovement public GameObject redCube public GameObject blueCube void Start() var bc blueCube.GetComponent lt PlayerMovementScript gt () bc.enabled !bc.enabled Update is called once per frame void Update () if (Input.GetButton ("Right")) transform.Translate(Vector3.right speed Time.deltaTime) if (Input.GetButton ("Left")) transform.Translate(Vector3.left speed Time.deltaTime) if (Input.GetButton ("Jump")) transform.Translate(Vector3.up height Time.deltaTime) var bc blueCube.GetComponent lt PlayerMovementScript gt () var rc redCube.GetComponent lt PlayerMovementScript gt () if (Input.GetButton ("Switch")) bc.enabled !bc.isActiveAndEnabled rc.enabled !rc.enabled


Rotate bone on 1 axis to look at another object Unity 3D I'm new to game development and I'm trying to create a basic 3D Tower Defence game as my first project. I've created a basic turret in Blender and I'm now trying to rotate 2 different bones to make the turret follow the enemy. The first bone (which I have working) rotates the turret to face the direction of the enemy. The second which I can't get right needs to rotate the gun at the top of the turret to look down at the enemy. I need it to keep facing the same direction as the rest of the turret and don't want it to tilt to either side. So it needs to move on 1 axis only. I have tried various things, including examples from the Internet but I can't figure it out. So far I've managed to get it to look down at its base, up at the sky and spin like a wheel. Basically everything except where it's supposed to be looking. Here is the code I have at the moment if (enemiesInRange.Count gt 0) Rotate Platform This section works fine Transform platform transform.root.Find("Armature BaseBone PlatformBone") Quaternion targetRotation Final rotation (I.e. facing the enemy) Vector3 turretPosition platform.position Store the turrets current position turretPosition.y 0 0 the Y axis to stop the turret tilting up or down Vector3 targetPosition enemyManager.activeEnemies enemiesInRange 0 .transform.position targetRotation Quaternion.LookRotation(targetPosition turretPosition) float rotateSpeed 2.0f Time.deltaTime platform.transform.rotation Quaternion.Lerp(platform.transform.rotation, targetRotation, rotateSpeed) Rotate GunBox TO DO This part is not working Transform gunBox transform.root.FindChild("Armature BaseBone PlatformBone LowerArmBone UpperArmBone GunBoxBone") Vector3 gunBoxPosition gunBox.position float angle Vector3.Angle(gunBoxPosition, targetPosition) gunBox.RotateAround(gunBox.position, Vector3.left, angle) Debug.Log(angle) Here's a picture of the turret to give you an idea what I'm working with. You can see in the screenshot that the bone's default X rotation is roughly 50. Enemies walk through the trench around the turret. The PlatformBone rotates everything from the silver platform upwards. I also don't understand why the line below makes the turret rotate instead of tilting it. I would expect to rotate the turret around the Y axis to keep it flat on the floor and face another direction. Yet I seem to have to do the opposite (If I select the PlatformBone its Y axis is facing up as expected) turretPosition.y 0 0 the Y axis to stop the turret tilting up or down


How to load and unload objects at a certain radius from the player? I am making a procedurally generated space exploration game in unity. I'm currently generating 5000 stars in a cube of a fixed size. Each star just gets a random 3d coordinate. What I would like to do is to dynamically load and unload stars at a certain radius from the player. This would be the maximum view distance. The algorithm that does this must be working with a seed for the universe, as the stars need to be loaded in the same spot when you revisit them. My idea is something like in the amazing Space Engine. I have pretty much no knowledge of algorithms that can do this, so I ask for your help.


Unity Trying to add an in scene 'press E to open' tag as UI element In Unity 5.4.1 I'm trying to add a tag that says 'press E to open' to a door as you approach it. I've got a RayCast pointing forward from the player, detecting the door and , connected to my PlayerController, I've got a copy of a prefab GameObject which itself contains a Text UI element. The GameObject interactionTag is instantiated into the scene when the player is close enough. But I'm having some trouble getting it to display correctly in the scene and I'm not sure why. Here are the relevant parts of my PlayerController public class PlayerController MonoBehaviour public Canvas canvas private Vector3 fwd private RaycastHit hit public GameObject interactiveTag private GameObject interactiveGameObject null private GameObject interactionTag void Update () fwd transform.TransformDirection(Vector3.forward) if (Physics.Raycast(transform.position, fwd, out hit, 3)) if ( hit.distance lt 1) interactiveGameObject hit.collider.gameObject GameObject interactionTag (GameObject) Instantiate(interactiveTag, interactiveGameObject.transform.position, interactiveGameObject.transform.rotation) interactionTag.GetComponentInChildren lt Text gt ().text interactiveGameObject.GetComponent lt IsInteractive gt ().interactionText this gets a text string from the door 'press E to open' interactionTag.transform.SetParent( canvas.transform, false) In game, the interactionTag is appearing though it's backwards and does not appear attached to the door. Also is any of this the best way of getting the 'press E to open' tag to appear attached to the center of the door? I'm beginning to wonder if what I'm doing is best practise. Thanks for any help.


How best to detect device performance capabilities and set quality setting accordingly when using Unity I am developing a Mobile game for Android and iOS on Unity. Currently Im in the optimisation stage of development and trying to work out what is the best way to detect device capabilities, with the aim of then setting an appropriate quality setting. OS platform detection is simple, but how can I detect between a high performance android device and a low or medium performance device at runtime? I did find this question that is similar https stackoverflow.com q 21565468 4148676 but the question is old, the answers not great and hoping there's a better way in the last 4 years of solving the problem. The only other solution I have is monitor the average FPS and adjust the quality based on the frame rate. Any advice would be appreciated.


How do I rotate an object back and forth? I want my object to rotate between two angles in relation to speed and it doesn't need to be a smooth rotation, how can I achieve that? Thank you in advance.


Drag and Flick Objects to any position (Unity3D) In unity, I have several boxes in one cluster. I want the user to be able to move any of these boxes to any position that they desire in the app, and have it stay there until they move it again. Also, I want the user to be able to flick any boxes and when it is flicked, have it bounce around the screen, as if it were trapped inside of the phone (but never leaving it). Any way I can do this? (This will be used for an Android Experiment)


Will using one class per inventory item create issue on the long term? I finally managed to plug my menu to my inventory system, display current items, use them etc. But the way I did it... makes me feel dirty. To cut short, my items are described this way using System public abstract class Item public abstract string Name get public abstract string Description get public virtual bool IsUsable get return false public virtual bool IsEquippable get return false public virtual bool NeedTarget get return false public virtual void OnUse() public class Potion Item public override string Name get return "Potion" public override string Description get return "Restores 100HP to one character" public override bool IsUsable get return true public override bool NeedTarget get return true public void OnUse(PlayerCharacter target) Effects.HealTarget(target, 100) public override void OnUse() OnUse(GameData.getFirstPc()) public class Poison Item public override string Name get return "Poison" public override string Description get return "Deals 100HP damage to one character" public override bool IsUsable get return true public override bool NeedTarget get return true public void OnUse(PlayerCharacter target) Effects.DamageTarget(target, 50) public override void OnUse() OnUse(GameData.getFirstPc()) My Inventory is declared like this public class Inventory private static Dictionary lt string, Item gt ItemDB new Dictionary lt string, Item gt () "00001", new Potion() , "00002", new Poison() , "00003", new HiPotion() , "00004", new FangOfDestroyer() , "00005", new Elixir() public static Dictionary lt string, int gt CarriedInventory new Dictionary lt string, int gt () When I want to add items to CarriedInventory I basically call CarriedInventory itemID newAmount Everything only uses the ID, and when I want to get an item's name I call ItemDB itemID .Name, when I want to use an item I call ItemDB itemID .OnUse() , etc My reasons for doing this were I can be as specific as I want on item uses as I want, I can have unique item effects without having to worry about extending it to all other items I can use the effects in the Effects class for general effects (heal, damage, etc) if later on I realize I need a new property for an item, I can just add a virtual property as default to the Item class (e.g. I realize I want an item to not be droppable, I add a public virtual bool IsDroppable with a value of true, and non droppable items can override this I avoid inheritance hell And... it works, it works, but it feels wrong. Is it wrong? How wrong? Is there a better way to do it?


Can you load all assets inside an Addressable folder? So, I have a folder marked as addressable. This folder has many sub folders, which might have more sub folders, ultimately having some .png images. I would like to load every single Sprite found in my main folder and its children (i.e. recursively). public static AsyncOperationHandle lt IList lt TObject gt gt LoadAssets lt TObject gt (IList lt IResourceLocation gt locations, Action lt TObject gt callback) public static AsyncOperationHandle lt IList lt TObject gt gt LoadAssetsAsync lt TObject gt (object key, Action lt TObject gt callback) public static AsyncOperationHandle lt IList lt TObject gt gt LoadAssetsAsync lt TObject gt (IList lt object gt keys, Action lt TObject gt callback, MergeMode mode) public static AsyncOperationHandle lt IList lt TObject gt gt LoadAssetsAsync lt TObject gt (IList lt IResourceLocation gt locations, Action lt TObject gt callback) The first, third and fourth seem to take a list of keys for individual addressable assets (e.g. the actual Sprites), which is not what I want. I just want to provide the key for the parent folder, and then get all the sprites in it or its sub folders. So, the second function seems a bit promising. I would've expected to use it like this Addressables.LoadAssetsAsync lt List lt Sprite gt gt ("Assets MyMainFolder", myCallback) But it just tells me that the key is invalid. I've made sure that the folder is addressable, it has that key, and the group has been built. So my question is is there a way to load every addressable asset inside an addressable folder? Like how AssetBundles worked. Unity 2019.3.0f3.


How to fix infinite jump in Unity 3D? I have the following code public float jumpHeight 3f bool isGrounded void Update() if(Input.GetButtonDown( quot Jump quot )) amp amp isGrounded) velocity.y Mathf.Sprt(jumpHeight 2f gravity


Difference between 'max distance' and 'radius' in Physics.SphereCastAll I needed a way to check for all gameobjects within a set sphere of my player object. I found Physics.SphereCastAll which will return a RaycastHit , exactly what I wanted. But, I am having trouble understanding the method signature docs. Basically, it's the two things in the title I am confused on right now From Unity docs radius The radius of the sphere. maxDistance The max length of the sweep. Is 'max length of the sweep' a measurement of time (or degrees?)? I would have thought the length would be the same as the radius (or at least you could calculate it from the radius) but it obviously isn't what I think length means.


UnassignedReferenceException The variable player of FollowPlayer has not being assigned My current task is to make the camera follow the moving cube in a stable way where the camera won't get locked in the center of the object so it won't get dizzy once the cube starts to collide or fall down. I have done the parenting right, I have named the cube as the player and then selected it as the Transform reference in the new component that I have created for the camera to follow. But it just says UnassignedReferenceException The variable player of FollowPlayer has not being assigned. and I am unable to get the right results. What should I do ? Here is the C script that I wrote using UnityEngine public class FollowPlayer MonoBehaviour public Transform player public Vector3 offset void Update() transform.position player.position offset My scene setup looks like this So I have un parented the main camera from the player and it works perfectly fine but I still get the error, Have any ideas why?


Triangles in the corners of skybox When looking at the corners of skybox this happens http i.imgur.com H8XvS8I.jpg How to get rid of this? 6 skybox textures are 2048x2048px each. Tried changing Near and Far clipping of the main camera inside the character controller but it was ineffective. If I look away from the corners the dark triangles dissapear. Only when I look directly at the corners they appear.


How can I handle two collisions in the same frame? My problem is that I have a player with collisions, and enemy can collide with players collision and execute Hurt function in players script. But the problem is enemies can overlap and can hit the player in the literally same frame. So they both execute Hurt function. In my Hurt function I change players collision layer for a 2 seconds, and he is no longer be able to seen by enemies. But it doesnt matter because of the same hit by two or more enemies in the same frame. How can I solve this? I tried bool to check if Hurt function is executed but it doesnt work too... Here is Code on Enemy IEnumerator OnCollisionEnter2D(Collision2D collision) if (collision.gameObject.CompareTag("Player")) buras kediler st ste bindiginde birden fazla kez calisabiliyor charMovementRef.StartCoroutine(charMovementRef.Hurt()) Debug.Log("hasar yedi") Code on Player Hurt should only works one at the same time public IEnumerator Hurt() layer de i tirerek d man collisionlar ndan ka gameObject.layer 9 can azalt health HeartUI() show the new health on UI karakter g r nt s yan p s ns n gameObject.GetComponent lt SpriteRenderer gt ().color new Color(1f, 1f, 1f, 0.5f) player z plat rb2D.velocity new Vector2(rb2D.velocity.x, 0) rb2D.AddForce(new Vector2(0, jumpPower 1.2f)) 2 saniyeli ine colliderlar kapal kals n, sonra eski haline evir yield return new WaitForSeconds(2) gameObject.layer 0 gameObject.GetComponent lt SpriteRenderer gt ().color new Color(1f, 1f, 1f, 1f)


Is ArrayLists so slow that it is doomed to kill performance in Unity? I was reading Which Kind Of Array Or Collection Should I Use? The document states to use list for the most performance. "...They are the fastest array in unity. For this reason, built in arrays are the best choice if you need the fastest performance possible from your code (for example, if you're targeting iPhone)...performs significantly faster than ArrayList." I am inclined to use list besides performance issues as well because... If you're using List you won't have to cast objects since it's generic and use a T backing storage (at least .net does this). ArrayList have to cast everything to object and cause boxing with value types. faster for value types as it avoids boxing., strongly typed elements. But it got me to wonder, since everyone seems to favor to make a degrading statement about ArrayLists, is ArrayLists that horrible? If so why does it even exist? Is it more of trace of supposedly deprecated codes?


AI using character controller makes unwanted change to it's y position The enemy parent object does not have any colliders except for the character controller. It starts out with y .57 and immediately jumps to y 1.6355 because of my call to CharacterController.Move(.) A code snippet is as follows myTransform.rotation Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(targetPos myTransform.position), rotationSpeed Time.deltaTime) Vector3 forward myTransform.TransformDirection (Vector3.forward) character.Move (forward moveSpeed Time.deltaTime) The above occurs in my update function. I am reluctant to post more code because this is for an assignment. I feel like I've tried everything. Using rigidbodies, I fixed this problem but then the enemies began to overlap when they got close. So I reverted back to character controllers. In either case I have been trying different ways of keeping y constant, freezing it, making the y rotation component zero, you name it. One other thing I'll note is that the enemy moves to this y position regardless of where it is initially placed. My main character also starts a distance in the sky and falls down. It so happens that the y position it ends up is this same one that the enemy teleports to. EDIT Also I am on Unity 5.2 EDIT 2 This is for a script I use to make the AI follow my player. It is similar to many you will find just googling, because I based it off of those. I have even tried other people's scripts and had the same problem. EDIT 3 If I put the enemy lower to the ground (say y .55) he will not pop up like before. However, he doesn't move toward the player anymore.


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).


How to limit and direct player's view in VR? We are making a VR game where the player will look at the world through the eyes of his character who sometimes moves on his own, so the player is only observer. The character will rotate his body on his own and we need to change the orientation of player's camera to look where the character looks. For example, the girl takes his hand and leads her way. It would be very unrealistic if the player's head will be turned 180 from his body and he will walk backwards. It'll allow us to avoid exhausting head rotations. Is it a good idea to guide his view by force by limiting camera euler angles relative to the direction of the body?


Exposing type definitions to modders in Unity Note that this question is not about modding assets data and not about security, I plan to rely on community trust. I don't know much about DLL's and I was wondering how I can provide interface and attribute definitions for modders. For Kerbal Space Program modders only have to reference the Assembly CSharp.dll, UnityEngine.dll and UnityEngine.CoreModule.dll files of a games build, to create and compile their own DLLs. Are there certain things I have to do, to mimic this behavior, or does this work out of the box? Are there gotchas to this approach? Will a mods DLL, that was compiled using an older version of Assembly CSharp.dll, break if the Assembly CSharp.dll is updated, even though no types relevant to the mod changed? Will modders be able to use Visual Studios debugging features for their DLLs? Is there a better approach to provide type definitions? My question is related to this question. But I would argue that that question is kind of broad, while mine is about one specific aspect. Might not be needed for the question, but here are the two levels of modding that I would like to support for my game 1. Easier modding I want to compile .cs files of modders that implement special interfaces like IAbility, IItem, etc. I will use Roslyn or cs sript to do so. 2. More advanced modding I also want to load .dll's that modders compiled, allowing them to register their own Types in the games DI Framework, mark methods classes with attributes like CallMethodOnLevelLoad and use Harmony.


Do I have to use new keyword for unity single game object? I'm using Unity4. Do I have to use new keyword for single game object? look at the following code. 1. GameObject obj new GameObject() obj Resources.Load("Prefabs Ball", typeof(GameObject)) as GameObject 2. GameObject obj obj Resources.Load("Prefabs Ball", typeof(GameObject)) as GameObject is it the same?


Unity Particle System Shuriken Setting particles in code with random row in texture animation? Good day, I'm attempting to randomly generate a space scene (quite large actually) in Unity through C code mainly. So far, I've gotten stunning results up to what image 2 will show you. However, now I'm looking to expand the look with more random particles. So, I've made a texture atlas of 8 in a vertical row, which works on the random setting if you have an emitter and the particle system is called with PS.Play() Assigning different materials would only work on a per particle system basis(which would be new texture PER cloud, so to speak) which is not what I want. So, my question How can I use the Shuriken Particle System's Texture Sheet Animation functionality through code, without having an "active" particle system? More precisely, I wish to use the 'Random Row' feature of it to assign random textures to each particle. Since I can't share my code (due to policies), here is a bit more info on how I do it I create an array with coordinates for each cloud. Assign a particle system to that cloud. Randomly generate all the particles for the cloud with relative offsets. Use PS.setParticles(particlesArray) Using a Texture Atlas consisting of the letters A to H to test, only B showing on all particles. Using a Texture Atlas consisting of the fog particles to test, only 2nd showing on all particles. Thank you DMGregory for the help, I've tested it multiple times and it works perfectly now, I've also went ahead and tweaked a few of my settings just to get a more "clear" space


How to flush changes in PlayerSettings inside Editor I have a script which works only in the Editor. The script makes changes inside PlayerSettings. However, the changes made are flushed to the hard drive just after something in Unity is saved for example any scene. We have a script which increments the build version. The described issue sometimes leads to the wrong version committed to Git as the changes a flushed to the disk later. How can I flush the changes of PlayerSettings from the code?


How to rotate a rigidbody with a Pid controller I would like someone to describe me how to use a PID controller to rotate a rigidbody with AddTorque to a specific position. (like a spacecraft that rotates the Y axis of rotation towards Camera.forward for example). Can anyone show it to me with a script? Actually I already use this script to rotate with AddTorque but the object almost never stops at the precise point. Vector3 camForward Camera.main.transform.forward Vector3 rbForward rb.transform.forward Vector3 torqueY Vector3.Project(torque, Vector3.up) Vector3 torque Vector3.Cross(camForward, rbForward) rb.AddTorque(torque) rb.AddTorque( rb.angularVelocity)


why isn't onTrigger invoking on collision with a trigger or a rigidbody? void onTriggerEnter(Collider other) if (other.gameObject.CompareTag("Pick Up")) other.gameObject.SetActive(false) count count 1 setCountText () This is the methodI want to invoke, on collision of a sphere with another cube. The cube is set as a trigger, and a rigidbody component is attached to both of the objects. Still, on collision, the method is not invoked. Is there anything else that may be done, for this method to execute?


What is the best way to create a square grid in Unity? So I need to create a square grid like the one below. And be able to click on a square, the square you chose then is filled with a different color as well as all the squares right and below the square you have chose. My question is what will be the most efficient way to create this grid either in 3D or 2D in Unity.


Monster Spawner Reference Issue I have a monster spawner that spawns the quot enemy quot kid which is red, and it has a line in the script where it references the quot player quot gameobject's transform. Before I made the spawner, I had the enemies put by hand and I could reference the player object without issue. Now they're not handplaced, they are spawned from the prefab folder by the spawner. When they spawn the game gives the null reference exception error and stops. I look up to the enemies that are spawned and none of them have the player gameobject referenced. Also when I click on to the enemy prefab to reference the player object, it just doesnt allow me to. How can I resolve this issue?


Is Unity NGUI still that usable after Unity has add support for 2D? I am tempted to refactor out the existing component which uses NGUI ("Next Gen UI kit") given that what I needed is only the sprite and texture atlas. Since in the newer versions of Unity those parts are natively supported, is there any reason I should still keep NGUI?


Configurable Joint, linear limit range I am working on a physics driven pressable button, but I cannot seem to tackle the minimum and maximum limits. This is the rig I have set up for the button (as it looks when pressed down). 2D view 3D view The idea is that the box collider is a trigger and the button (cylinder, mesh collider) is a rigidbody with configurable joint, locked and limited on a single axis. I am using configurable joint, as that's the only one that supports basic, linear restrictions. I have set up the configurable joint to restrict motion on a single axis, but the joint only allows single dimensional limit, that is applied to both directions. Screen capture of relevant configuration Basically, the opened Linear Limit section is the last property that has been changed for the joint anything else are defaults and irrelevant (at least I haven't found my solution in the properties below, mostly angular stuff). The limit of 0.2 units work, and the button can be pressed it only gets pressed until those 0.2 units and thats the expected behaviour. The unexpected is that sometimes the angle at which I hit the button, adds force to the button outwards from the box, and it moves 0.2 away from it, ending up like this Obviously, the specified limit of 0.2 units constrain the movement in both directions from the anchor, actually resulting in the range of 0.2 to 0.2 (relative to anchor). How, and is it even possible, to restrict the movement only in a single direction relative to anchor?


Simulating circular motion with gravitational forces in Unity2D I am currently messing around with a game where you control a black hole and use its gravity to fling planets at targets. I have the gravity calculations working pretty well when the planets start out stationary but I want to take it a step further and have the planets start out in circular orbit around the black hole. Ideally what I want to do is place a planet, provide it with an orbital period, and have it orbit my black hole object in uniform circular motion. To do this I am following these steps Use the objects initial distance from the black hole ( r ) and the given orbital period ( T ) to calculate the standard gravitational parameter of the system ( mu ) via the equation mu frac 4 pi 2r 3 T 2 Find the tangential velocity of the circular motion via the equation v sqrt frac mu r Assign the object an initial velocity with a magnitude of v and a direction perpendicular to the vector between the black hole and the object Every time the Update() function is called, apply a force to the object in the direction of the black hole that represents its gravitational pull F frac mu m r 2 where m is the mass of the object. All of these equations came from the Wikipedia page on circular orbit. When I do all of this I get planets that do orbit the black hole, but their orbits are elliptical and rather unstable while I want them to be perfectly circular. Here is my GravitationalForce script, which I attach to the planet object and provide the black hole object as otherBody. public class GravitationalForce MonoBehaviour public GameObject otherBody public float orbital period 2 float grav param Rigidbody2D rigidbody2d Rigidbody2D rigidbody2d other Start is called before the first frame update void Start() get rigid bodies of this object and the object it is attracted to rigidbody2d GetComponent lt Rigidbody2D gt () rigidbody2d other otherBody.GetComponent lt Rigidbody2D gt () calculate the grav param for this object Vector2 position this rigidbody2d.position Vector2 position other rigidbody2d other.position Vector2 dist vector position this position other float dist dist vector.magnitude grav param (4 Mathf.Pow(Mathf.PI, 2) Mathf.Pow(dist, 3)) (Mathf.Pow(orbital period, 2)) calculate and assign the initial velocity Vector2 dist vector rotated new Vector2( dist vector.y, dist vector.x) dist vector rotated.Normalize() Vector2 velocity vector dist vector rotated (Mathf.Sqrt(grav param dist)) rigidbody2d.velocity velocity vector Update is called once per frame void Update() calculate gravitational force Vector2 position this rigidbody2d.position Vector2 position other rigidbody2d other.position float dist Vector2.Distance(position this, position other) float force magnitude (grav param rigidbody2d.mass) (Mathf.Pow(dist, 2)) float theta Mathf.Atan2(position other.y position this.y, position other.x position this.x) Vector2 force vector new Vector2(force magnitude Mathf.Cos(theta), force magnitude Mathf.Sin(theta)) rigidbody2d.AddForce(force vector) Any ideas on why my orbits are unstable and elliptical instead of stable and circular? My only thought is that circular orbit is a very sensitive state and rounding errors in the physics engine or floating point number weirdness might be causing it to deviate from the circular path. If that is the problem, is there any easy fix to that and if not, what could the problem be? Thanks!


Move object to mouse direction without raycast? I have script moving object to mouse postion using raycast. But what I need now is use the mouse movement to move my object. using System.Collections using System.Collections.Generic using UnityEngine public class HoverPanel MonoBehaviour public GameObject ground private Rigidbody rg public float moveForce, speed 2 public Vector3 Mouse pos void Start() rg gameObject.GetComponent lt Rigidbody gt () void Update() rg.AddForce(Input.GetAxis( quot Vertical quot ) moveForce ground.transform.forward) if (Input.GetAxis( quot Mouse X quot ) lt 0) Code for action on mouse moving left print( quot Mouse moved left z quot ) if (Input.GetAxis( quot Mouse X quot ) gt 0) Code for action on mouse moving right print( quot Mouse moved right z quot ) if (Input.GetAxis( quot Mouse Y quot ) lt 0) Code for action on mouse moving left print( quot Mouse moved back x quot ) if (Input.GetAxis( quot Mouse Y quot ) gt 0) Code for action on mouse moving right print( quot Mouse moved forward x quot ) void FixedUpdate() No need to use this RaycastHit hitGround Ray ray Camera.main.ScreenPointToRay(Input.mousePosition) if (Physics.Raycast(ray, out hitGround, 500)) Mouse pos new Vector3(hitGround.point.x, transform.position.y, hitGround.point.z) transform.localPosition Vector3.Lerp(transform.localPosition, Mouse pos, speed Time.deltaTime)


How to have an object follow the mouse, even if not clicked in Unity? I have this object. I want to click on it and drag it around. Also if I click anywhere on the screen, I want the object to move but keep the distance. In the script below I made the object follow the mouse, but I can't do the second part. I have a couple rays for debugging. Any ideas? using System.Collections using System.Collections.Generic using UnityEngine public class Player MonoBehaviour Vector3 playerPosition Vector3 mouseF Vector3 mouseN void FixedUpdate() if (Input.GetMouseButton(0)) setMouseF() setMouseN() Debug.DrawRay(mouseN, mouseF mouseN, Color.green) Debug.DrawRay(mouseN, (playerPosition mouseN), Color.red) move the player base on mouse position transform.position mouseF if (Input.GetMouseButtonUp(0)) on mouse release, set the new player position playerPosition mouseF void setMouseF() Vector3 mouseFar new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f) mouseF Camera.main.ScreenToWorldPoint(mouseFar) void setMouseN() Vector3 mouseNear new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane) mouseN Camera.main.ScreenToWorldPoint(mouseNear)


unity destroy enemy when jumping on it I am creating a 2D platformer using Unity3D, I want to have the player destroy enemies when it jumps falls over them (just from the top). But I have been having problems trying to implement this. I stripped everything and used two simple box colliders in order to make it easy. So, when onCollisionEnter2D is called I get the bounds of the objects colliding like this Bounds playerBounds new Bounds(transform.position, collider2D.bounds) Bounds collisionBounds new Bounds(collision.transform.position, collision.collider.bounds) Then I check if the object colliding is below by comparing it's bounds If the player's lowest point is greater than the colliding object's highest, then it is above it bool isAbove playerBounds.min.y gt collisionBounds.max.y Then I check if the object is actually an enemy, and if so, I destroy it if(isAbove) if(collision.gameObject.tag "Enemy") collsion.gameObject.getComponent lt EnemyController gt ().die() Now the thing is this never happens, isAbove is never true, so I tried checking the heights of each object so I use Debug.Log("player " playerBounds.min.y " enemy " collisionBounds.max.y) It says the player bottom most is below the enemy top most. Since I use this same method to detect if the player is grounded in order to enable jumping I noticed it works beautifully with other things like platforms but not with enemies. Also y used Debug.break to stop the game and noticed that when colliding with platforms the player's collider was always above the platform's, but when it collided with enemies they overlap so the player's bottom most part is below the enemy's top most part. I read somewhere that this is due to the minPenetrationPenalty property, I didn't like the results of messing with it so I just left it the same (If I lower it doesn't even work with platforms, and I increase it they don't even touch and the collision is detected). I tried to compensate for this penetration when checking the bounds so I said bool isAbove playerBounds.min.y gt collisionBounds.max.y 0.01 It sometimes fails and sometimes not depending on the angle and other stuff, I still don't get it because if this was the problem It shouldn't work with the platforms either but it does, it only fails with enemy. I even tried to check for the overlap and said float overlap playerBounds.min.y collisionBounds.max.y bool isAbove overlap gt 0.01 this still works beautifully with platforms only reporting positive values (which means they are not overlapping), but with enemies it actually reports negative values (which confirms the previous they do overlap), even more strange it actually reports overlaps greater than what should be allowed, the usually report a 0.09 which means a 0.09 overlap which is greater than the 0.01 that the physics engine is supposed to allow. If I apply this code in OnCollisionStay2D instead it works, I guess by this time the overlap is fixed, but this looks unnatural and I still don't understand why this works perfectly with platforms (they never even overlap!) and not my enemies.


Problem with shooting So what I am trying to achieve is have the player shoot toward the mouse positiion and I have that working but I want the player to have to charge their shot. So if the player just presses the button it only goes a certain distance but if the player holds the button down for a bit it goes farther. I tried to make a video that kinda explains what I am going for. This is the code that controls the shooting public class BowController MonoBehaviour public GameObject arrow public Transform shootLoc public float force public Camera cam public float chargeMin public float chargeAmount public float chargeMax public bool charging void Start () void Update () Ray cameraRay cam.ScreenPointToRay(Input.mousePosition) RaycastHit hit Vector3 pointToLook if (Physics.Raycast(cameraRay, out hit, 50)) pointToLook hit.point Debug.DrawLine(cameraRay.origin, pointToLook, Color.blue) else pointToLook cameraRay.origin (cameraRay.direction 50) transform.LookAt(pointToLook) if(Input.GetMouseButtonDown(0)) charging true if (charging) Charging() if (Input.GetMouseButtonUp(0)) GameObject tempArrow tempArrow Instantiate(arrow, shootLoc.position, shootLoc.rotation) as GameObject tempArrow.transform.LookAt(pointToLook) Rigidbody tempBody tempBody tempArrow.GetComponent lt Rigidbody gt () tempBody.AddForce(transform.forward force, ForceMode.Impulse) force 100 charging false void Charging() force Time.deltaTime chargeAmount if (force gt 500) force 500 And this is the code that is on the arrow public Rigidbody rBody public float speed void Awake () flying true void Update () if (flying) rBody.velocity rBody.velocity.normalized speed transform.LookAt(transform.position GetComponent lt Rigidbody gt ().velocity) transform.Rotate(0, 180, 0) void FixedUpdate() if (flying) transform.rotation Quaternion.LookRotation(rBody.velocity) void OnCollisionEnter(Collision collision) flying false I am still pretty new to coding so any help is appreciated. Thank you all very much in advance for the help!


Need help with using Player Prefs to save number of coins collected I'm using unity 3D to make a game where the character collides with coins in order to collect them. When playing the game, the player should start out with zero coins and each time he collides with a coin, the amount should increase by one. On a main menu scene, the total number of coins (that have been collected across multiple games) should be displayed. The total number of coins is being displayed on the main menu but once in the gameplay scene, the total number of coins is being displayed there too (where it's supposed to start at 0 and then increase by 1 each time a coin is collected). Here is the script I use for when the player collides with a coin using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class CoinScript MonoBehaviour void OnTriggerEnter(Collider target) CoinScoreManager.coinAmount 1 Destroy(gameObject) Here is the script I use to manage the UI and coin number in the game play scene using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class CoinScoreManager MonoBehaviour public static int coinAmount public Text coinText void Start() coinAmount PlayerPrefs.GetInt( quot CoinAmount quot ) void Update() coinText.text coinAmount.ToString() PlayerPrefs.SetInt( quot CoinAmount quot , coinAmount) Here is the script I use to manage the UI and total coin number in the scene with the main menu using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class MainMenuController MonoBehaviour int coinAmount public Text coinAmountText void Start() coinAmount PlayerPrefs.GetInt( quot CoinAmount quot ) void Update() coinAmountText.text coinAmount.ToString() I think the problem is in the second script shown above. In the Start function I'm calling the coinAmount which is the same variable used to show the total coin number. I think that's the problem but I'm not really sure how to fix the problem as I'm still kinda of new to Unity and programming. Please let me know if there's anything else you need to know about the game in order to figure out how to fix this. Thanks for your help!


Detect when item has been dragged dropped onto an inventory slot In my inventory system I want to be able to drag and drop items into inventory slots. I managed to make it work, but only in a weird way When the player starts dragging, it picks up the item and it follows the mouse's position. When they release the button outside the inventory, the item's position is restored to the slot from which it was picked up. I use GameObject mouseReleasedObject eventData.pointerCurrentRaycast.gameObject to detect whether the drag was released over an inventory slot. The problem is that when the player drops it on a possible inventory slot, the same quot restore to previous slot quot behaviour happens. That's because the mouse is top of the dragged item and the slot as well but the item is rendered above everything else. How can I make the dragging ignore the item itself, and detect the slot underneath? Start dragging public void OnBeginDrag(PointerEventData eventData) GameObject draggedObject eventData.rawPointerPress if(draggedObject.GetComponent lt RectTransform gt () is null) return if(draggedObject.tag quot InventoryItem quot ) Debug.Log( quot InventoryItem drag has started! quot ) dragStartSlot draggedObject.transform.parent.gameObject draggedItem draggedObject draggedItem.transform.SetParent(canvas.transform) draggedItem.transform.SetAsLastSibling() End dragging public void OnEndDrag(PointerEventData eventData) GameObject mouseReleasedObject eventData.pointerCurrentRaycast.gameObject if(draggedItem is null) return Debug.Log( quot Released at quot mouseReleasedObject.gameObject.name) if(mouseReleasedObject.transform.tag quot InventorySlot quot ) if(mouseReleasedObject.transform.childCount lt 1) the inventory slot is empty, we place here the item! draggedItem.transform.SetParent(mouseReleasedObject.transform) draggedItem.GetComponent lt RectTransform gt ().localPosition Vector3.zero else the inventory slot is taken, we swap the items! else the item is not released on a proper slot, we restore it's position! draggedItem.transform.SetParent(dragStartSlot.transform) draggedItem.GetComponent lt RectTransform gt ().localPosition Vector3.zero


Unity how to implement a sound detection ? I want to trigger an event if an enemy (or player) can hear a sound generated from other enemy player. How to implement a sound detection system ? Thanks


Unity tilemap collider not colliding with rigidbody In the wireframe you can see the tilemap collider for this hill. The red circle falls right through however. The circle has a 2D rigidbody attached. Everything is on the Default sorting layer and on layer order 0.


Unity and Chartboost loading problems I implemented chartboost in my ios game and locally it wors great. I can receive ads. Now my game is online but in the google analytics I get only error messages from the game, meaning the chartboost ads fail to load. Here https www.dropbox.com s cft98lk27mt7p3s cb.jpg?dl 0 The iage show google analytics registering only failed loads and there is no single successfull ad load? What could be the problem here?


Why the Vector3.Dot value is 12 when running the game? using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI using UnityEngine.Events using System public class InteractableItem MonoBehaviour public string currentMode private Transform player private InteractableMode currentInteractableMode private string currentDesription private float originDistance private void Awake() player GameObject.Find( quot Player quot ).transform originDistance transform.GetComponent lt InteractableItem gt ().distance public enum InteractableMode Description, Action, ActionWithoutThrow public enum ViewMode FrontView, AllView public ViewMode viewMode ViewMode.AllView public InteractableMode interactableMode InteractableMode.Description public float distance TextArea(1, 10) public string description quot quot public bool IsAnyAction() return interactableMode InteractableMode.ActionWithoutThrow interactableMode InteractableMode.Action public bool IsActionWithoutThrow() return interactableMode InteractableMode.ActionWithoutThrow private void Start() currentMode GetComponent lt InteractableItem gt ().interactableMode.ToString() currentInteractableMode GetComponent lt InteractableItem gt ().interactableMode currentDesription GetComponent lt InteractableItem gt ().description private void Update() var heading transform.position player.transform.position var dot Vector3.Dot(heading, transform.forward) if(viewMode ViewMode.FrontView amp amp dot lt 1) transform.GetComponent lt InteractableItem gt ().distance 0 if (viewMode ViewMode.FrontView amp amp dot gt 1) transform.GetComponent lt InteractableItem gt ().distance originDistance The script is attached to some objects and one of them the ViewMode is set to FrontView and then when running the game first time the dot value is 12 and then it's getting inside and going the line if(viewMode ViewMode.FrontView amp amp dot lt 1) transform.GetComponent lt InteractableItem gt ().distance 0 but it should not set the distance to 0. only if I'm getting close enough to the item then it should see the item from the front and then only if I'm moving the player behind the item the dot should be minus and set the distance to 0 but for some reason the dot is minus 12 when running the game so it's setting the distance to 0 right away.


Tilting a game object left right forward back with gyroscope, regardless of player's heading I'm working on a mobile game in Unity and using the gyroscope to rotate an object along the x and y axes. float x Input.gyro.attitude.x float y Input.gyro.attitude.y This code give me the rotation I want when pointed in a certain direction along the z axis. I want the rotation to not depend on the z axis. I want the rotation to act the same no matter what direction I'm pointed in the real world. Here is a 12 second clip of what I get using a mobile gyroscope when pointed at 1 or North on the z axis I want the rotation to be the same no matter what direction I am pointed on the z axis with the gyroscope. Is there some way to rotate the whole coordinate system?


Triggering animation in character OnTriggerEnter? I've been stuck on this for hours. I have a character whose animations are based in mecanim to transition based on the bool variable ShivaEnter. One invisible cube is set to change the bool value from false to true and vice versa OnTriggerEnter. The code is as follows using UnityEngine using System.Collections public class PontyAnimations MonoBehaviour SerializeField private Animator animator private GameObject ponty private GameObject ponty void Awake () animator GetComponent lt Animator gt () void OnTriggerEnter (Collider other) if (other.gameObject.tag "Player") animator.SetBool ("ShivaEnter", true) void OnTriggerExit (Collider other) if (other.gameObject.tag "Player") animator.SetBool ("ShivaEnter", false)


Build displays black screen with static Something really odd happens when I'm trying to load a scene. It is supposed to look like this (it also has to show the next scene after loading) What is going on?


Instantiate prefab button inside of panel I have a Canvas GameObject with a panel inside of it and a button prefab of the default button. When I drag the button from my resources folder onto the Canvas in the hierarchy, it places itself where I expect it to, into the panel. However when I instantiate it like below GameObject button Instantiate(Resources.Load("UI Dialogue Button"), new Vector3(0, 0, 0), Quaternion.identity, MyCanvas.transform) as GameObject it gets placed into the center of the screen because of the second parameter. However, I can't set it as a child of the parent because that doesn't happen until the last parameter. It also doesn't feel right to figure out the exact Vector3 to plug in so that it looks like its on top of the panel. Is there a way to instantiate the button onto the panel in code as it works when dragging it from the resources folder onto the Canvas in the hierarchy?


Unity C Array Scripting! I was just trying and make a simple 2D game. I have a simple circle sprite (red, green and blue). These circles fly upwards with my scripting as shown below public class Direction MonoBehaviour public GameObject ballons public float increase public float timeInterval public float timeForGetGo public float increaseInterval public float startTime public float timeForNextSpawn public Transform instantiatePos void Start () StartCoroutine (direction ()) void Update () increase increaseInterval direction () Instantiater () IEnumerator direction () while (true) foreach (GameObject gameObjects in ballons) gameObjects.transform.position new Vector3 (gameObjects.transform.position.x, gameObjects.transform.position.y increase, 0f) yield return new WaitForSeconds (timeInterval) So, instead of making them fly with one script by one script, which I normally do, I tried to make array of these gameObjects and make them go upwards. It worked great! But, I have a problem. I want these upward going circle to instantiate but when I instantiate them, they won't go upwards as they aren't in the list of arrays I put earlier as in public GameObject ballons in first line in that script. So, as in conclusion, my problem is the instantiated objects won't have same property coz the script is attached to another gameobject and not in the original gamobject itself. Any ideas?


Make a game object move inside circle and bounce from walls without gravity I have a circle with a RigidBody2D and CircleCollider2D components on it. I'm trying to make it move constantly inside a bigger circle without gravity involved, make it bounce off the circle walls like it has constant velocity but without any delays, same speed all the time. Here is an example of the same behaviour but inside a rectangle I would like to do the same but inside a circle and detect the collision with the circle walls Thanks in advance )


Black screen after running emulation mode in the Unity Editor for hololens I am having issues with black screen when running the emulation mode or simulator for Microsoft hololens. In the preview the camera shows what the user should see. I see no obvious reason to behave like this and no error warning is given. I am using code snippets from the Origami tutorial,except I chose to use RayCastNonAlloc. Movement.cs public class Movement MonoBehaviour public GameObject person public float seconds private Vector3 point new Vector3(0,0,0) private RaycastHit rayHit new RaycastHit 5 void OnSelect() person.transform.position Vector3.Lerp(person.transform.position, point, seconds Time.deltaTime) Update is called once per frame void Update() if (Physics.RaycastNonAlloc(Camera.main.transform.position, Camera.main.transform.forward, rayHit, Mathf.Infinity, 0) gt 0) foreach (RaycastHit hit in rayHit) point.x Mathf.Clamp(hit.point.x, 290f, 6970f) point.y Mathf.Clamp(hit.point.y, 40f, 1860f) point.z Mathf.Clamp(hit.point.z, 1700f, 140f) Scene.cs using UnityEngine using UnityEngine.XR.WSA.Input public class Scene MonoBehaviour public GameObject cursor public GameObject Focused get private set public Scene Instance get private set private GestureRecognizer recognizer private MeshRenderer Renderer private readonly RaycastHit rayHit new RaycastHit 5 void Awake() Instance this recognizer new GestureRecognizer() recognizer.Tapped (args) gt if (Focused ! null) Focused.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver) recognizer.StartCapturingGestures() Renderer cursor.GetComponent lt MeshRenderer gt () void Update() GameObject oldFocused Focused if (Physics.RaycastNonAlloc(Camera.main.transform.position,Camera.main.transform.forward,rayHit,Mathf.Infinity, 0) gt 0) Renderer.enabled true foreach ( RaycastHit hit in rayHit) cursor.transform.position hit.point cursor.transform.rotation Quaternion.FromToRotation(Vector3.up, hit.normal) Focused hit.collider.gameObject else Focused null Renderer.enabled false if (Focused ! oldFocused) recognizer.CancelGestures() recognizer.StartCapturingGestures()


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


Why Unity Navmesh codes should be executed first? I'm trying to calculate path using NavMesh.CalculatePath and use rigidbody alongside with it, how ever if character does not stick to navmesh baked area the calculatePath codes will not work. I also found that if my path finding codes does not run first the path finding will not work either. for example void Update path finding in this script will work PathFinding() GetDistance() void Update path finding in this script will NOT work GetDistance() PathFinding() any help regarding to solving the problem or understanding how Unity navmesh system works will appreciated.


Comparing analog stick movements to predefined flick shapes I want to create a control scheme similar to the EA Skate games, where flicking the right analog stick in various ways makes the character do various tricks I record the user input over a set amount of time or until the user moves the analog stick back to its resting position. The recording is a List of Vector2 Coordinates. Depending on how fast the user flicks the analogue stick, I sometimes get a shorter (15) or longer (45) list of points. Now I want to compare these lists of points to predefined shapes like the ones in the screenshot, to match which action the player intended to take. My idea was to use some metric to compare the similarity of the recording to lists of arrays, however, I don't which metric I might use. I found the Hausdorff Metric and it seems applicable, but I don't know how to implement it. It might also be an overkill for the problem, so I wanted to ask, how other people would solve the problem.


How to manage collision of two player ? I'm developing a multi player car game. Suppose that car A hit car B both A and B have Rigidbody and collision functions attached. Because car A hit car B i want to take actions only to car A (add or remove point) but not to B. So i need to identify that car A is 'hit' (with guilty ) car B that has no 'guilty'. Can you suggest me how to do ?


Black stripes at the junctions of road segments I made a simple runner where the road is dynamically generated, and the sphere together with the camera moves with the help of Rigidbody velocity, but the problem is that black bars appear at the joints between segments, and if you add an AddForce sphere, then the sphere at the joints jumps which should not be. How to solve this problem I checked the positions of the segments, they fully correspond to the desired ones, that is, there are no gaps between them, I use the standard shader Segments 10.4 units in size. Imported from Blender, but if you take the standard cube model then the same thing (black bars), so that s not the point. Positions between these segments The segment before (on which the sphere in the screenshot) and the next segment Road Material Settings


How to get good movement synchronization in a networked game (action shooter) I've spent the last two days trying to get good movement interpolation with Photon in Unity but I can't get anything that I'm happy with. I've tried several methods but none satisfied me. My understanding is that I better use some kind of interpolation (as opposed to extrapolation dead reckoning) because in my game the players can change direction fast. I've tried lerping between the current position and the last received authorized position, I've tried lerping between the old and the new authorized position, but nothing gives me the right amount of responsiveness smoothness. What can I do? Sample code public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) if (stream.IsWriting) do we have authority over this object? stream.SendNext(transform.position) stream.SendNext(transform.rotation) else newNetworkTime Time.time oldPosition transform.position oldNetworkPosition networkPosition networkPosition (Vector3)stream.ReceiveNext() networkRotation (Quaternion)stream.ReceiveNext() void RemoteMovement() float t 1.0f ((newNetworkTime interpolationPeriod Time.time) interpolationPeriod) transform.position Vector3.Lerp(oldPosition, networkPosition, t) transform.rotation Quaternion.Lerp(transform.rotation, networkRotation, Time.deltaTime movementSpeed)


How to make a 'Picture book Cutscene' in Unity 2D with simple 2D images? I'm trying to implement a simple cutscene system in my Unity game, preferably one that allows cutscenes to play at the start and end of each of the levels. What I was imagining was pretty similar to A Hat in Time's 'storybooks' from it's time rifts, but full screen and advanced with a single key. The images are simple and comic like, and I was wondering how to implement such a feature since it feels like it's a bit different to Unity's pre existing Timeline system, as there isn't many moving parts. How do I go about approaching this problem? At least, I don't know how to get the project to a state where a person can press a key to turn to the next page (whether or not there's a visual transition to the next is optional) and once it's done, to start the actual level scene. Do I still use the Timeline for this? I know I could potentially use an empty game management prefab in order to set up when to play the cutscenes, however.


How to manage "jump" in my 2d platform game? I'm developing a simple 2d platform game with Unity 2d. I have a problem managining my "Jump" action for the player. I would like the player to Jump only when he has his feet on a "surface" terrain, platform, crate etc. I'm considering using colliders when my player collides with a surface, set my bool canJump true. When he jumps, I set canJump false (he is midair). My terrain has a Rigidbody2d is Kinematic and a Box Collider 2d. My Player has a Rigidbody2d is Dynamic and a Capsule Collider 2d (or a Polygon Collider.. ) The events OnCollisionEnter2d() and OnTriggerEnter2d() are never raised when Player collides with terrain. Does anyone know what's wrong? Thanks EDIT Now i'm using this to check if "something" is under my feet RaycastHit2D hit Physics2D.Raycast(rb.transform.position, Vector2.up, 0.1f) if (hit) canJump true It doesn't works! hit is always true! I'm getting mad!


Unity Passing an array in a shader I want to pass my array (which is inside my c code) to my shader. Shader "custom shader4" Properties myArray("Array", Float 256 ) SubShader Pass CGPROGRAM public float myArray 256 code... this is obviously not working. Is anyone here who knows how to solve this? (also in c ) myMaterial.MyArray anotherArray It has to be something like this right? Or do I need a workaround?


Rigged through Blender (Rigify) and Errors in Unity I am working on a Unity scene and as the 3D model is missing the bones, I ended up going to Blender for the rigging. For that, I followed the procedure that Unity suggests by using the add on Rigify. I was also following this tutorial, which was really helpful. After exporting from Blender (in .fbx) and importing it on Unity, I went through the configurations (as vcard suggested here) In the "Rig" section, I pressed the button "Configure" (to configure the Avatar Definitions) and came across an error "Character is not in T pose". I solved this one quite fast by accessing the menu "Pose" (in the Inspector) and then "Enforce T Pose". After that, back in the scene, I came across the following error on the Inspector Invalid Avatar Rig Configuration Missing or invalid transform Required human bone 'Head' not found. I went straight to the configurations and decided to add the specific bones to the Head that appeared on the inspector (in the Avatar Definitions configurator). With that, I came found out that the problem is really the organization where there were placed by Rigify. Any guidance is appreciated.


What is the bare minimum I need to set up the Android SDK for Unity development? I want to import my Unity project to Android, and I need to download the Android SDK, but I do not want to download any unnecessary components. Do I need to download all platforms, or just the latest one? I am worried about the size of Android 7.1.1 (API Level 25) the SDK Manager reports this as the latest version, but I am not sure. I only want to import my project for Android smartphones, with no plan of publishing it. I do not want to build to Android TV or Android Wear, for example. Do I need to download all of the contents under the specific platform? I ask because there are Android TV and Android Wear system images, and the files can get quite large.


How can I change the highlighted color of a Unity button when it's clicked? I was playing around with buttons in Unity, and I wanted to see if I could change a button's highlighted color every time I clicked on it. I added a script in the same GameObject as a button component, and I had a changeColor function attached to the component's OnClick(). The function was in a ButtonScript class written like this public class ButtonScript MonoBehaviour public Button button public void changeColor() Debug.Log ("Changing highlighed color") int r Random.Range (0, 255) int g Random.Range (0, 255) int b Random.Range (0, 255) Color currentColor button.colors.highlightedColor currentColor.r r currentColor.g g currentColor.b b I couldn't do button.colors.highlightedColor new Color(r,g,b) because I got a "Consider storing the value in a temporary variable" error. When I tried a test play and clicked the button multiple times, the highlighted color didn't change. How can I make a function that changes a button's highlighted color when it's clicked, if it's possible?


How to make a collider the follows all the animations of a prefab? I have attached a capsule collider with my player(prefab) and made a script so that when Space key is down it does the jump animation in Unity. But because of the collider not jumping with the player, the player gets stopped by obstacles though he visually passed it. How can I make a collider that moves with my animations attached to a prefab?


Load large quantities of data in Unity3D I'm building an Android app using Unity3D where users can visualize data immersively. The data is immutable and stored using a MySQL database hosted on cPanel. When the user clicks a button in the environment, it starts the creation of a chart. First, contacts a .php file present in the server responsible to query the database, fetching the data and make it available to the Unity controller which then adds the points to the chart. This works fine for small quantities of data. To increase performance, thought of exporting from MySQL as CSV and transform to one JSON, instead of querying a database or try to make MySQL transform to JSON, but I'm afraid this won't be enough. Could also extract as CSV and use a 3rd party for reading it. How would you load the data in such case to have the best performance?


NavmeshAgent not to turn back Imagine the blue part of this picture is streets and navmesh. the red object is a car with navmeshAgent. the green circles are the colliders set as triggered and they are the destination of the car. when the game starts the car will choose one of them and go to that , after reach that it will choose another one randomly so it means the car will go through all of this forever. now the problem is sometimes when car reach's one them and choose another since it will choose the closer path to next destination sometimes it will have to turn back which its not realistic and doesn't make sense. as you can see in this example when reach that point since the middle one is closer from where the car is triggered it will turn back and the red arrow is wrong path , instead it should go through the green arrow and that's the correct path. how can i do something to not to turn back instead find another way?


Need help with my on collision restart program I tried using the program using UnityEngine private void OnTriggerEnter(Collider other) if (other.tag "setting object tag") Application.LoadLevel(Application.loadedLevel) But the OnTriggerEnter command came up with an error saying "a namespace cannot directly contain members such as fields or methods". And the Application.LoadLevel(Application.loadedLevel) program had an error saying "application.loadedLevel is obsolete, use sceneManager to determine what scenes have been loaded".


Circle Collider 2d is slipping off box colider2d when it shouldnt I have a crude rectangle sprite with a box colider 2d, and a circle sprite with rigidbody 2d and circle collider 2d, as seen in the image below. When I click on the red rectangle, it moves up fairly quickly a little more than the diameter of the circle. If this occurs from the position show, or with the circle any further right than it currently is, the circle appears to fall down onto the yellow box almost instantly, hugging the side of the red rectangle. If I let the circle go a little more onto the red rectangle then it is pushed up correctly. Why is the circle falling off the red rectangle from this position, and how can I prevent it from acting like this?