Unity Rotations Not Following Local Nor Global Axis? In the gif below, you can see that rotating on X moves all 3 axis including the X axis. It's possible it's rotating on the global X rather than local X (hard to tell). But Y looks more like it's rotating on global Z and Z is quite clearly rotating on local Z. What is going on? Why is there no consistency?


The name FB' does not exist in the current context I am trying to allow the user to share the final game score on their FaceBook timeline. I am following FaceBook tutorial and examples. When I try to download and import the FaceBook SDK package (7.11 2.0) in Unity (2017.3) I get the error error CD1704 An assembly with the same name 'FaceBook.Unity.Settings' has already been imported. Consider removing one of the references or sign the assembly Library FacebookSDK FaceBook.Unity.Settings.dll (Location of the symbol related to previous error) I read on other posts that the latest version of Unity may have the Facebook SDK already integrated, and will not require importing the package manually. I therefore removed the from my project. The error disappear, but when I try to initialize the Facebook SDK for Unity using the code below, I get the error The name FB' does not exist in the current context using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI using Facebook.Unity public class ShareOnFaceBook MonoBehaviour Use this for initialization void Awake () if (!FB.IsInitialized) Initialize the Facebook SDK FB.Init(InitCallback, OnHideUnity) else Already initialized, signal an app activation App Event FB.ActivateApp()


How can one replicate the 'Quake Disruptor' of Wipeout XL 2097? Following my previous question, I am wondering how one can achieve the same effect under Unity? The effect in action https youtu.be kzmmLeCwL0g?t 790 Description of the effect When you fire the Quake Disruptor weapon, it creates a sine wave that mimics an earth quake, it happens over the next track sections forward to the player ship as you can see on the small video. This results in instant damage and slowdown to the ships that are caught in the quake. Technical challenges Deforming the mesh The function for generating a quake like wave to apply to each section of the track mesh is easy, e.g. a Gaussian filter will probably be good enough https www.desmos.com calculator goasdepcmv Applying the deformation to mesh This is where it starts to get trickier, a track is made out of sections that have few faces, each face being nothing more than a quad. Here you can see three sections and their faces (wall, track, track, wall) The challenge in here is how to apply the deformation and yet being able to check collisions against the track (remember that we can't use a mesh collider since it'll be updated in real time). I first thought that subdividing the mesh using tessellation would be needed to apply smooth deformations, hence my previous question. However, if you look closely at the video they simply move either edge of faces according to where they're against the 'quake' function being applied to the track mesh. Here's a link to a video with the best quality, around 13 mins 10 secs https archive.org details PSX Longplay 243 Wipeout 2097 We're getting closer but we still need to be able to check for collisions. Being able to still collide against the track This is the big question mark, since we cannot update a mesh collider in real time as it's a CPU hog, I really have no idea on how to address this part of the problem. This also leads to another problem, since we cannot use a mesh collider, how are physics are going to be handled, by writing a physics system from scratch ? Question How can such effect be achieved under Unity, if possible at all? PS You will want to remember that the PS1 had a 33Mhz CPU and certainly no mesh collider like the one we can find in Unity, yet they achieved to do it. For sure there is a trick involved but I couldn't figure it out.


How to create HDR and bloom in Unity3D? Unity3D's reference describes the HDR Bloom as Using HDR allows for much more control in post processing. LDR bloom has an unfortunate side effect of blurring many areas of a scene even if their pixel intensity is less than 1.0. By using HDR it is possible to only bloom areas where the intensity is greater than one. My question is how to achieve it in a surface shader? I have tried to output both the Albedo and Emission greater than 1, but still when I set the Threshold of Bloom equal to or greater than 1, no visible effect can be seen. The relevant part of shader snippet is float rim saturate(dot(normalize(IN.viewDir), o.Normal)) if (rim gt 0.98) o.Emission 1.5 or any large value Which basically outputs a bright white circle when view angle and normal are at almost same angle, and I want to enhance it with HDR. But outputting a value greater than 1 is not being registered and setting the threshold almost equal to 1 (0.98 or above) creates the Bloom on areas other than the bright white spot, which is not what is needed. I have tried to output extremely large values of Emission and have also tried output Albedo 1. Please tell what I am doing wrong or missing. I think I have not been able to figure out what is the meaning of pixel intensity 1 and what settings does this translate to.


Imposters in Unity How to set which color is used as 'transparent' in the RenderTexture? I'm still working at making imposters for my Unity scenes. Here I am attempting to make a large block of stadium seating, using the one seat mesh as shown. I'll try to explain in full what Ive done so far Imported 3d mesh of seat Created RenderTexture 'seat' (default format R8G8B8A8 UNORM) Added new Orthographic camera in front of seat. (settings Clear Flags Solid Color TargetTexture 'seat' Created some quads and aligned them so I can see the textured side. Gave the quads a new material 'seat'. I've gone through many of the settings in the Material and other places changed many things here and there such as 'transparent' or 'cutout' and lots of the other settings but cannot get rid of the magenta color in the seating textures I created. Also tried making that color alpha 0 but it had no effect. And tried various colors as transparent (magenta, white, black). Am I doing this completely wrong? Hopefully I am just missing some small setting. Ideally somewhere I can just set the magenta color to mean transparent pixels. Really do need help here honestly have been trying very hard to achieve this alone but not getting anywhere fast.


How do I determine the rotation of a Tile using Tilemap in Unity 2d? I want to know the rotation of the tile in C in order to do some logic on another object that is sitting on the tile. The rotation matters for the logic. I don't see anything except GetTileData in the doc, but that doesn't actually seem to "Get" the tile data. I could cast to Tile but not all tiles are Tile. Alternatively, I think I can get the rotation if I can get the GameObject for the tile but I have no idea how to do that either from a BaseTile. Anyone have any suggestions? Maybe I'm trying to do this wrong and I should make different tiles for each orientation or extend BaseTile or some other solution instead of trying to determine rotation. Any help or ideas would be greatly appreciated! Additional info When I inspect around in the Unity editor I see that the rotation is stored in Z in something called "Grid Selection" but I can't find a programmatic way of accessing that.


World rotation independent mouselook Preface I am terrible at using quaternions right. I wanted to create a world rotation independent mouselook script. That is, no matter the 'down' for the camera, the mouselook should feel natural to the player in relation to what is displayed on screen. I now have the following script running on update in my camera Quaternion worldRot Quaternion.LookRotation(Vector3.forward, Vector3.left) xRot rotSpeed Input.GetAxis("Mouse Y") yRot rotSpeed Input.GetAxis("Mouse X") transform.rotation Quaternion.AngleAxis(yRot, worldRot Vector3.up) Quaternion.AngleAxis(xRot, worldRot Vector3.right) worldRot Unsurprisingly, it tumbles all over the place. I think the issue is in basing the rotation angles on the worldRot (World rotation as seen by the camera), while then also rotating the whole by worldRot. I cannot get my head around how else to go about it, though... My initial alternative was to use transform.rotation Quaternion.AngleAxis(yRot, Vector3.up) Quaternion.AngleAxis(xRot, Vector3.right) worldRot But this anchors the mouse's movements to the world rather than the camera, which as described above isn't desired either. Based on this (or, perhaps, in a completely different way), how do I make a mouselook system with an arbitrary down vector?


Is there a way to view all colliders in a unity project at runtime (after the game have been deployed)? I'm have created a small Unity project but physics has weird behavior (bug). Unfortunately it only happens on some specific hardware (after build), not on development machine. I don't know what is the reason it's probably due to different framerate. Viewing all object and their colliders would probably help me a lot. Is there a possibility in Unity to view all colliders in the game at run time (some kind of debug mode). Something similar as Game tab view in Unity with Gizmos option enabled, but for all objects ?


How do I draw a context menu next to my object? I want to show a menu next to an item in an inventory. This is what I try to rebuild I do this by placing a canvas in 3D world space next to the inventory As I don't want the menu to be rotated, I rotated the menu the opposite X value as the camera. The camera has an X rotation of 11, so I rotate the menu by 11 to make it look straight Since I don't want the menu to get stuck in the case, I move it closer to the camera One can see that the menu is now offset to the left and to the top because of the camera perspective. How could I offset the menu in such a way that it still aligns with the right top corner of the item? Thank you!


Unable to get accurate y position on terrain to spawn object all I am trying to spawn some crabbies and can't seem to get an accurate y height to spawn. I have a terrain created with GAIA Pro 2 and have tried a few things to get an accurate y value. When trying to get the y from the terrain data I keep getting a 0 for example newCrabStartPos.y mainIslandTerrain.terrainData.GetHeight((int) rayPosition.x, (int) rayPosition.z) getYPositionFromRay(rayPosition) 2.5f Here is my current implimintation IEnumerator SpawnCrab() while(spawnedCrabbies lt waveCount) GameObject instance Instantiate(Resources.Load( quot Whakin Crab quot , typeof(GameObject))) as GameObject instance.transform.position SetStartPosition() spawnedCrabbies 1 yield return new WaitForSeconds(spawnRate) Vector3 SetStartPosition() float minDistanceAwayFromGoal 10f float maxDistanceAwayFromGoal 50f float xpos Random.Range( 1f, 1f) lt 0 ? Random.Range( minDistanceAwayFromGoal, maxDistanceAwayFromGoal) Random.Range(minDistanceAwayFromGoal, maxDistanceAwayFromGoal) float zpos Random.Range( 1f, 1f) lt 0 ? Random.Range( minDistanceAwayFromGoal, maxDistanceAwayFromGoal) Random.Range(minDistanceAwayFromGoal, maxDistanceAwayFromGoal) Vector3 newpos new Vector3(xpos, 0, zpos) Vector3 rayPosition new Vector3(xpos, 100, zpos) Vector3 newCrabStartPos new Vector3(newpos.x, 15, newpos.z) newCrabStartPos newCrabStartPos goal.transform.position newCrabStartPos.y getTerrainDistanceFromRay(rayPosition) mainIslandTerrain.terrainData.GetHeight((int) xpos, (int) zpos) getYPositionFromRay(rayPosition) 2.5f return newCrabStartPos float getTerrainDistanceFromRay(Vector3 drawFromPosition) RaycastHit hit new RaycastHit() if (Physics.Raycast(drawFromPosition, Vector3.down, out hit, 100)) return (100 hit.distance) collider.gameObject.transform.position.y return 0


Preparing a 2D character to export from Blender to Unity? I'm an animator for a game currently, and I don't have Unity (can't download due to too much gigs coupled with slow internet,) but the game designer told me I can use Blender to export animations into Unity. I asked if I needed to prepare multiple files to export, and they told me that I could just have one file with all the animations in it. The game, as stated in the title, is 2D. My problem now is, how do I turn a rig into an actual character with different animations under it? (Right now I only have an 'idle' animation, but need to make running, jumping, walking, etc.) I mean how do I save this 'idle' animation and work on another animation without overwriting the previously finished animation(s)? Thank you much


accelerometer not working unity why is the cube moving when I use a controller, but not with the accelerometer? void Update () text.text "X " Input.acceleration.x " Z " Input.acceleration.z transform.position new Vector3(10 Input.acceleration.y, 0, 10 Input.acceleration.z) transform.Translate(Input.acceleration.x, 0, Input.acceleration.z) transform.position new Vector3(10 Input.GetAxis("Horizontal"), 0, 10 Input.GetAxis("Vertical")) transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) (I'm on a Xperia Z3 compact by the way)


How can I implement UI in Unity using Chromium? I'm looking for an alternative to UI Builder. Ideally I'd like to have basically a Chromium instance atop Unity3D which would have its JS calls somehow land in the C (maybe in the quot Update quot loop it listens to a constant stream of potential calls and the parameters will correspond to function names in my Unity code, I don't know) here's what I found which doesn't quite live up to my expectations Unity WebView doesn't support Windows. 3D WebView for Windows and macOS (Web Browser) requires the UI to be served on an actual live URL and for Unity to access it via that URL and for all interaction to be handled via API, impractical or slow at best. PowerUI HTML CSS is interesting, but was made in 2011. The documentation is all gone. the support for css feature is probably incredibly slim. Embedded Browser looks pretty good, but I'm unsure that it could be bent into a UI system. I want it to frame my game, not to cover it. Coherent Gameface looks probably the best, although the CSS implementation seems a tad lackluster. Also this project was started in 2012, it's probably carrying very old, very slow code. This Unity forum thread may be relevant. Chromium Embedded Framework was a tool used by some assets on the asset store to create chromium UI but it has been removed. If not using these assets, how can I implement my idea of using Chromium as my UI layer?


Why does Unity3D crash in VirtualBox? I'm running Unity3D in a virtual instance of Windows, using the Virtual Box software on Linux. I have guest additions installed with DirectX support. I've tried using Windows XP SP3 32 bit, and Windows 7 64bit. My host is Ubuntu 12.04 64bit. I installed and registered Unity on both. It loads up fine, and then crashes my entire VirtualBox instance (equivalent of a computer shutting off with no warning).


How to create a solid cross scene game manager in the editor of unity? I have been checking dozens of known 'solutions' for how to create a game manager in Unity, but none leave me satisfied. I know I can create a singleton GameManager.Instance() that would have data to persist across multiple scenes, but it doesn't show up in the editor unless I assign it to a game object. The problem is, this game object would then be destroyed upon loading a new scene except if I use DontDestroyOnLoad(). However, when I use DontDestroyOnLoad(), and I open up a new scene in the editor, this GameManager Object doesn't exist in the new scene. The DontDestroyOnLoad() method assumes that the program entry point will always be the main first scene, which is often not the case when working in the editor. This isn't great. Example When I have events within scene2 (say a button or something), I cannot reference the gameobjects in scene1 in the Unity Editor (most importantly, the game manager). Instead, I have to first attach a settings.cs script to my UI Button GameObject. When pressed, the Button will then call a function from the settings.cs void ChangeInput() GameManager.Instance().ChangeInput() . This feels quite clunky because the Button Element cannot reference the GameManager directly, since the Button is scene specific but the gamemanager is not. Is there a proper solution for issues like this?


Architecture for extremely modular game? I'm developing a modular game in Unity 5.6. Each module has very little overlap in assets with the others. I'm concerned about having a bloated repository after a few months of development, and since I'm using Bitbucket (a free account) I'm limited in my repo size, but not in my number of repos. So instead of having one huge folder for my game I'm considering having a launcher project and scene that loads builds from a folder in Assets. Each module would be its own project, and I would just drop its build into the launcher's folder. My question is, is this a reasonable approach to building a highly modular game? Hopefully I'll be continuing development for quite a while, and I want to make sure the project is as lightweight and extendable as possible. Or am I overthinking this, and should I just use one big repo?


Avoiding singletons for puzzle system Say for instance I have a puzzle with 3 switches that need to be in some configuration (say all on) in one room, that opens a door in another, with a load screen separating, so I can't link the switches directly to the door. My first thought was to create a singleton that stored the state of each "solution element" which in this case is the switches, but could be a correctly turned knob, ect. then a given "Puzzle Gate" like a locked door would check the required solution elements to decide it's own state, but I'm hesitant to use singletons for all of the commonly given reasons. What alternatives do I have to singletons that would give me the same or similar control?


Duplicating and adding sprites at runtime in Unity I am trying to create a 2D game in Unity in which objects keep falling from top and the player has to dodge them. Suppose I have created a sprite which serves as a single enemy that the player has to dodge.Now I have to create multiple such sprites at runtime so that they can keep on spawning from random positions.Despite searching on the net for quite some time i could not find a clear answer. I am just a newbie and I am just starting to learn game development in Unity so answers in detail will be very helpful. Thanks in Advance.


Unity3d How to use controller joystick to look around? I try to use my xbox controller as input device for a game targeted to run on windows. However the documentation fails to explain how to set it up. E.g. how can I use the right stick from my xbox controller to look around, like in any 3D game? Even such a common task is not documented. I found a very old wiki entry where the xbox controller is briefly described, I was able to find out that the Y Axis of the right analog is called 5th axis (Joysticks) and the X Axis is called 4th axis (Joysticks). I post the images below, in case the link get's dead. Linux Note wired controllers only support axises for the d pad, while the wireless controller only supports buttons for the d pad, refer to the table above for the wireless controller configuration. I figured out that the name of a control is responsible for the action which the button, stick, key, pedal etc. does. But it is not documented how the control has to be named for looking around vertically or horizontaly like you can do in an 3D game to look around with the camera by using the right joystick (e.g. witcher 3) How can I control the camera by using the right joystick?


My bullet keeps going up So I have a bullet script that fires a bullet straight in the Y direction that gets called as the bullet is instantiated. The plan is to always shoot in the same direction, straight in the Y, but to just rotate the bullet upon instantiation so that the straight is the right kind of straight if that makes sense? What i really want to know i think is how to work out the value for the 3rd property of the instantiate based on the key pressed before the fire, what makes it worse is that i dont even know how to create a rotation variable. Instantiate(Resources.Load("P1Bullet"), transform.position, transform.rotation) this is how i move my bullet in the bulletmove script void Update () Vector3 pos transform.position Vector3 vel new Vector3(0, speed Time.deltaTime, 0) pos pos transform.rotation vel transform.position pos


Can a material be created from a gameobject in Unity? I am trying to manually create snowflakes in unity, after I created a snowflake in the unity scene, is it possible to create a material out of it?


Unity change default settings for standard components How can I change the default settings for the standard components or is this even possible? E.g. setting the default font size for a text component so that each new text component I add will have the same font size?


Relative vertical alignment of 3 Texts on Canvas This is a menu that appears if I press Enter on the RE4 inventory if an item is selected. I have drawn a thin red rectangle around it And here is a video that shows some of the menu's effects. I am familiar with a simple text canvas. I understand that I need to make each line a separate "Text" object so that I can scroll up and down through them. Here is what I have so far The problem that I'm facing now is that the Canvas will be scaled at runtime. I don't work with fixed values. This is a problem since I don't see how I could easily make it so that each TextLine object fills 33,3 of the canvas. Am I right to assume that I can only solve this by making a scripts that holds a reference to each TextLine object and which then calculates their position when the scale of Canvas is known? Or is there any easier solution? Thank you!


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


Accelerometer input for flying game I'm trying to create an infinite flying game where the gameobject (a plane) keeps moving forward and at a particular height throughout the game. I want to be able to roll and pitch the plane but not move it up down. I added a rigid body to the plane and selected "y" position constrain. However the plane doesn't stay in the 'y' position but starts move up or down. I just have a script that translates the plane in the z direction. Not sure how to implement the mobile input and keep at the same "y" position throughout. Update Here is the code for the plane. Its very basic as I'm not sure how to use the accelerometer public class Player MonoBehaviour public float speed 1.0f void Update () float tempx Input.acceleration.x float tempy Input.acceleration.y float tempz Input.acceleration.z transform.Translate(0, 0, 10) move forward in z transform.Rotate( 0, tempy speed, tempz speed) As for the freezing of the 'y' position, I'm just selecting the y constraint available in the inspector that comes along with the rigidbody.


Unity Performance Recycling Pooled Objects OR Re Instantiating? Re using pre instantiated objects in a pool. Destroying then re instantiating objects in a pool. Both pools are limited. When creating loads of objects which is better for performance?


Proper way to calculate x and y components of two 2D vectors I'm having some issues on resolving this with the current set of Vector2 methods. Could you help me to define a universal solution? The idea is to move a spaceship to another point using only relative to (A) lateral and forward movements. Given two points A(1, 1) and B(2, 3) A has a known angle with the y axis alpha How to calculate the x dist and y dist relative distances in order to move A to B?


How to display a GUI text at run time in unity? I'd like to display a GUI text at run time in my game for a second, so I want to know if it's possible to add or remove a GUI label to the scene at run time?


Unity Small holes of light seems to go through my blender mesh So, I am currently working on a low poly terrain in Blender which will be flat shaded in Unity. It all works great, however I am working on a cave for the terrain, and I seem to be getting these small odd light artifacts I have tried to highlight them with the read circles. If you look carefully, you can see the small holes. The odd thing is, the entire mesh should be completely solid. Here's a screenshot of the cave entrance in blender (which is the floor I'm looking at in Unity) All normals of the faces seems to be facing correctly, and mesh has simply been modelled by extruding edges from existing parts of the mesh, so there shouldn't actually be any actual holes. Does anyone have any experince with this kind of problem?


How can I call two functions in a sequence with onclick? I'm learning Unity. I have two functions, one that transitions to a new scene and the other one is the button animation. I add both functions to the onclick of a given button. I assume it calls both functions at the same time and executes the transition without running the animation. I want the button to run the animation first (I'm using DOTWEEN) and once it's done to execute the transition.


Split group of enemies? . . In my script, enemy goes to dead point and if player closet to him he attacking player. When I started making wave of enemies I notes that all of them goes to player. Now, I need to add something making enemy avoid player in case there are 4 enemy around him and goes to dead point. What I did is, I attached every player script "enemyAround" to count any enemy around player. public int enemies 0 void OnTriggerEnter(Collider other) enemies void OnTriggerExit(Collider other) enemies But I couldn't figure how to make enemy read it ?. If Enemy select player to attack him, He reads or knows How many enemy around the selected player. enemy script private Animator enemy anim private NavMeshAgent mAgent private GameObject player public GameObject dead point public int farPoint, dead point number, player number public float dist public bool enemt run, enemy atack false public bool near private enemyAround arounds public int enemy around player Use this for initialization void Start() mAgent GetComponent lt NavMeshAgent gt () enemy anim GetComponent lt Animator gt () player GameObject.FindGameObjectsWithTag("Player") dead point GameObject.FindGameObjectsWithTag("dead point") 3 points enemy dirction() void Update() count enemies around player enemy around player selected player for (int i 1 i lt player.Length i ) if (Vector3.Distance(transform.position, player i .transform.position) lt Vector3.Distance(transform.position, player player number .transform.position)) player number i dead point number dead point.Length dist Vector3.Distance(transform.position, player player number .transform.position) if (dist lt 5) near true else near false if (player ! null amp amp dist lt 5.1f) mAgent.destination player player number .transform.position if (dist lt 1.2f) enemy atack true else enemy atack false else if (dead point number gt 0) mAgent.destination dead point farPoint .transform.position else mAgent.destination player player number .transform.position if (mAgent.remainingDistance lt 1.5f) enemy atack true else enemy atack false enemt run true mAgent.speed 1.0f enemy anim.SetBool("run", enemt run) enemy anim.SetBool("attack", enemy atack) end update choose any deat point. void enemy dirction() if (dead point number gt 0) farPoint Random.Range(0, dead point.Length) mAgent.destination dead point farPoint .transform.position else


Animation imported from Blender into Unity via FBX doesn't play? I started building this model in Blender and gave it a simple animation that rotates the board about the axel. ...I exported it as FBX and imported it into Unity. I can see the animation is stored in the file when I import, but I can't find an animation file after I drop it in the scene, and there is no controller for the Animator controller it generated, either. I can watch the animation play in the FBX preview thumbnail but nowhere else. How can I get my animation working?


IConvertGameObjectToEntity interface on Unity ECS Was working on ECS and following the tutorials by Mike Geig in Unite Copenhagen on YouTube(https youtu.be BNMrevfB6Q0), and understood that unity automatically converts transforms, mesh renderers and things like that to ECS, the IConvertGameObjectToEntity interface converts entities that I want specifically for my game. But, while following his tutorial exactly as he did it, the entities that I have on my game do not have colliders in them, but is seen in his demo, how do I resolve that? EDIT I've Instantiated an entity, and it works fine, but then implementing the void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) from the IConvertGameObjectToEntity interface, I just have an entity, and only the mesh is visible, and an empty Component data that I've assigned on the Convert() method is available, I don't have a collider as it is on the prefab. Here is my Spawn Entity Code void Start () manager World.Active.EntityManager ObjectEntityPrefab GameObjectConversionUtility.ConvertGameObjectHierarchy(ObjectPrefab, World.Active) for (int i 0 i lt 100 i ) SpawnTheObject() private void SpawnTheObject() Entity object manager.Instantiate(ObjectEntityPrefab) manager.SetComponentData(object, new Translation Value transform.position ) manager.SetComponentData(object, new Rotation Value Quaternion.identity ) Here is The code attached to The Object public class AsteroidLifeECS MonoBehaviour, IConvertGameObjectToEntity public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) MoveSpeed moveSpeed new MoveSpeed Value MovementSpeed A component data that has only one float called Value dstManager.AddComponentData(entity, moveSpeed) RotateSpeed rotateSpeed new RotateSpeed Value RotationSpeed A component data that has only one float called Value dstManager.AddComponentData(entity, rotateSpeed) Health health new Health Value Health A component data that has only one float called Value dstManager.AddComponentData(entity, health)


Unity 2D Dealing damage when character is crushed between two solid objects Whats the best approach to dealing damage to a player when they get stuck between two solid objects? For instance, I'm trying to make moving platforms that the player can ordinarily touch. It's only when the player is caught in between the moving platform and the ceiling, for example, that damage is dealt or the player dies. So, what would be the best way to approach this? Thanks in advance!


Horizontal scrollview only I am using unity's scrollview. I want to disable the vertical scrollbar and i want the viewport to resize vertically depending on the content. Too confusing to explain with word so i have created the example picture below How do i achieve this properly ?


Unity can i make children of a moving platform also work as moving platforms? I have a moving platform that is a kinematic body, moving by a script, which is working as expected. I tried to parent it to another kinematic body, and make the child also function as a moving platform (the script only moves the parent), but it seems that the friction is ignored for the child object, and the carried object slips behind it and falls down when the child platform moves. The child platform is the same physical material as the parent. Is there any way i can make the child's friction work too, while having the script only move the parent? This is important, because in my real application the child moves and rotates inside a couple nested levels of transformations (basically the fork teeth of a fork truck). here is a simple abstraction of my question https youtu.be U854IcS96 Y Thanks!


Tab between input fields I am new to working with Unity3d, I need to navigate between several inputField, for this I have looked at the solution that is in tab between input fields, but always the FindSelectableOnUp() or FindSelectableOnDown() returns null, so my next is always null and always ends in next Selectable.allSelectables 0


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


Canvas not scaling to screen size So I have a very simple scene set up with just a camera, a game object called TestGrid with a grid script, and then a canvas. I have a TextMeshPro prefab that I instantiate to fill the 10 x 20 grid with cells. If I build and run the game, I see all the cells on my screen. However, in the editor play view, I can only see as many grid cell as would fit on startup. Making the game view smaller or larger will scale the ones already there, but everything that didn't fit initially is quot clipped quot out. The quot canvas quot is in the bottom left corner of the quot grid quot I'll share my code as well using System using System.Collections using System.Collections.Generic using TMPro using UnityEngine using UnityEngine.Diagnostics public class TestGrid MonoBehaviour private float cellSize 50.0f SerializeField private float width 0.0f SerializeField private float height 0.0f SerializeField private TextMeshProUGUI labelPrefab Start is called before the first frame update private void Start() if (labelPrefab null) Debug.LogError( quot You must set a label prefab. quot ) return GameObject canvas GameObject.Find( quot labelCanvas quot ) if (canvas null) Debug.Log( quot Unable to find canvas quot ) return This is just a 2D array of ints. Grid grid new Grid((int) width, (int) height) var canvasRect canvas.GetComponent lt RectTransform gt ().rect cellSize Math.Min((canvasRect.width width), (canvasRect.height height)) for (int x 0 x lt grid.Data.GetLength(0) x) for (int y 0 y lt grid.Data.GetLength(1) y) SpawnLabel(new Vector3(x, y, 0), canvas, grid.Data x, y .ToString()) TODO Replace this with LineRenderer Debug.DrawLine(GetWorldPosition(new Vector3(x, y)), GetWorldPosition(new Vector3(x, y 1)), Color.white, 100f) Debug.DrawLine(GetWorldPosition(new Vector3(x, y)), GetWorldPosition(new Vector3(x 1, y)), Color.white, 100f) Debug.DrawLine(GetWorldPosition(new Vector3(0f, height)), GetWorldPosition(new Vector3( width, height)), Color.white, 100f) Debug.DrawLine(GetWorldPosition(new Vector3( width, 0f)), GetWorldPosition(new Vector3( width, height)), Color.white, 100f) void Update() NYI private void SpawnLabel(Vector3 localPos, GameObject canvas, string text) float x localPos.x float y localPos.y var world GetWorldPosition(new Vector3(x, y, 0)) new Vector3( cellSize, cellSize) .5f var label Instantiate(labelPrefab, world, Quaternion.identity, canvas.transform) label.text text label.fontSize 100 label.autoSizeTextContainer true private Vector3 GetWorldPosition(Vector3 local) return local cellSize Additional images of environment I'm actually not too sure what is going on here, so here is everything I know I'm parenting my TextMeshPro prefab transform to the canvas transform, so that it scales properly My Canvas Scalar is set to reference resolution of 2560 x 1440, with a RPPU of 108 Canvas Scalar is also set to Scale With Screen Size Canvas Screen Space is set to Overlay I've also read the following links with no luck https stackoverflow.com questions 32347009 unity canvas does not fill screen https answers.unity.com questions 943190 ui panel not covering whole screen.html https answers.unity.com questions 1331722 ui scaling issues.html Expected Results No matter what the screen size is, I should see my full 10 x 20 grid of quot cells quot (in play view they're just 0's). Question If my canvas is supposed to scale with screen size, why is it that when I choose a cell size calculated from the canvas size, that it thinks the canvas is 2560 x 1440 when the screen size is clearly much smaller than that? Do I need to calculate with a different value? Must I dynamically resize everything I draw within the canvas? What's going on here?


In Unity, How to format Old RPCs into new "PunRPCs" In older unity versions you could simply used RPC. With newer verisons of Unity my code now doesn't work and it says that it needs to be transformed into "PunRPC" , Pun being "Photon Unity Networking." I am not sure how to reformat it to work with current unity versions. Can anyone shed light on this? My Code FXManager.cs 1 using UnityEngine 2 using System.Collections 3 4 public class FXManager MonoBehaviour 5 6 RPC 7 void SniperBulletFX( Vector3 startPos, Vector3 endPos ) 8 Debug.Log ("SniperBulletFX") 9 10 11 PlayerShooting.cs 1 using UnityEngine 2 using System.Collections 3 4 public class PlayerShooting MonoBehaviour 5 6 public float fireRate 0.5f 7 float cooldown 0 8 public float damage 25f 9 FXManager fxManager 10 11 void Start() 12 fxManager GameObject.FindObjectOfType lt FXManager gt () 13 14 if(fxManager null) 15 Debug.LogError("Couldn't find a FXManger.") 16 17 18 19 20 Update is called once per frame 21 void Update () 22 cooldown Time.deltaTime 23 24 if (Input.GetButton ("Fire1")) 25 Player wants to shoot...so. Shoot. 26 Fire () 27 28 29 30 void Fire() 31 32 if (cooldown gt 0) 33 return 34 35 36 Debug.Log ("Firing our gun") 37 38 Ray ray new Ray (Camera.main.transform.position, Camera.main.transform.forward) 39 Transform hitTransform 40 Vector3 hitPoint 41 42 hitTransform FindClosestHitObject (ray, out hitPoint) 43 44 if (hitTransform ! null) 45 Debug.Log ("We hit " hitTransform.name) 46 47 We could do a special effect at the hit location 48 DoRicochetEffectAt (hitPoint) 49 50 Health h hitTransform.GetComponent lt Health gt () 51 52 while (h null amp amp hitTransform.parent) 53 hitTransform hitTransform.parent 54 h hitTransform.GetComponent lt Health gt () 55 56 57 Once we reach here, hitTransform may not be the hitTransform we started with! 58 59 if (h ! null) 60 This next line is the equivalent of calling 61 h.takeDamage( damage) 62 Except more "networky" 63 PhotonView pv h.GetComponent lt PhotonView gt () 64 if (pv null) 65 Debug.LogError ("Freak out!") 66 else 67 h.GetComponent lt PhotonView gt ().RPC ("TakeDamage", PhotonTargets.AllBuffered, damage) 68 69 70 71 if (fxManager ! null) 72 fxManager.GetComponent lt PhotonView gt ().RPC ("SniperBulletFx", PhotonTargets.All, Camera.main.transform.position, hitPoint) 73 74 75 else 76 We didn't hit anything (except empty space), but let's do a visual FX anyway 77 if (fxManager ! null) 78 hitPoint Camera.main.transform.position (Camera.main.transform.forward 100f) 79 fxManager.GetComponent lt PhotonView gt ().RPC ("SniperBulletFx", PhotonTargets.All, Camera.main.transform.position, hitPoint) 80 81 82 83 cooldown fireRate 84 If anymore information is needed, please let me know, I would love to figure out how the new "PunRPC(Photon Unity Neworking)" works so I can use it in future projects. Edit This is the error I get "PhotonView with ID 2 has no method "SniperBulletFx" marked with the PunRPC or PunRPC(JS) property! Args Vector3, Vector3 UnityEngine.Debug LogError(Object)"


Unity 2d text not rendered properly in scene mode I am a beginner in Unity and trying to add a text box to my scene. I have done this before and was able to do it properly. Problem But recently I created a new project, added a text element to it, but text is not rendered properly in that text box. Anything I type in it is shown as boxes. Here is the screenshot for it. While text is shown properly in play mode. I also tried adding custom fonts in it but it didn't made any effect. What can be the cause for this.


Controlling Source Image From Script I am trying to make a health system where hearts display how much health you have. On each heart, I have an Image component. I am trying to control what source image the Image component uses from a script, but it is not letting me. I read the documentation for the Image component here and it has no sprite property. This is my code using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UIElements public class HeartScript MonoBehaviour public GameObject heart1 public GameObject heart2 public GameObject heart3 public Sprite halfHeart public Sprite fullHeart public Sprite emptyHeart private double playerHealth 3 Update is called once per frame void Update() if(playerHealth 2.5) heart1.GetComponent lt Image gt ().image fullHeart heart2.GetComponent lt Image gt ().image fullHeart heart3.GetComponent lt Image gt ().image halfHeart else if(playerHealth 2) heart1.GetComponent lt Image gt ().image fullHeart heart2.GetComponent lt Image gt ().image fullHeart heart3.GetComponent lt Image gt ().image emptyHeart else if(playerHealth 1.5) heart3.GetComponent lt Image gt ().image emptyHeart heart2.GetComponent lt Image gt ().image halfHeart heart1.GetComponent lt Image gt ().image fullHeart else if(playerHealth 1) heart3.GetComponent lt Image gt ().image emptyHeart heart2.GetComponent lt Image gt ().image emptyHeart heart1.GetComponent lt Image gt ().image fullHeart else if(playerHealth .5) heart3.GetComponent lt Image gt ().image emptyHeart heart2.GetComponent lt Image gt ().image emptyHeart heart1.GetComponent lt Image gt ().image halfHeart else if(playerHealth 0) heart3.GetComponent lt Image gt ().image emptyHeart heart2.GetComponent lt Image gt ().image emptyHeart heart1.GetComponent lt Image gt ().image emptyHeart public void RemoveHealth() playerHealth playerHealth 0.5 How do I change the sprite the heart uses from a script?


How do i play mp3 files in Unity Standalone? I am making a game in Unity in which the player can select music files in their hard drive to use them in game. I use the WWW class to load the sound files, but this only works for OGG, WAV and Tracker files. I use the following code WWW www new WWW ("file " soundPath) while(!www.isDone) yield return 0 GetComponent lt AudioSource gt ().clip www.GetAudioClip(false, true) I want to play audio files in mp3 format, which is the most widely used format for music in general, but when i try to play them, this gets printed to the debug log Streaming of 'mp3' is not supported on this platform. How can i easily achieve mp3 playback on desktop?


Unexpected result when generating world with 2 perlin noises I try to generate a world with a temperature and an humidity noise to generate biome based on the y values of the two. I take the y values and round them on a 33 base for the humidity and 25 for the temperature then add the two to get 12 possibilities of biome. to test it I first tried generating a chunk by assining the sum of humidity and temperature to their y location. I was expecting to get multiple platform at different height (12 possibilities of height) but I instead got this even if it doesn't look like it, there are random patterns within the bigger layers. i don't understand why I got that result (which looks pretty sick not gonna lie). here is my script const int seed 50 const int FREQUENCE 100 const int AMPLITUDE 100 const int size 100 int BIOME DATA 0, 33, 66, 25, 58, 91, 50, 83, 116, 75, 108, 141 int temp VERT new int 100 100 int hum VERT new int 100 100 public int biome VALUE new int 100 100 void Start() generate the y values for the humidity vertices for (int x (int)transform.position.x, i 0 x lt size (int)transform.position.x x ) for (int z (int)transform.position.z z lt size (int)transform.position.z z ) float y Mathf.PerlinNoise((float)x seed FREQUENCE, (float)z FREQUENCE) AMPLITUDE y Mathf.Floor(y 33) 33 hum VERT i (int)y i generate the y values for the temperature vertices for (int x (int)transform.position.x, i 0 x lt size (int)transform.position.x x ) for (int z (int)transform.position.z z lt size (int)transform.position.z z ) float y Mathf.PerlinNoise((float)x seed FREQUENCE, (float)z FREQUENCE) AMPLITUDE y Mathf.Floor(y 25) 25 temp VERT i (int)y i assigne une valeur repr sentant un biome pour chaque vertex for(int i 0 i lt biome VALUE.Length i ) biome VALUE i System.Array.IndexOf(BIOME DATA, (hum VERT i temp VERT i )) biome VALUE i new Vector2(temp VERT i ,hum VERT i ) GenerateChunk(biome VALUE) void GenerateChunk(int Y VERTICES) Mesh meshy MeshRenderer meshRenderer GetComponent lt MeshRenderer gt () meshRenderer.sharedMaterial new Material(Shader.Find( quot Standard quot )) MeshFilter meshFilter gameObject.GetComponent lt MeshFilter gt () Vector3 VERTICES new Vector3 Y VERTICES.Length List lt Vector2 gt UV new List lt Vector2 gt () List lt int gt TRIANGLES new List lt int gt () List lt Vector3 gt NORMALS new List lt Vector3 gt () meshy new Mesh() cr ation des Vecteur for (int i 0, x 0 x lt size x ) for (int z 0 z lt size z ) VERTICES i new Vector3(x transform.position.x, BIOME DATA Y VERTICES i , z transform.position.z) i cr ation des normales for (int i 0 i lt VERTICES.Length i ) NORMALS.Add( Vector3.forward) cr ation des triangles for (int x 0 x lt size 1 x ) for (int z 0 z lt size 1 z ) int i size x z TRIANGLES.Add(i) TRIANGLES.Add(i 1) TRIANGLES.Add(i size) TRIANGLES.Add(i size 1) TRIANGLES.Add(i size) TRIANGLES.Add(i 1) cr ation des uv for (int i 0 i lt VERTICES.Length i ) UV.Add(new Vector2(VERTICES i .x, VERTICES i .z)) assignation des valeurs meshy.vertices VERTICES meshy.triangles TRIANGLES.ToArray() meshy.uv UV.ToArray() meshy.normals NORMALS.ToArray() meshFilter.mesh meshy


"Instantiate" function in Unity spawns enemy but it doesn't show up So, I'm making a top down shooter (2D) and I already made an enemy prefab. It walks to the player and damages it, and reacts to bullets physically until it eventually dies. The prefab itself is ok, because I can spawn it manually and it works as intended. The problem comes when I want to automate the spawn process with a script. So I made a script to do so, here it is using System.Collections using System.Collections.Generic using UnityEngine public class GameController MonoBehaviour public GameObject enemy private float spawnPositionX private float spawnPositionY Vector2 spawnVector Start is called before the first frame update void Start() SpawnEnemy() void SpawnEnemy() spawnPositionX Random.Range( 630f, 630f) spawnPositionY Random.Range( 340f, 340f) spawnVector new Vector2(spawnPositionX, spawnPositionY) Instantiate(enemy, spawnVector, Quaternion.identity) As you can see, it's nothing too complex. I just refer to a game object (which I linked by the way) and then create some variables that will hold the x and y positions in which the enemy will spawn at random. Then when I call the function, those positions get set and stored into a bi dimensional vector to then be used with the instantiate function. This... works... kinda? When I run the game, the instance of the enemy gets made, I can see the clone in the hierarchy and I can select it and see that it's indeed moving, but it's like... not there? I can't actually see it on the screen and it's not invisible as I can't interact with it either. It's really weird and I have no idea what's going on. I tried to put the script on the camera, on the canvas, on a new empty object, nothing. I also checked that the prefab and the instance that's being spawned are indeed active. I thought about the coordinates being out of bounds, but when I check my player coordinates they are inbounds, so that can't be it either. I'm completely lost on this one, thoughts? Thanks.


Animate an element from ngui in Unity How can I animate an element from ngui in Unity? For example, how can I move it from the left to the scene when the button is clicked?


Unity Render only select objects but show previously rendered objects I am making an RTS game which is having performance issues. Is it possible to render the ground and units separately so I can only render the ground when the camera moves but keep the result displaying the units over the top? I'm not sure what details to include but The camera is fixed angle and orthographic The profiler says drawing takes up about 50 of CPU when units are moving. All the logic is done by a c script outside of monoDevelopment but called through a gameobject each frame, (takes 2 of cpu in tests). Units are put in place using the "transform.position" command each frame. Units and tiles are instantiated and destroyed when the Camera passes them. The game is using rigged .3ds models for the units. The units have disabled rigidbodies. Each tile in the game is a separate sprite. The performance drops with 100 low poly units without animation or 20 higher poly units with animation.


3d Maya object mesh problems when used in Unity Asking for help to solve a problem 3d Maya objects imported in Unity to make an ios app. Maya object change when imported on Unity mesh attributes disappears and mesh structure comes evident. Has anyone some suggestion to fix this problem?


how can i fix my code in order to get rid of the error that says that the object I want to instantiate is null? using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class replicate MonoBehaviour public void replicateCube(InputField T) int H int.Parse(T.text) for (int i 0 i lt H i ) GameObject prefab Resources.Load("Cube") as GameObject GameObject go Instantiate(prefab) as GameObject go.transform.position new Vector3(0, i 5, 0)


Generate static 2D Tilemap from array How do I generate a 2D tile map from an array like in this tutorial for XNA ? I basicly want to generate a static map based on my tile prefabs.


How to create a Unity Editor box grouping with a header and vertically stacked content inside? I am trying to do something like this with Unity Editor for my window but I am not sure how it is done. So it is basically a box ( a wrapper ) with a title at top. Beneath the title there are boxes or "cards" where you add text to it. Any help is appreciated!


How to make the whole game wait until some new feature at beginning is finished? In Unity I have been working on a driving game and its almost finished. I'm just trying to add some polishing touches. Ironically this part im stuck on now would not have been any issue at all in purely code based frameworks i used before (LibGDX Xna) because I could just make a boolean that's called ReadyToPlay or something and just put that around all the code i want to wait to start. I've made a secondary camera which rotates around the players car, it works fine but my problem is that the GUI is also already loading AND the race start countdown occurs still whilst the camera is still spinning. I'm not sure in Unity how to go about stopping that to allow the time for the camera to spin. One idea I have to fix this (i'm checking first because this doesnt seem right to me) is to use the yield routine in the GUI loading script and tell it exactly how many seconds the camera is going to spin for. I'd rather have just have the camera detected when its done a full spin and then make a boolean true, or trigger another method to start the game properly. I promise I have done some research trying to find ways but the only thing i can find except yield, is Monobehaviour.Invoke but the invoke method still requires me to specify the time. The whole strategy for yield or invoke feels wrong to me. I guess my main problem is that the code is spread over a few scripts, instead of being funneled thru a main.cs and then gameManager.cs etc etc so theres no way (that I know) to break the chain higher up. I'd have to add bools to each script to say isLuxuryCameraAlive and that still seems wrong to me as I might have 5 10 scripts and have to also section of bits of code in each script. How would you experienced programmers attack this issue?? Thank you!!


Issues with 3dsmax and Unity3d scale I changed the units in Blender so they are identical to Unity 3d. If I make a 1m 3 box in Blender, it will import into unity as exactly the same size as the standard cube. With 3ds max, I changed the unit setup to metric and made sure it was centimeters in the system unit setup tab. However, when I import an obj file made in Blender and used in Unity, it is absolutely tiny. I have to convert the model to meters on import and then, when exporting, I have to set the model scale to .01 otherwise it is enormous in the unity scene. I've tried changing the max units to meters and nothing changed. How do you change the max unit grid setup so one grid unit is 1m 2 and exactly equivalent to unity's grid?


Unity Blurry on new Windows 4k Computer I just got a Razer 14 Inch 4k with a GTX 1060 and am having some blurry rendering in unity. Also the cursor is tiny... Here is a screen shot As you can see, the rendering is really blurry. I came from a mac and did not expect unity to look worse after switching to a computer with a great screen res and graphics card... Please help! EDIT I am still getting jagged shadows but now I seem to be able to fix it with changing shadow distance in Quality Project Settings But then the shadow disappears really quick if i have low shadow distance...


How to make Scriptable Objects derive from other Gameobejcts? I encountered a problem where I want to make a Scriptable Object that derives from another class, but C does not support multiple inheritance. Further, I do not think it would not make sense to make interfaces for this example. There is a lot of duplicate code within methods that only an abstract class could contain implementations of. Basically, I want an abstract class that models "anything that can take a turn." I call it a TurnTakeable. But I also want the TurnTakeable to be split into friend and foe derived types, as the two are slightly different. Yet they mostly have the same behavior. Is there a workaround, or do I have to make an interface? (


Whats the best way to make my Unity game moddable? Basically the title. I'm building a game with several NPCs and complex systems, and I want it to be nice and modular for modders right from the beginning. So far, I have looked into Asset Bundles, I don't completely understand these, probably will have to write some custom loading code? I don't know how if this will let the modders write code. Lua Based Modding, I don't particularly like Lua, but I will fall back to it if I absolutely have to (The Unity Lua Plugin makes this a seemingly very fast way.) Exposed C (original idea from this Question). But again, as stated in the question raw c has a lot of disadvantages, not to mention the security risks and compatibility issues. Minecraft Style? Completely custom? Basically a lot of events and registries? I'm not sure about this option. To give you an example, there are several Tribes in the game. Ideally, if a modder wanted to make a new tribe they would need to extend from some Tribe base class and then register add their custom tribe to my AvailableTribes list. Not to mention the models, animations, and sounds for the Tribe NPCs and such. Any help is appreciated!


Unity detecting edge of mesh or end of mesh I'm trying to create procedurally generated tiles and I've reached a point where I need to figure out the boundaries of the mesh or the outer vertices of the mesh. RaycastHit hit if (Physics.Raycast(bound i .v2, Vector3.forward, out hit)) if (hit.distance gt 2) I've tried raycasting all the vertices, but still can't get the vertices of the edge. The mesh does have a collider. any help on how i would go about this is appreciated, Thanks.


Weird windowed resolution can't seem to change without changing the name My game is windowed, and when I set the resolution in the build settings (960x540 16 9 Windows standalone), and build it, it works as intended, but from then on, I can no longer change the resolution (can change it in the editor, and it also saves, but when I build it, it is still the original res (960x540))unless I change the Product Name as well. When I change the product name, I can change the resolution, build it, and it will change, but then it is stuck as well. When I change back to the first name, the resolution automatically change it the resolution for the first name (960x540) (it doesn't show up in the editor, only when you build it.) So basically Name1 960x540 Name2 1280x720 Name3 1024x576 etc So you can change the resolution every time you change the name and build it, and that name is stuck with that resolution (no matter what you change it to in the editor later). I am fairly new with unity, so am I missing something very basic here? Thanks for any help!


Why do these textures tile rather than just overlap? It might help to provide all the details, so here is the YouTube tutorial which sparked my question. There's a prefab of the background tile called "Tile Background." This prefab has the default settings, except that Pixels Per Unit is set to 512, and that it has a script attached to it called BackgroundTile which hasn't even been opened. It's just there for the other script to reference. An empty object was created called Board, which has Tile Background as its tile prefab. It also has a script, Board.cs, the contents of which are here using System.Collections using System.Collections.Generic using UnityEngine public class Board MonoBehaviour public int width public int height public GameObject tilePrefab private Backgroundtile , allTiles Start is called before the first frame update void Start() allTiles new Backgroundtile width,height Setup() private void Setup() for(int i 0 i lt width i ) for(int j 0 j lt height j ) Vector2 tempPosition new Vector2(i, j) Instantiate(tilePrefab, tempPosition, Quaternion.identity) Width is set to 4. Height is set to 7. Other than that, the camera position is X 1.5,Y 3 and the aspect ratio is 9 16. My question is this why, when this is run, does Vector2(i,j) get interpreted as tiling the sprites, rather than placing the sources of the sprites in a 4x7 pixel grid, where they overlap almost entirely? There's no place where their positions get multiplied by the size of the tiles, right? Halving the pixels per unit doesn't even just halve the height of the board it stays a constant size and looks really weird, despite the board not having set dimension attributes. What's going on here?


Unity text component not updating text properly It was worked fine previously, but after some point, it's not working. This is the code. It's not a pseudo code, actual code in game public Text healthText void Start() healthText GameObject.Find("UI InGameUI CharacterStatus HealthText").GetComponent lt Text gt () void Update() if(healthText) print(health) healthText.text Time.deltaTime.ToString() healthText.text "HP " health.ToString() healthText.text "HP " health variable "health" is float value. I just want to print it to the screen, but it's always prints "Health 100" even it changes. So I printed the value to the console, but it prints well in the console and only text components was not printed properly. So I printed Time.deltaTime instead of the health and it works! Seriously, what the hell is happening? Is this a bug? If health variable wasn't changed, it should be also printed 100 in the console, but it's not! Try this to another text component, still not working.


Button onClick in a menu prefab doesn't work I don't seem to be able to make a reference to a Button inside a menu prefab. My menu prefab consists of a panel and the panel has 4 buttons. I added public GameObject prefabMenu in my code and drag and dropped the prefab in the Unity Editor to it. When my scene is starting (Start() method) I instantiate this prefab into a GameObject like this panelMenu Instantiate(prefabMenu, canvas.transform) after that I try to refer one of the buttons with this line and set an onClick listener btnResume panelMenu.transform.Find( quot BtnResume quot ).GetComponent lt Button gt () btnResume.onClick.AddListener(() gt Log.I( quot Working quot )) The log method however doesn't not get called when I click on the button (I checked and the btnResume is not null). I appreciate any help on this. Thank you.


Can a material be created from a gameobject in Unity? I am trying to manually create snowflakes in unity, after I created a snowflake in the unity scene, is it possible to create a material out of it?


Mesh vs LineRenderer Performance I've created a script, which is drawing a line along a bezier curve, so that I can animate whatever I want with lines, mostly for UI purposes. For the moment I'm using a line renderer, which works, but the performance is not that great in my opinion. So I was wondering if there are actually some better methods to draw lines, like simply creating a mesh along the path I've got.


Problem modifying GameObject in list of GameObjects Unity So I've been working on a little project that involves Valve's quot Portal quot style portals, the type where you can seamlessly see what's on the other side and walk through. I've run into a problem when it comes to teleporting an object to it's new location upon hitting the portal. I have a List lt GameObject gt that contains all the objects that are in close enough range to feasibly travel through the portal, but when I try to modify the transform.position of one of these GameObjects, nothing happens, no error messages. So I've been going through my script line by line and writing little dummy functions to test different parts of it to see where the problem lies, and everything seems to work up until I index the list and try to modify a value, nothing happens. So was thinking that perhaps the List doesn't actually contain a reference to the GameObject in the scene, but simply a copy of the GameObject's data at the time it was passed into the list. So I checked this by making the list public so that I see it in the inspector, and when I click on an item in the list it highlights that same GameObject in the hierarchy, which suggests it is actually a reference. See bellow... I am at a loss as to what's happening here and would really appreciate if anyone could offer a suggestion, Here is the dummy function where I try to arbitrarily modify the GameObject data from the List... if (Input.GetKeyDown( quot k quot )) for (int i 0 i lt trackedTravelersObjects.Count i ) trackedTravelersObjects i .transform.position new Vector3(0, 30, 0) Debug.Log( quot K quot ) You'll notice a Debug.Log( quot k quot ), this is just to check that the code is actually being called, which it is. Thanks.


Best way to constrain character to a path? I'm in the process of developing a level based runner for mobile phones, and I've hit a wall when deciding which method to use to get the character to move through the level. Basically I need my character to travel a constrained path across the level as I manipulate the character by speeding up down and jumping to avoid obstacles. I couldn't just place a straight path and use Curved World look as I needed a realistic feel to character motion. I also have up down slopes that have to affect the character's speed. I'm not use whether using iTween is the best for this as it makes it difficult to manipulate character speed and especially the jumping 'arc'. I've tried using MoveTo() but problems arose when trying to change character parameters... PutOnPath() made sense in theory but I found it harder to implement. Is there any easier way to go about this? I'm almost completely new to Unity, so an easier implementation is what I'm going for, for now. Thanks in advance!


How to make a character that moves like a slinky? I have a school assignment to make a 2D platformer game, with a character that moves like a slinky (Animated example from the assignment linked above) At first, the character needs to grow in height over time When the player presses a button, the character starts to bend toward the next platform Its height when you press the button determines whether it will hit the next platform After that it must shrink to its initial size, and it goes over again. How can I approach this?


Basic Character Controller Not Working Properly in Unity I've been trying to setup a simple mouse camera which I had all the code working fine, except when I move with wasd and move my mouse to turn the camera simultaneously the input freezes up and gets stuck repeatedly inputting whatever the last input was. I've tested the simplest way to replicate the issue and it doesn't even need a camera for the issue to come up. If anyone would like to test and try to replicate the issue these are the steps its super fast and simple. create new project(basic PC 3D project) create a plane, and a cube Add a basic character controller script to the cube (this time I used the official Unity code to be sure it's not an issue with code) and that's it, that's actually all that was needed to create the issue for me. And to explain to anyone who may want to test it the issue is as follows when you use wasd keys normally, everything works fine and the controls are responsive. However if you hold down one of the wasd keys while also moving your mouse (just wiggling the mouse should suffice) suddenly things will lock up and the cube will keep moving for a bit even after you let go of the respective wasd keys. In general if you hold a direction while simultaneously wiggling the mouse for a longer period of time, it will extend the amount of time the cube keeps moving after you let go of the direction. And this was done on Unity version 2020.1.16f1 If anyone has any idea what the issue may be its really appreciated.


How to display full website in Unity WebGL? I want to display the complete website within the WebGL in Unity. I have tried Awesomium plugin but it doesn't work in WebGL. Please tell me is there any way to display the webpage. Thank you.


How would I properly flip a character when they reach the edge of a ground object in Unity 2D? The idea here is that the raycast shoots downwards from an empty game object and when it detects that there is no ground below it the character should bounce back and walk the other way. When I get to the edge of my platform the character just gets stuck in place and keeps rotating on the Y axis. public class npcAI MonoBehaviour public float speed public float distance private bool movingRight true public Transform groundDetection raycast goes downward from this point private Vector2 movementDirection void Start() Initialise direction movementDirection Vector2.right void Update() transform.Translate(movementDirection speed Time.deltaTime) RaycastHit2D groundInfo Physics2D.Raycast(groundDetection.position, Vector2.down, distance) if (groundInfo.collider false) if (movingRight) movingRight false movementDirection Vector2.left transform.localScale new Vector3(0.30F, 0, 0) else movingRight true movementDirection Vector2.right transform.localScale new Vector3(0.30F, 0, 0) The code above was edited to reflect the answer below. If you find yourself attempting to do the same thing and need to flip your sprite when you reach the edge change 0.30F to whatever double the X value of your sprite is in order to flip it. My sprites scale was (0.15, 0.15, 0) so I used 0.30F to flip my sprite. Be mindful of when you should use and when you should use .


unity problem in limiting rotation of object? I am trying to make a game with unity. In this game, player uses mouse to rotate a container or box around x and z (rotate to left and right and also toward the camera and opposite). I used below code to control movement and limit it. float zRot transform.eulerAngles.z float xRot transform.eulerAngles.x float yRot transform.eulerAngles.y Debug.Log ( "xDir " xRot.ToString() " yDir " yRot.ToString() " zDir " zRot.ToString() ) if ((xRot gt 330 xRot lt 30) amp amp (zRot gt 330 zRot lt 30)) transform.Rotate (Input.GetAxis ("Mouse Y"), 0, Input.GetAxis ("Mouse X")) else Debug.Log(xRot.ToString() " " zRot.ToString ()) transform.Rotate ( transform.rotation.x , transform.rotation.y, transform.rotation.z ) The contatiner rotate 60 degrees in x and z and when it gets to the limits it stops, which is what I want. However when I rotate in both direction to the near the limits (330 or 30), the contatiner becomes out of control and it rotates freely and constantly. It's like the contatiner has passed the limits. The questions are Did I used a good approach to limit the rotation and how to stop the object completely when it get to the limit of rotation? When and why the object becomes out of control exactly?


Unity3D playing sound when Player collides with an object with a specific tag I using Unity 2019.2.14f1 to create a simple 3D game. In that game, I want to play a sound anytime my Player collides with a gameObject with a specific tag. The MainCamera has an Audio Listener and I am using Cinemachine Free Look, that is following my avatar, inside the ThridPersonController (I am using the one that comes on Standard Assets but I have hidden Ethan and added my own character avatar). The gameObject with the tag that I want to destroy have an Audio Source In order to make the sound playing on the collision, I started by creating an empty gameObject to serve as the AudioManager, and added a new component (C script) to it using UnityEngine.Audio using System using UnityEngine public class AudioManager MonoBehaviour public Sound sounds Start is called before the first frame update void Awake() foreach (Sound s in sounds) s.source gameObject.AddComponent lt AudioSource gt () s.source.clip s.clip s.source.volume s.volume s.source.pitch s.pitch Update is called once per frame public void Play (string name) Sound s Array.Find(sounds, sound gt sound.name name) s.source.Play() And created the script Sound.cs using UnityEngine.Audio using UnityEngine System.Serializable public class Sound public string name public AudioClip clip Range(0f, 1f) public float volume Range(.1f, 3f) public float pitch HideInInspector public AudioSource source After that, in the Unity UI, I went to the Inspector in the gameObject AudioManager, and added a new element in the script that I named CatchingPresent. On the Third Person Character script, in order to destroy a gameObject (with a specific tag) when colliding with it, I have added the following void OnCollisionEnter(Collision other) if (other.gameObject.CompareTag("Present")) Destroy(other.gameObject) count count 1 SetCountText() It is working properly as that specific object is disappearing on collision. Now, in order to play the sound "CatchingPresent" anytime the Player collides with the object with the tag, in this case, Present, I have tried adding the following to the if in the OnCollisionEnter FindObjectOfType lt AudioManager gt ().Play("CatchingPresent") But I get the error The type or namespace name 'AudioManager' could not be found (are you missing a using directive or an assembly reference?) AudioManager.instance.Play("CatchingPresent") But I get the error The name 'AudioManager' does not exist in the current context As all the compiler errors need to be fixed before entering the Playmode, any guidance on how to make the sound playing after a collision between the player and the gameObject with the tag Present is appreciated.


How to make it two seconds for Time.time? var targetscript Diamond var red Color var orange Color function Start () gameObject.camera.backgroundColor red function Update () if (targetscript.score gt 4) gameObject.camera.backgroundColor Color.Lerp(red, orange, Time.time) So right now, if the score is larger than 4 then it would change the camera background color to orange with lerp. But its too quick. I read on the internet that Time.time is 1 second. What is the alternative way but for 2 or 3 seconds? I tried this http answers.unity3d.com questions 328891 controlling duration of colorlerp in seconds.html I tried the code for the voted answer but it didn't work. It still lerps through quickly. Does anyone have any ideas? Thanks


Where is Advertisement.Banner class in Unity Advertisement v2.3.1 package? I'm implementing Unity Ads in my game, now i'm using Advertisement package v2.3.1 from package manager. I set up rewarded and video ad, but can't do anything with Banner ads. I set up id in a project dashboard and just call Show function with banner placement id. private IEnumerator ShowBannerWhenReady() while (!Advertisement.IsReady(bannerPlacementId)) yield return delay Debug.Log("Showing Banner") ShowOptions options new ShowOptions resultCallback HandleBannerShowResult Advertisement.Show(bannerPlacementId, options) As for unity documentation Advertisement namespace have Banner class, but i don't see it in my project. So on android build i don't see any banner or smth, other ads work as expected.


Export "Lite" and "Full" versions with different package names for Google Play Console On the Google Play Console, you can't have two games with the same package name. Is there a way to have two of the same game with different package names, exported from the same Unity project? For example, a quot lite version quot with ads and a quot full version quot without ads.


How can I destroy the trigger forever? I have a trigger that plays an animation but when i switch scene and i come back to the original scene, the animation plays again. I want to remember actioned triggers in order to play triggers once per scene. How can I do that? The GlobalScript public class GlobalScript MonoBehaviour public static GlobalScript Instance public Animator ani void Awake () if (Instance null) DontDestroyOnLoad(gameObject) Instance this else if (Instance ! this) Destroy (gameObject) The current script (Running every time i load the scene) public Animator ani public AudioClip sound public GameObject text private int seconds 2 var delay 2.0 This implies a delay of 2 seconds. public void SavePlayer() GlobalScript.Instance.ani ani Use this for initialization void Start () ani GlobalScript.Instance.ani ani.enabled false text.SetActive (false) void OnTriggerEnter(Collider other) AudioSource.PlayClipAtPoint (sound, transform.position) ani.enabled true text.SetActive (true) Destroy (gameObject) Destroy (text,3) text.SetActive (true) StartCoroutine(Die()) And function itself IEnumerator Die() play your sound text.SetActive(true) yield return new WaitForSeconds(2) waits 3 seconds Destroy(gameObject) this will work after 3 seconds.


How to use a whole new set of assets (reskinning) I need to be able to load my game with a different set of assets, basically reskinning it. I knew beforehand that I would need a way to do that in the future so right now i'm accessing my assets via a ScriptableObject that I call an "Accessor". Basically the accessor only hold references to the assets and when I want to get, for example, the sprite for my cards I make a call that looks like that Sprite cardSprite Accessors.Instance.GetCardFrame() Solution seem simple, I add a layer above the accessors that allow it to choose between differents sets of references. The problem is that right now I only use the accessors for dynamically generated gameobject ( When I instantiate a card for exemple ). How could I do that with, let's say, UI in the editor ? It will be nearly impossible to work on the UI if I can't see it due to the sprite not being loaded in editor mode.


Will Unity skills be transferable? I'm currently learning Unity and working my way through a video game maths primer text book. My goal is to create a racing game for WebGL (using Three.js and maybe Physic.js). I'm well aware that the Unity program shields you from a lot of what's going on and a lot of the grunt work attached to developing even a simple video game, but if I power through a bunch of Unity tutorials, will a lot of the skills I learn translate over to other frameworks engines? I'm pretty proficient at level design with WebGL, and I'm a good 3D modeller. My weaknesses are definitely AI and Physics. While I am rapidly shoring up my math, and while Physics is undeniably interesting there's only so many hours in the day and there's a wealth of engines out there to take care of this sort of thing. AI does appeal to me a lot more, and is a lot more necessary. AI changes drastically from game to game, is tweaked heavily during development, and the physics is a lot more constant. Will leaning AI concepts in Unity allow me to transfer this knowledge pretty much anywhere? Or will I just be paddling up Unity creek with these skills?


Unintended window opening when pressing Unity's "Submit" button I've been working on a top down 2D game for a while now, and yesterday I found a strange bug that I just can't explain to myself whatsoever. I have a loot window for looting enemies, as well as a character panel to equip gear see stats. I realized that after I open and close a loot window, if I press the space button (used for attacking, not for opening any windows) while holding A LeftArrow or W UpArrow it opens the character panel. Once this happens, I can press space to open close the character panel. Went to the character panels OpenClose() function (all it does is set the canvas group alpha to 0 and block raycast to false and vice versa) which is being called unintentionally, put a debug.log inside to verify if it really was being called, and yes, it is. I look up all references to see where I used it, but I only use it in a single place in the project that is behind an if statement looking for they keycode C (NOT space). I added a debug.log for the Input.inputstring to see if somehow a magic C button press is ending up in that function, but no. If I press C to open the window, the debug log pops up, if I press space, the inputstring appears to be empty, so the if statement to get to the only place in the code referencing that function cannot be met. Removed the space button from my Player entirely, the behaviour still persists. Added another debug.log with stackTrace.GetFrame(1).GetMethod().Name to show who is actually running this function, but it turns out that if I run it and press C, it says it's being opened by the update function in the UIManager (as expected). If I run it the strange, unintended way, it says it is being run by the EventSystems Invoke function. Coupled with the fact that the behaviour persists despite the space button being removed from the player, I realized that it's Unity's built in "Submit" button being pressed. Strange behaviour It appears to call the submit function on the OpenClose button for the character panel, but only under the circumstance that I closed a loot window and haven't clicked the mouse anywhere yet afterwards. If I deactivate the button that holds the character panels OpenClose function, the behaviour stops. The button shouldn't be pressed though, because it is on a canvas group with alpha 0 block raycast false, just like all the other buttons with the identical function that work fine. The loot window has no idea about the character panel either, and all the windows are properly wired to their own OpenClose function. Upon further inspection, the window only starts showing up if, after closing a loot window, i press A LeftArrow Space or W UpArrow Space. This is getting more and more confusing for me. So basically my issue is how do I figure out why this function is being called? It feels as if closing the loot window somehow "caches" the OpenClose button for the character panel onto the submit button, but only until I click elsewhere on the screen. Did you guys have any experience with a similar situation? Could you share some pointers on how to debug this? What is the "submit" button usually used for, and what would make it only work in combination with the left top directional buttons? I've spent about 4 hours on this now and don't know how to get any further.


How can I increase the speed and frequency of a spawn? I'm using the official Unity tutorial for the Space Shooter game, and I'm at the part where the ability to spawn a set amount of hazards in a wave at a certain delay is introduced. I want to make it so that at the end of a certain level, the speed of the hazards, and the amount of hazards both increase. I'm pretty sure that can be handled in the game controller, but I don't know the commands I would be needing to use to make that happen. This is the existing code public class GameController MonoBehaviour public GameObject hazard public Vector3 spawnValues public int hazardCount public float spawnWait public float startWait public float waveWait void Start () StartCoroutine (SpawnWaves()) IEnumerator SpawnWaves () yield return new WaitForSeconds (startWait) while (true) for (int i 0 i lt hazardCount i ) Vector3 spawnPosition new Vector3 (Random.Range ( spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z) Quaternion spawnRotation Quaternion.identity Instantiate (hazard, spawnPosition, spawnRotation) yield return new WaitForSeconds (spawnWait) yield return new WaitForSeconds(waveWait) What commands would I need to use to increase the amount of hazards that spawn at the end of each round? And likewise, how could I change the Hazard's script so that it will increase in speed by a certain factor at the end of each round? Is there a way I can reference the hazard's script in this script, by any chance?


How can I make alternate fragments drop (or make them black) based on a checkerboard texture? How can I make alternate fragments drop(or make them black) based on a checkerboard texture in a Unity fragment shader? I am using forward path rendering in my shader passes for lighting and shadows for every object in the scene. Now,I need a shader (or something) that drops alternate pixels from the overall screen space after everything is rendered. How can I achieve this effect?


gazing and lip syncing in Unity 5.2 Is it possible to achieve gazing or lip syncing in Unity 5.2 at all, similar to Locomotion done through MecAnim?


Unity how to have a ghost 3d game object I want to have a 3d game object (player) who converts to ghost. That means that the user must not collide with other players, but must not pass walls, trees, and must take care about terrain height levels (I mean, I can't put it as kinematic and remove the collider because the Vector3.MoveTowards which moves the player will ignore the height dimension and will pass the mountains, etc) My was thinking about tagging the players and in some way try to skip the collider between them. Any idea? Thanks


Write Data From List To CSV File I am trying to write to a CSV file the values that I put in lists from a key press in the keyboard. It does work somehow but in my csv file I get the values 2 times. Also, when I put values to only one of the lists, I don't get any data to CSV file. How can I save the values from the lists to my csv file but to be independent from each other? This is my code using UnityEngine using System.Collections using System.Collections.Generic using System.Text using System.IO using System public class record MonoBehaviour public List lt string gt inventory new List lt string gt () public List lt string gt OnlyX new List lt string gt () void Update() if (Input.GetKeyDown(KeyCode.F)) inventory.Add("F") if (Input.GetKeyDown(KeyCode.J)) inventory.Add("J") if (Input.GetKeyDown(KeyCode.X)) OnlyX.Add("X") string filePath getPath() StreamWriter writer new StreamWriter(filePath) writer.WriteLine("Inventory,OnlyX") for (int i 0 i lt inventory.Count i) for (int j 0 j lt OnlyX.Count j) writer.WriteLine(inventory i "," OnlyX j ) writer.Flush() writer.Close() private string getPath() if UNITY EDITOR return Application.dataPath " Data " "Saved Inventory.csv" elif UNITY ANDROID return Application.persistentDataPath "Saved Inventory.csv" elif UNITY IPHONE return Application.persistentDataPath " " "Saved Inventory.csv" else return Application.dataPath " " "Saved Inventory.csv" endif


How do I make Ground Check stop rotating with the character when it rotate? How do I make my character routice without Ground Check rotating with it, but still follow my character? Code using UnityEngine using System.Collections public class Player MonoBehaviour public float maxspeed 10f bool facingRight true Animator anim bool grounded false public Transform groundCheck float groundRadius 0.2f public LayerMask whatIsGround public Vector2 jumpDirection new Vector2(1f, 1f) public float jumpFocre 500f bool doubleJump false void Start () anim GetComponent lt Animator gt () void FixedUpdate () grounded Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround) anim.SetBool ("Ground", grounded) if (grounded) doubleJump false float move Input.GetAxis ("Horizontal") anim.SetFloat ("Speed", Mathf.Abs (move)) GetComponent lt Rigidbody2D gt ().velocity new Vector2(move maxspeed, GetComponent lt Rigidbody2D gt ().velocity.y) void Update() if((!doubleJump) amp amp Input.GetKeyDown ("up")) anim.SetBool("Ground", false) float move Input.GetAxis ("Horizontal") jumpDirection.x move GetComponent lt Rigidbody2D gt ().AddForce(jumpDirection.normalized jumpFocre) if(!doubleJump amp amp !grounded) doubleJump true void Flip() facingRight !facingRight Vector3 theScale transform.localScale theScale.x 1 transform.localScale theScale


How can I update a sprite sheet without affecting the sprites already being used? Every time I overwrite my sprite sheet with additional or updated sprites, I have to reattach the textures to all of my Animations and Sprite Renderers. How can I update a sprite sheet without affecting the sprites on that sheet which are already being used? During the development of even a small game, hundreds of textures are being used. And new textures are being added and updated every day. This results in many hours spent reattaching textures which could otherwise be used being productive. What strategy can I use to prevent this? This is an example of what I mean I have a sprite sheet with 40 textures. All of its sprites are attached to their relative GameObjects. I decide I want to change the color of one of my sprites' hat. I go into gimp and load the sprite sheet. I change the color of the hat. I overwrite the old sprite sheet. Back in Unity, all of the textures are no longer attached to their respective GameObjects. I go in and splice the sprite sheet again and manually reattach all of the textures. Then I decide I like the old hat better. I go back into gimp, change the sprite sheet, and am then forced to reattach all of the textures...again. There has to be a better way! (Also would like to be capable off adding new sprites in addition to editing old ones.)


Continous Movement and Gravity Switch With 1 button I have a sphere with a rigidbody on it, and it moves to the right continously as I need it, but as it moves I want the space bar to be able to switch the gravity (so it either rides on the ceiling or on the floor), as it moves along to the right. Please help, have been googling consistently for the past 3 hours. Here is the code I have so far public class movement MonoBehaviour public float movementSpeed 10 private bool haspressed void Start() void FixedUpdate() transform.Translate(Vector3.down movementSpeed Time.deltaTime) if (Input.GetKeyDown ("space") amp amp haspressed true) transform.Translate (Vector3.right movementSpeed Time.deltaTime) haspressed false else if (Input.GetKeyDown ("space") amp amp haspressed false) transform.Translate (Vector3.right movementSpeed Time.deltaTime) haspressed true Thank you sooo much!


Unity 2D Destroy object with dynamic collider after exiting object with static collider I'm using the Unity5 game engine and am programming a 2D shooter in bird's eye view. I have a static Box Collider 2D which covers the entire game area. It has "Is Trigger" checked and contains a very simple script which should destroy every object that exits it. using UnityEngine using System.Collections public class DestroyByBoundary MonoBehaviour void OnTriggerExit(Collider other) Debug.Log ("OnTriggerExit") Destroy (other.gameObject) The player character shoots bullets which have a dynamic Circle Collider 2D. However, the bullets are never destroyed when they leave the game area and just fly on indefinitely. The debug statement never gets executed either, of course. I have tried the same thing with OnTriggerEnter, which yields the same result. If any more information should be needed, I'll be happy to provide it.


remove sudden upward downward jerk from camera I have a scene with low poly assets amp NavMesh enabled for character navigation. When player climbs the bridge there's a sudden upward jerk in camera. Also, when the player comes down, there's a downward jerk in Camera. I want the camera movement to be smooth so it appears as if the y axis of the camera is floating like a drone. Below is my script that I'm using public class FollowCamera MonoBehaviour float MIN X 26.72f float MAX X 34f float MIN Z 6.22f float MAX Z 47.6f float MAX Y 15f float MIN Y 0.6f public float startYPositionOfCamera The target we are following public Transform target The distance in the x z plane to the target public float distance 10.0f the height we want the camera to be above the target public float height 5.0f How much we public float heightDamping 2f public float rotationDamping 3.0f AddComponentMenu("Camera Control Smooth Follow") void Start() startYPositionOfCamera transform.position.y void LateUpdate() Early out if we don't have a target if (!target) return Calculate the current rotation angles float wantedRotationAngle target.eulerAngles.y float wantedHeight target.position.y height float currentRotationAngle transform.eulerAngles.y float currentHeight transform.position.y Damp the rotation around the y axis currentRotationAngle Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping Time.deltaTime) Damp the height currentHeight Mathf.Lerp(currentHeight, wantedHeight, heightDamping Time.deltaTime) Convert the angle into a rotation var currentRotation Quaternion.Euler(0, currentRotationAngle, 0) Set the position of the camera on the x z plane to distance meters behind the target transform.position target.position transform.position currentRotation Vector3.forward distance Set the height of the camera transform.position new Vector3(transform.position.x, currentHeight, transform.position.z) Always look at the target transform.LookAt(target) Clamp the position of camera so it doesn't go back of mountains transform.position new Vector3( Mathf.Clamp(transform.position.x, MIN X, MAX X), Mathf.Clamp(transform.position.y, MIN Y, MAX Y), Mathf.Clamp(transform.position.z, MIN Z, MAX Z) )


Unity loop through list and match PlayerPrefs I have a list of stickers and when a player completes a level they get awarded a sticker which I save into PlayerPrefs. I want to be able to return the list of sprites saved into PlayerPrefs on the awards scene. I have not been to loop and match the PlayerPrefs. I am not sure how to go about this. public class StickerManager MonoBehaviour public List lt Sprite gt stickers new List lt Sprite gt () public List lt Sprite gt unlockedStickers new List lt Sprite gt () public void UnlockSticker (int id) PlayerPrefs.SetInt("sticker", id) public List lt Sprite gt LoadUnlockedSticker () int i 0 foreach (Sprite spri in stickers) if (PlayerPrefs.GetInt("sticker", i) stickers i ) unlockedStickers.Add(stickers i ) i return unlockedStickers


Get width of a 2D GameObject in Unity I'm trying to get the width and height of a 2D GameObject. My GameObject is simply a prefab created using sprite. I have tried solutions from other posts but they don't work for me Vector2 size myGameObject.GetComponent lt CircleCollider2D gt ().bounds.size float width size.x float height size.y and Vector2 size myGameObject.GetComponent lt Collider2D gt ().bounds.size float width size.x float height size.y My prefab has a Circle Collider 2D but x and y always returns 0 I'm using Unity 5.5.0f3, not sure if previous solutions apply to this version.


Load nextLevel with a button click Can anyone help me someone with this code? I'd like to go to the next level by clicking a button example my level name is L1,L2,L3,L4,L5,L6,L7 and when I finish level L1, I want to go to level L2 with the click of a button, and from L5 go to L6 like this. public class GameLevels MonoBehaviour public Button Play private int idLevel Use this for initialization void Start () idLevel PlayerPrefs.GetInt("idLevel") Play.interactable false public void SelectLevel(int i) idLevel i PlayerPrefs.SetInt ("idLevel", idLevel) Play.interactable true public void LoadLevel(string Levels) SceneManager.LoadScene (Levels) public void Replay() SceneManager.LoadScene ("L" idLevel.ToString ()) public void loadNextLevel()


Unity 5 Cloth Constraints I'm trying out the new Version of Unity 3D (5.0.0.4f) and figure out whats new, whats possible now. My experience with Unity 4 free is also just a little. Anyway I work with the "new" cloth component and have some general questions to different funkctions. The documentation brought no knowledge to me. So I would be thankful if one of you could explain me the different points in an accessible way. First question touchs the constraints. When I edit the contraints (of a plane for example), there are two options to activate. What are the differents between "Max Distance" and "Surface penetration". "max Distance" is clear to me but i don't know what the second option does. Seceond question I have an tablecloth positioned over a sphere. In playmode when i move the sphere up and the tablecloth react correctly. But the sphere ist temporaliry visible trough the cloth. Its look like a graphicbug then, but ist there a way to prevent this? So I hope my questions a clear enough to understand. Thanks a lot for your educational effort.


Unity 3D Vive Focus conversion difficulties I Keep getting this error message below when I try to build and run the game. I have downloaded sdk package sdk tools windows 4333796.zip Android studio. I am new to this kinda technology any help will be appreciated. The VR device is Vive Focus. error Message below Extracting from com.htc.vr.samples.hellovr.unity manifest miniWaveSDKVersion is Null! NumDoFHmd is Null! NumDoFController is Null! NumController is Null! Please ensure that these metadata in your manifest matches the capabilities of your title. This metadata will affect how viveport store distributes and displays your title


Why is my custom Texture2D blurry? Have some WWW object downloading a .PNG image. ((SpriteRenderer)renderer).sprite Sprite.Create(request.texture, new Rect(0,0,100,100)) My sprite looks fine. Now, let's be a bit redundant and create a Texture2D out of the bytes from the download Texture2D t new Texture2D(100,100) t.LoadImage(request.bytes) ((SpriteRenderer)renderer).sprite Sprite.Create(t, new Rect(0,0,t.width,t.height)) Technically, this should produce something identical to the above snippet. However, the sprite is blurry (as in, low quality). I suppose it is when calling LoadImage. What may be causing this?


How to move object on local space not object space in unity I am watching this (game dev, space parenting amp rotation) Sebastian Lague video and found that there are three spaces actually (not two) and these are world space, local space and object space. World space The static space (0,0,0) Object space related to the object space Local Space related to the parent of the object I am amazed that i didn't find the distinction between these two spaces(local and object) on official unity forms but actually it exists. My question is that why there is no Space.Local? I found that there are Space. Self and Space.World. Space.Self is refer to object space. I can move my object to object space using this void Update () transform.Translate(new Vector3(0,0,1) Time.deltaTime 2,Space.Self) And i can move my object to world space using this void Update () transform.Translate(new Vector3(0,0,1) Time.deltaTime 2,Space.World) but there is no support for local space that i could move the object to local space (means move the object related to its parent object). There is a fair distinction between Local and Object space but unity didn't consider it i guess or i am wrong.