Unity sprites rendering problems on Android I'm creating a simple 2d game for android, with normal sprites and animations. The problem is that when I open the game on my smartphone (Samsung galaxy trend plus), The sprites are rendered this way Of course, this is not what should happen. Moreover, within the Unity editor everything works flawlessly. My settings for the export are Texture compressions ETC2 (GLES 3.0) Tested also with "Don't override" Player settings Default orientation landscape Use 32 bit display buffer unchecked tried also with this option checked Rendering path forward tried also with Legacy Deferred Static batching Dynamic batching both checked Camera settings Clear flags Solid color tried also skybox I don't have any other scene, and this one has only one camera (I saw some topics where people were having problems because they had two or more cameras). The sprites are all .png images with transparence, except for the background, that has no transparence, but is lagging. There are three sprites which are animated using the spritesheet, but they're terribly lagging, and almost can't be seen in this screenshot. I really can't understand why, I'll continue to try, waiting for your answers. Thank you in advance! EDIT If in the player settings the orientation is set to auto rotate and the device is in portrait, all the sprites works perfectly!!! The problem is that my game is meant for landscape...


Creating structure to a game (Missions, Dialogue, Triggering events upon items collected, etc) monitoring the progress of a player in our code? Hello all I have been working with Unity and other game engines libraries for many years in my spare time. It's been a long twisty road full of joy and pain D In the last few months or so I have been jumping back in and noticing I really have a good grasp of the basics for almost all aspects of game development (in other words I can happily make little characters move on input in several ways with rigidbody, without rigidbody Animations I have an ok understanding with shaders and skyboxes and post processing I kind a barebones knowledge of, etc). My main issue I always come unstuck with (and end up defeated until I start building a new project which just involves doing the above stuff I listed that I already kinda understand), is managing actual Quests or Special Events throughout the game. For example, today I'm trying to make a puzzle game (similar to Monkey Island but much much more basic puzzles for now). So you start out in the game stuck inside a room, there are many items in the room , and a door and fireplace. The door is locked. To solve the puzzle you just need to use the Jug of Water on the fire, then you will be able to click the fireplace to climb out of the room. I've actually made this exact puzzle before and it all worked (I used mainly Strings and had complicated if statements to work out if the player was holding that item). But once I applied this method across a whole game (lets say you keep the empty water jug there and need it in a puzzle way later in game along with some other items etc.) then it gets majorly complicated and seems like not a good way to do it. I've read lots about text data types. Apparently its possible to create my own custom commands in text files so that I can annotate the text and use that to trigger methods in my code , but whilst I have read a bit about this on a few forum posts I cannot find much help with coding this (on a very simple beginner level). I'm hoping I can build a text file that holds items along with dialogue and mission data Item names Item description dialogue Whether they are quest items Can they be combined (and if so with what and into what) Ideally, the same system could be used for dialogue (Initial "Hello" with NPC follow up conversations does NPC give quests? if so start one final (after all quests from this NPC complete) "See ya around!" type dialogue) The text file should be able to help me from what I've read but I dont know how?!?!? I'm fairly well versed in Polymorphism so like an Item is the parent and then child class might be Food Item Weapon Item Tool Item ,etc. and I also have parsed data from text to make simple pong breakout style levels (using Json and XML). I feel like that is the way to do it, but Im missing much about adding attributes or custom markup or something like this to my text data. I know the query here is extremely broad but any broad helpful suggestions of where I can start would be greatly appreciated. Many thanks


Update() method never called I have a class BlinkingBehaviour which inherits from MonoBehaviour. Game objects attached to scripts containing classes that inherit from BlinkingBehaviour should, as the name suggests, blink. BlinkingBehaviour is a small class so I will share the entirety of its code here public class BlinkingBehaviour MonoBehaviour private Renderer renderer public bool BlinkingEnabled public Color BlinkingColour new Color(1.0f, 127f 255f, 39f 255f) protected float CurrentColourScale protected float ColourScaleIncrementPerUpdate 0.005f protected const float MaxColourScale 2f protected void Start() this.renderer this.gameObject.GetComponent lt Renderer gt () protected void Update() if (this.BlinkingEnabled) SetBlinkingColour() else SetColour() protected void SetColour() if (this.CurrentColourScale lt 1f) this.renderer.material.SetColor(" EmissionColor", this.BlinkingColour this.CurrentColourScale) else this.renderer.material.SetColor(" EmissionColor", this.BlinkingColour (MaxColourScale this.CurrentColourScale)) protected virtual void SetBlinkingColour() SetColour() this.CurrentColourScale ColourScaleIncrementPerUpdate if (this.CurrentColourScale lt MaxColourScale) return ResetBlinkingColourScale() protected void ResetBlinkingColourScale() this.CurrentColourScale 0f I have a class Lamp which inherits from BlinkingBehaviour. I attached Lamp.cs to an object in my scene. In my inspector, I checked the BlinkingEnabled option, expecting to see the Lamp game object blinking after I pressed "Play". However, the object did not blink. Here is my Lamp class public class Lamp BlinkingBehaviour private void Start() base.Start() private void Update() base.Update() After setting various breakpoints, I could see that the Start() method was hit in both Lamp and BlinkingBehaviour. I could also see that this.gameObject.GetComponent lt Renderer gt () returned a valid component. On the other hand, my breakpoint in the Update method in Lamp was never hit. What can I do to fix this issue? UPDATE I deleted the Start() and Update() methods from my derived class. I discovered something new The Update() method in BlinkingBehaviour is never called, even though Start() is.


Can I set the unity camera to have the same position in a real world? I have a problem about setting the camera in the unity to have the same extrinsic parameters as my real world camera to the origin. So let's me describe my problem step by step. I have a camera in a real world and Its extrinsic to an aruco plane was calculated. So I use the Aruco plane(You can think as a plane reference) as an world origin(0, 0, 0). The in my unity, I want to set my camera to have the same extrinsic as my real world camera. So I take an translation to set the Position in unity transform toolbox. And set the rotation by convert my rotation matrix from extrinsic to the euler's angle and set it to x, y, z rotation. So I test this by use the unity properties named "camera.cameraToWorldMatrix". You can treat this as an extrinsic of the unity camera transform to the world coordinates(0, 0, 0). So this value should equal to my extrinsic since it's use the same rotation euler's angle. But unfortunately it's not. So how can i solve this problem or there's a simpler way to set the cameraToWorldMatrix equal to my extrinsic parameters. For more information All of my coordinates system is respect to opengl (In Opencv coordinates system are negated in y and z axis from opengl) 1.Here's my extrinsic that i got from the solvePnp() function. This is an extrinsic from camera to my aruco plane. Then I use this R T to get the euler's angle rotation and translation. And in my image also show my euler and translation. So this extinsic is also my expected extrinsic. I use these euler's angle rotation and translation to set my camera in unity. Here's my code to map from the camera coordinates to the aruco plane coordinates def mapBallToArucoPlane(camera coordinates, rvec, tvec) Mapping ball in left camera coordiantes to the camera coordinates(Aruco plane coordiantes) By using the inverse of rvec tvec Since rvec tvec is the transformation matrix from Aruco gt camera, but we need camera gt Aruco R cv2.Rodrigues(rvec) 0 print(R.shape, cv2.Rodrigues(rvec)) T np.array(tvec) print(R.shape, T.shape, np.hstack((R, T)).shape, np.linalg.pinv(np.hstack((R, T))).shape) arucoPlaneToCameraMatrix np.vstack((np.hstack((R, T)), np.array( 0, 0, 0, 1 ))) cameraToArucoPlaneMatrix np.linalg.inv(np.vstack((np.hstack((R, T)), np.array( 0, 0, 0, 1 )))) plane coordinates cameraToArucoPlaneMatrix camera coordinates plane coordinates plane coordinates plane coordinates 1 return plane coordinates, arucoPlaneToCameraMatrix My output extrinsic. (Should be the same as above) Thank you very much.


How can I move objects pixel by pixel in the scene editor? I'm trying to find a way to move objects pixel by pixel(on my screen at least) in the scene editor. I tried a lot of different buttons but nothing seems to work, please tell me Unity has this functionality because doing it by mouse or by altering X and Y yourself is really tedious.


How to align edge vertices of modular props snapped on a 2D grid? For a project I am working on I create some 3D props in Blender that can be put together in a modular way on a 2D grid in Unity. In Unity I generate the grid contents using these props. Now given these two simple shapes (imagine a pipe or railing in top view) If they are put next to eachother on the grid like so (left) I want to make a smooth transition between the two so that their edge vertices align nicely (snap together, see right image above). Note that the angle between the shapes is always the same. However there are variations like straight, left, right for each intersection and also numerous shapes. How can I achieve this? I have thought of the following possibilities Just model each possible variation in blender and use the matching prop when generating the grid (I hope I can avoid this since its a lot of effort, also it's not reusable) Rig the shapes in Blender. In Unity move the bone transforms accordingly so that they align (I like this idea, but is it practical?) (Somehow) mark the vertices on the edge of the shapes and move them to where they belong i.e. modify the mesh in Unity. Are there other better ways to achieve this? I appreciate any hints and tips. I also know I am not the first one to try this so any guidance on where to look for resources and what terms to search for is also appreciated.


Get a Vector2 Based on Object Rotation in Unity I feel like there is an obvious answer to this but I can't find it. Is there a function in unity that gives you a Vector2 (or 3) based on the rotation of an object. for example z rotation 0 gt (0, 1) z rotation 90 gt (1,0) z rotation 180 gt (0,1) z rotation 270 gt ( 1,0) I could just write this in my script the long way, but I feel like there might be a function for it in unity


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 completely hide and protect strings from the player in Unity? I have been using Unity to create a 2D game which will be completely offline (which is the problem), the game play needs you to enter certain strings at certain levels and Unity compiles to DLLs, which can be easily reverse engineered, so is there a way to protect those strings (the game is offline so I can't retrieve from other source)? The game relies heavily on those strings, and yes I'm aware of Obfuscation but I want something more robust. And I know that the easy way out would be doing everything online from a data source but I was wondering if it's possible. It can be decompiled like this


Does "Object.ToString().GetHashCode()" return a truly unique character seed? In my game I'm generating a character seed from a bunch of traits that the player chooses. The traits are all part of a Enum. In unity I've attached a script to a bunch of toggles. When the player selects a toggle I do this charGen.testCharHash trait.ToString().GetHashCode() Does this guarantee that I will have a unique number generated based on the players choice ?


Consistent normals at any angle in bezier curve Could not work out or find any solution for this. I have a spline which consists of bezier curves (in 3d space) in fact, any straight line will also have such problem. I take a point on the curve and need to get a normal to this point at any given angle 0 360 (say, to build a mesh around it or to calculate an offset for the movement). I understand that in 3d space we have to define a plane to build normal, normally by using Vector3.Cross(A, B) In general, one uses curve's tangent as A and, e.x., Vector3.up or right as B. But, if curve becomes vertical (it can go in any direction, imagine any track that is ground independent, like in space), it gets aligned with Vector3.up, and the direction of normals goes crazy, swaps direction and so on, which is quite logical. More, it does so not only in straight vertical position, but start to change gradually around it. So, the question is how can I get consistent (all in equally correct direction) normals, using any given curve point position and angle for normal rotation? Update The initial approach looked like this public Vector3 GetTangent(...) Vector3 q2 CalculateTangent (...) Quaternion lookAt Quaternion.LookRotation (q2) Vector3 normal lookAt Vector3.up normal Quaternion.AngleAxis (angle, q2) normal return point normal size Which generated the following normals (blue is up) Now, if I try to use the previous normal for the direction Quaternion lookAt Quaternion.LookRotation (q2, previousNormal) first of all, I don't understand what to place here Vector3 normal lookAt ? And any combination of tangent, normal and rotation gives me something like this Where it can be clearly seen that normals on the vertical are improved (though not correct), but on the horizontal all went wrong, as if I just changed Vector.up to Vector3.right. In addition, the code for generating the tube in its main part looks like this float vStep (angleTo angleFrom) pipeSegmentCount if (b 0 amp amp tP 0f) tP 0.01f if (b 0 amp amp t 0f) t 0.01f if (b spline.Nodes.Count 2 amp amp tP 1f) tP 0.9f if (b spline.Nodes.Count 2 amp amp t 1f) t 0.9f Vector3 vertexA spline.GetTangent ( pP, tP, bP, Vector3.up, pipeAngle, pipeRadius) Vector3 vertexB spline.GetTangent ( pointsTotal b s , t, b, Vector3.up, pipeAngle, pipeRadius) for (int v 1 v lt pipeSegmentCount v , i 4) vertices i vertexA vertices i 1 vertexA spline.GetTangent ( pP, tP, bP, Vector3.up, v vStep pipeAngle, pipeRadius) vertices i 2 vertexB vertices i 3 vertexB spline.GetTangent ( pointsTotal b s , t, b, Vector3.up, v vStep pipeAngle, pipeRadius) Where 0.01f and 0.99f are because ends of spline do not have control points and LookRotation produces an error about zero rotation. b and bP are node indexes, and P suffix is for "previous". This particular code is used to generate a round rail and move an object beneath it. Thus, it is important that the bottom normal is consistent and always at the bottom (when it is vertical, this bottom is not the world bottom of course, but it protrudes at the side of the tube, object will turn itself accordingly, looking forward the curve).


Method subscribed to an event is called twice for every time the event is raised I am trying to make an inventory system in Unity with ScriptableObjects and a text driver that displays the contents of an inventory. So far the code looks like this An InventoryObject is defined as having a quot Container quot List of ItemObjects (simple scriptable objects, they just have a little information on the object as its sprite, its name, and whether or not it is stackable) and some methods to properly add or remove items (taking item stacking into account) from that list. https pastebin.com t4P3aGmi A PlayerInventory is a script that will be carried by the player's character. It contains a method for adding items collided with to its assigned InventoryObject instance. It also contains an OnItemPickedUp event that takes its InventoryObject instance as a parameter and passes it to listeners like UpdateDisplay. OnItemPickedUp is raised whenever a collision with a compatible item happens. https pastebin.com RsV7XYPp An UpdateDisplay script that listens to the OnItemPickedUp event and subscribes the ProcessInventoryToSingleString(InventoryObject inventory) method, that subsequently calls several methods to transform the contents of the InventoryObject's Container list into a single, formatted string. https pastebin.com N0nsvcWH The items are represented by giving a GameObject with a collider2D, aSpriteRenderer and script that contains the particular ItemObject's data and sets its SpriteRenderer's sprite to the ItemObject's. The problem I'm having is that the method subscribed to the event is being called more than once for each time the event is raised. as shown by the debug logs. Sometimes it's called twice, sometimes even four. This results in my UI display showing more items than there are. https files.catbox.moe afa467.mp4 https files.catbox.moe 6oxh9b.mp4 Here are pictures of the console debug logs I appreciate any help. EDIT These errors also appear. I'd like to believe that they're unrelated.


Load custom resources in Unity The situation is I work in my free time on one study project. I have resources of one game packed in it's own format. My intent was to use those with Unity without converting them into Unity's inner format. But with brief analysis of Unity Api Reference I did not find anything that would help my in my efforts. Like I have custom binary files I would need to parse with Unity and upon that data create geometry, lights and so on using Unity's classes. So I wonder if it's even possible? I would really appreciate if anyone would show make a hint on this subject


How can I make a shader that renders only the scene's skybox? I am trying to replicate the following image There are a few ways about doing this that involve camera stacking, layers, etc. Is it possible to create a shader that will only render the skybox?


If I make a 3d model in a .fbx format, do I owe any royalties fees to autodesk for using fbx files in Unity? I'm currently making a game where every format for every asset is either opensource freeformat, or requires no license fees to use. I've pretty much settled happily on .ogg for audio, vorbis webm for video, .png for pictures and openoffice for documents (or .pdf files since they were free standard since 2001?) What I'd like to know though is, if I make a 3d model in a .fbx format, do I owe any royalties fees to autodesk for using fbx files in Unity? If not, does this apply to every 3d model format, or only certain ones? Do software companies like Blender Unity pay for the privilege to import fbx files so that users like me don't have to?


Unity 2019 Error com.unity.xr.arsubsystems 2.2.0 preview.3 Runtime ImageTrackingSubsystem XRImageTrackingSubsystem.cs57,30) error CS0506 I am opening an old project created in 2019.3 inside my new Unity 2019.4. I got this error message in Unity Console Library PackageCache com.unity.xr.arsubsystems 2.2.0 preview.3 Runtime ImageTrackingSubsystem XRImageTrackingSubsystem.cs(57,30) error CS0506 'XRImageTrackingSubsystem.Destroy()' cannot override inherited member 'Subsystem.Destroy()' because it is not marked virtual, abstract, or override Please note that this current project does not use anything related to AR quot Augmented Reality quot or XR package. I have already Googled this error message, but have not seen a solution yet. However, I guess that this error likely comes from some conflicts in the AR or XR versions. To fix this error, should I install or update the basic Unity XR or AR package ? Thank you very much.


How can I create a custom List of GameObject inspector which works like the default one in Unity? I need to drag and drop GameObject to ObjectField. drag and drop a group of GameObjects to list name. The main problem is either do 1 or 2 work. I need the function same as unity List Inspector for future devolvement. Code as follow. static SerializedProperty ThisList public override void OnInspectorGUI() ThisList serializedObject.FindProperty("G") List name call G serializedObject.Update() Show(ThisList) serializedObject.ApplyModifiedProperties() public static void Show(SerializedProperty list) EditorGUILayout.PropertyField(list) EditorGUI.indentLevel 1 if (list.isExpanded) EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size")) ShowElements(list) EditorGUI.indentLevel 1 private static GameObject a new GameObject 50000 private static void ShowElements(SerializedProperty list) This code can drag and drop GameObject to ObjectField. for (int i 0 i lt list.arraySize i ) list.GetArrayElementAtIndex(i).objectReferenceValue EditorGUILayout.ObjectField("OBj", list.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject)) This code can drag and drop a group of GameObjects to list name. if (Event.current.type EventType.DragUpdated) DragAndDrop.visualMode DragAndDropVisualMode.Copy Event.current.Use() else if (Event.current.type EventType.DragPerform) for (int j 0 j lt DragAndDrop.objectReferences.Length j ) a j (DragAndDrop.objectReferences j as GameObject) Event.current.Use() However, it not work when both codes together. If EditorGUILayout.PropertyField(list, true) I can get the same result as the unity function. but I cant Custom the List. (such as add name, change position, add button...)


Unable to stop navmeshagent for rotation before moving I'm trying to get the NavMeshAgent to rotate before calculating a path and proceed walking. I stumbled upon a thread that said this can be done by manually rotating the object first. However, I am still stumped as to how to do this as my unit either a)refuses to move or b)moves, but does not stop to rotate. Below is the code I've attempted. void Update() RaycastHit hit if (Input.GetMouseButtonDown(0)) Ray ray Camera.main.ScreenPointToRay(Input.mousePosition) if (Physics.Raycast(ray, out hit) amp amp hit.collider.tag "Ground") targetPosition hit.point if (transform.rotation ! lookRotation) check if unit is in line with direction of hit.point agent.Stop() stops the navmeshagent from moving. direction (targetPosition transform.position).normalized lookRotation Quaternion.LookRotation( direction) transform.rotation Quaternion.RotateTowards(transform.rotation, lookRotation, Time.deltaTime speed) perform rotation else else, if already in line, set path and walk. agent.SetDestination(targetPosition)


Help with OnTriggerEntered Canvas UI This seems like it should be incredibly easy and I know there are other posts out there with a similar title, but I promise you I have looked at all of them. All I want is for my canvas that simply says "you win" to appear when I enter an invisible box collider that I have . My canvas is by default set to disabled. public class YouWin MonoBehaviour public Canvas myCanvas private void Start() myCanvas GetComponent lt Canvas gt () void OnTriggerEnter (Collision Collider) myCanvas.gameObject.SetActive(true) This script seems incredibly simple and straightforward, but for whatever reason, when I enter my box, nothing at all happens. Why might this be? What am I missing? As per an answer I also tried public class YouWin MonoBehaviour public GameObject canvas void OnTriggerEnter (Collider Collider) canvas.gameObject.SetActive(true) But had no luck with this either. I've been tinkering to no avail, can you please give me some suggestions?


How to implement a save load system in Unity? Many game allows the player to save progress at any time and load the save back at any time (like Minecraft and Doom 3). I would like to implement it in Unity. I think I will need to put the value of every variable in every script into a save file, but how? Or maybe not?


unity real time terrain editor im trying to make an editor for my game. but I want to know is it possible to edit terrain map heights or textures? if the answer is true, should i make it from scratch or can I use unity editor tools in real time? is there any asset for it? thank you for helping


Creating teams 2v2, 3v3, etc I'm figuring out how to create games with teams. The problem is that there will be games 1v1, 2v2, and so on as well as free for all. What would be the most efficient way to do this in Unity C ? I'm thinking of making a Dictionary with players' instances and every player has an index for a team. For example, we have 2v2 game, two players have teamIndex 1 and the other two have teamIndex 2. Is this the right way to do it, or there is a better way? Thank you!


load scene some time (2 seconds) after object is destroyed in Unity How do I check if an object has been destroyed. And do something like change scenes 2 seconds later. this is what I tried float delay 2 void OnDestroy() delay Time.deltaTime if(delay lt 0) Application.LoadLevel("scene2")


Sync Collider size with bones in model I'm setting at runtime a BoxCollider2D size by taking the difference between the Y position of two bones on the model... but the size I'm getting out of this creates a collider that is almost twice as tall as the distance between the two points... am I making a dumb mistake somewhere? If it matters, it's a 3d model in a 2d environment. BoxCollider.size new Vector2( BoxDefaultSize.x, Mathf.Abs(head.position.y Mathf.Min(leftFoot.position.y, rightFoot.position.y)) ) In the picture the blue gizmo shows the foot position, the green one the head position. The collider is almost 2x the distance between them Maybe there's a better way to sync the collider with the model animation that I don't know about? Addendum Vector3.Distance(head.position, leftFoot.position) returns pretty much the same result


Get intersecting point of Arc, X distance from centre (Unity) I'm no mathmetician so forgive my wording when I ask this, there is no doubt an answer somewhere but I dont even know what to search for. I want to find the intersection point (B) as a Vector2 on a perfect circle. If I know X, Y, A and C I assume I can use the radius and distance to calulate the position of B based on the distance between X and C somehow? (using C if there are any methods which will accomplish this) TIA.


Canvas enabling is not working I have a canvas with two buttons in it and I want to enable it on the button click, but when I try to enable it, it doesn't work. However, when I try to disable it on button click it does work. Here is my code public GameObject mycanvas public void onClick() mycanvas.SetActive(true) Can someone please tell me what I am doing wrong?


Moving inventory items around causes reference problems I'm in the process of implementing an inventory system in my game. The script which is most important to this question is InventorySlotManager. public class InventorySlotManager MonoBehaviour ItemData itemData const int numSlots 20 Item itemsInInventory new Item numSlots SerializeField GameObject slots new GameObject numSlots SerializeField GameObject itemImagePrefab int stackSize new int numSlots void Awake() itemData GameObject.Find("Item Manager").GetComponent lt ItemData gt () void Start() AddItem(itemData.coin) AddItem(itemData.silverRing) AddItem(itemData.coin) void Update() if (Input.GetKey(KeyCode.Alpha1)) AddItem(itemData.coin) if (Input.GetKey(KeyCode.Alpha2)) AddItem(itemData.silverRing) void AddItem(Item item) int indexOfDuplicateItem System.Array.IndexOf(itemsInInventory, item) if (indexOfDuplicateItem gt 1) Text quantityTextOfDuplicateItem slots indexOfDuplicateItem .transform.Find("Item Image(Clone)").gameObject.GetComponentInChildren lt Text gt () quantityTextOfDuplicateItem.text ( stackSize indexOfDuplicateItem ).ToString() else for (int i 0 i lt numSlots i ) if (itemsInInventory i null) itemsInInventory i item GameObject itemImage Instantiate(itemImagePrefab, slots i .transform) itemImage.GetComponent lt Image gt ().sprite item.itemSprite Text quantityTextOfNewItem slots i .GetComponentInChildren lt Text gt () stackSize i item.itemQuantity quantityTextOfNewItem.text stackSize i .ToString() return This does what you'd expect. (The bit in Update is just there temporarily for testing.) When an item gets added, the function checks to see if one already exists in the items array. If not, then the for loop is executed and the item is added to the items array, an item image game object is instantiated in the corresponding index of the slots array, etc. So far so good, everything behaves properly until I start dragging items around in my DragHandler script. So I press play, my inventory has two kinds of objects in it (coin, and silver ring). They each display their correct quantities (stack sizes) as I keep adding items. Then, I move the coin from slot 0 to slot 5 and attempt to add more coins to the inventory. It stops working because the line Text quantityTextOfDuplicateItem slots indexOfDuplicateItem .transform.Find("Item Image(Clone)").gameObject.GetComponentInChildren lt Text gt () returns null at that point. What is the best way to fix this such that this reference won't become null if I move the item to a different slot after it gets added to my inventory? I think I either have to map the items array to the slots array or store all of these values, e.g., items, slots, quantitytext, in one array. Is this correct?


How to handle enemies outside camera view in 2d platform i am making a 2d platformer in unity like mario or adventure island, and i am placing enemies manually(not doing any spawning) in the world, and those enemies have animations and movement scripts with update function. And now my question is, how can i handle the enemies outside camera view. I just want that the enemies should update animate move only when they come inside the camera view, otherwise they should be fixed where they were manually placed in the world. Maybe not only enemies but other things like coins, stars, etc(having different animations and scripts) Should i need to use some collision trigger, like attaching trigger to camera and detecting each enemies entered inside it and enabling animations and scripts on them. Please tell me if that is an efficient way or if not please tell me if there is any simple and efficient way to do this. Please correct me if there's anything wrong. Thank you.


Updated Unity project from 2020.2.1f to 2021.1.7 lighting is messed up, scenes are brighter I've updated my project from 2020.2.1f to 2021.1.7 (also tried 2020.3.8), and now my scenes are much brighter for some reason Any tips? Current I use the standard pipeline I think, because the Render Pipeline Asset is set as None. I have only one realtime directional light in the scene, and no Lighting Settings set in the Lighting window. The environment is the Default Skybox.


Setting object position in screen space camera I'm trying to set an Image gameobject's transform.position. My canvas is "screen space camera" because I needed to use a line renderer. However, when I set the position, say to new Vector3( 320, 240) the object (in play mode) gets positioned at 16266.44, y 15360, way off screen. I've tried to reset the localPosition and such based on some other answers but it doesn't help. What else could be translating my pixel coords? var go Instantiate(HexTilePrefab, this.transform) go.transform.localPosition Vector3.zero go.transform.localRotation Quaternion.identity go.transform.localScale Vector3.one go.transform.position new Vector3(screenX, screenY)


Can Unity support use textures that are not square? I have been told by another highly skilled Unity artist that Unity cannot efficiently handle non square images. Since that doesn't sound right to me, I wanted to get a second or third confirmation to that claim. Having worked in the game development industry for almost 15 years, I have always understood that best practice was keeping in powers of two, but that if the UV map called for it, a 1024x512 map was acceptable, rather than using a 1024x1024 map with 1024x512 pixels of wasted UV space. Granted, that was best practice on game engines other than Unity. Can anyone confirm that in Unity's case, it is better (best practice) to have a 1024x1024 image containing UV islands occupying 1024x512 pixels, rather than using a 1024x512 image map to exactly accommodate the UVs? Which platforms can use non square images and which ones cannot with the Unity engine? I am particularly interested in whether or not this limitation affects PC builds.


Unity Canvas hover image does not trigger event So i have the following setup This produces the following UI Now on each of the "HudCircle"(Bottom Right Left Top), I have the following components As you can see I have a script that has the following code public class HUDAction MonoBehaviour, IPointerEnterHandler, IPointerExitHandler public Color StartColor public Color SelectedColor public Image Image private void Awake() Image GetComponent lt Image gt () StartColor Image.color public void OnPointerEnter(PointerEventData eventData) Image.color SelectedColor Debug.Log("Over") public void OnPointerExit(PointerEventData eventData) Image.color StartColor Debug.Log("Not over") Sadly when playing this scene nothing happens when I hover either of the circles. Can anyone tell me what I've done wrong?


Getting any type in Unity Inspector I am developing a SaveManager system for my games. Basicly what it should do is 1) Gets the "ANY" user created Serializable class by Drag amp Drop to inspector. (save data). 2) Writes that class to a file using either BinaryFormatter or XMLSerializer. I want to be able to use it in my future games. So it should be save data class(type) independant (like serializers). I will use it like an asset, import the SaveManager, give serialized class as parameter, and let it do the rest. But as i said, it should be able to use any user created serialized class. So the problem is, since that "serialized class" will be written by the user in the "game project" (not in the SaveManager project), and i don't have that "serialized" class type in my SaveManager project, i don't know how to make the SaveManager, reference the class from inspector. So lets say i create this class in the game project (not in the SaveManager project) System.Serializable public class SaveData public string Name "Name" public int Number 5 Now when i import the SaveManager project (asset) into my "game" project, i should be able to drag and drop the script to the SaveManager inspector and let it do the rest. Since BinaryFormatter works for every Serializable type, the name of the type is actually doesn't matter. I mean BinaryFormatter is type free as long as the type is serializable. I want to use that feature, and make the SaveManager type free too. So in future if i want to use, say "MyNewSaveData" serialized class, "in an another game", i want to be able to drag and drop this to SaveManager inspector and let it do the rest. Now the thing is, if i use public object SaveData in SaveManager script, unity inspector doesn't show it. if i use public Object SaveData it casts the user created type to an Object, and i lose the type i need. I tried to use System.Type, but unity doesn't show it too. Basicly what i want to do is, get "any" serialized class as reference. Like public SerializedClass SaveData or something like public Script SaveData That reference should accept "any" serialized class. Gets it's type, then casts it to that type. When i use public Object SaveData if i use SaveData.GetType(), i get the type the "user created". I have the type, in my hands, but i can't cast Object to that type. I don't know how to use that type for casting. What ever i do, it either doesn't show up in inspector, or it casted to another type and i lose the data. What should i do?


Set up Blob shadow projector My game completely uses baked lighting in URP and because of URP's forward renderer, point and spot lights can't cast realtime shadows on moving characters if I set their types to mixed lighting, and my game mostly takes place indoors, so directional lights wouldn't make sense. So now, I thought I'd use the blob shadow projector from the standard assets pack and it didn't work then I found out that it does not support URP. Does anyone know how I can recreate the blob shadow projector for URP? Or is there another way to create fake shadows for non static characters?


How do I detect whether mouse (or touch) is being pressed over thecurrent gameObject in Unity 5? I have a Canvas set as Screen Overlay, and an Image there. I want my image become an 8 direction custom pad, so I wanted to make a component script for the image. In such behavior I would like to detect, on each frame (Update()) whether the mouse (or touch 0) is being pressed over the current object, say public class MyBehavior MonoBehavior void Update() if (Application.isPlaying amp amp Input.GetMouseButton(0)) TODO Verify the mouse is pressing over this.gameObject else if (Application.isMobilePlatform amp amp Input.touchCount gt 0) Touch touch Input.GetTouch(0) if (touch.phase ! TouchPhase.Canceled amp amp touch.phase ! TouchPhase.Ended) TODO Verify the touch is pressing over this.gameObject What I need is Determine the pressed over UI object is actually this.gameObject and not one which is overlapping in front. Determine the position of the click, in the same coordinate space as the image being clicked. My goal is to calculate the appropriate direction of the click (angle) wrt the pivot of the image. I will process that direction value. I will also calculate the appropriate distance to the pivot, and process it. How can I achieve that goal? (Notes The test I want to do for standalones and mouse are actually for debug purposes)


SerializeField UntiyEvent not properly saving modifications in EditorWindow I'm making a node editor in Unity using an EditorWindow, I'm currently trying to make it so designers can add their own methods to a node using serialized UnityEvents but I haven't been able to get it to function properly. SerializedObject serializedObject new SerializedObject(selectedNode.NodeState) SerializedProperty property serializedObject.GetIterator() property.Next(true) while (property.NextVisible(false)) EditorGUILayout.PropertyField(property) serializedObject.ApplyModifiedProperties() serializedObject.Update() The above code runs through all necessary fields of the class so the user can modify them. Everything functions perfectly with the exception of UnityEvents. They almost do as I intend them to do, except they don't preserve the variable inputs of inserted object's method. If I keep working within the editor window they stay, but if I close the window and re open the inputted variable resets. I thought this may be caused by an issue somewhere else in my code, but all other fields work fine.


Multiple SpriteSheets break batching The problem I can't fit all my 2d animation sprites for all units and environment in 1 spritesheet. Everything batches fine until I use two spritesheets... I noticed the following all units from spritesheet A batch fine until something needs to be rendered fom spritesheet B. so lets say from back to camera 50units tree 50 units camera will result in 3 drawcalls... Not that bad but if you have unit tree unit tree unit tree ... like it's probably most of the time... this wil result in 100 drawcalls even though you have only two spritesheets... How can you solve this? Or better, how can i use two spritesheets and have only two drawcalls even though the sprites are at different distances to the camera Hope this image helps to understand the problem 1 the trees are on spritesheet B and batch fine 2 the batching is broken as the unitsprite sits on spritesheet A and is put in between the trees...


Inserting into the first available inventory slot Hello my inventory system picks up one item but does not pickup any more to fill the other two slots. It is saying the whole inventory is full when it should be one slot is full. Here is my code for the inventory and this is attached to the player. public class MedInventory MonoBehaviour public bool isFull public GameObject MedkitSlot public GameObject BandageSlot public GameObject CoffeeSlot This next script is attached to the items you pickup. public class MedPickup MonoBehaviour private MedInventory medInv public GameObject itemButton private void Start() medInv GameObject.FindGameObjectWithTag( quot Player quot ).GetComponent lt MedInventory gt () itemButton.SetActive(false) void OnTriggerStay2D(Collider2D other) if (other.CompareTag( quot Player quot )) GameObject targetSlot new GameObject 0 bool validItem true switch (gameObject.tag) case quot medkit quot targetSlot medInv.MedkitSlot break case quot bandage quot targetSlot medInv.BandageSlot break case quot coffee quot targetSlot medInv.CoffeeSlot break default validItem false break if (validItem) for (int i 0 i lt targetSlot.Length i) if (!medInv.isFull i ) medInv.isFull i true itemButton.SetActive(true) Instantiate(itemButton, targetSlot i .transform, false) Destroy(gameObject) break


Generate plane with script missing triangles I am trying to do a simple script to generate a plane from a script by creating a new mesh. After trying it, it seems like some of the triangles aren't showing up. I checked if they were in the list by making it publci and they are in it, so I dont understand why the last triangles aren't showing while the others are. int size 4 Mesh meshy public List lt Vector3 gt vert new List lt Vector3 gt () public List lt Vector2 gt uv new List lt Vector2 gt () public List lt int gt tri new List lt int gt () void Start() vert new List lt Vector3 gt () tri new List lt int gt () meshy new Mesh() for (int x 0 x lt size x ) for(int z 0 z lt size z ) vert.Add(new Vector3(x, 0, z)) meshy.vertices vert.ToArray() for (int i 0 i lt ((size 1) (size 1)) i ) tri.Add(i) tri.Add(i 1) tri.Add(i size) tri.Add(i size 1) tri.Add(i 1 (size 1)) tri.Add(i 1) meshy.triangles tri.ToArray() for(int i 0 i lt ((size 1) (size 1)) i ) uv.Add(new Vector2(0, 0)) uv.Add(new Vector2(1, 0)) uv.Add(new Vector2(0, 1)) uv.Add(new Vector2(1, 1)) meshy.uv uv.ToArray() GetComponent lt MeshFilter gt ().mesh meshy


Why doesn't my material show up on my imported model (Unity Blender) UPDATE The material does work on smaller objects like a simple sphere, but not on my big arena model, which is actually imported from blender, any suggestions? UPDATE Tried to export as .fbx, but doesn't change anything. I've imported this material pack https www.assetstore.unity3d.com en ! content 13004 I tried to apply it to my mesh, but only weird things happen, I can't see the texture at all. So I tried to apply this material in the "shader calibration scene" and that worked without any problem, even updating to the standard shader worked fine. So I tried to fix it with the following things Rebaking lighting Restarting Unity Tweaking the material settings Tweaking quality settings in Unity Building the project All these things couldn't fix it, but it should most likely be related to my project settings, since this material is working in another project (shader calibration) Here are my quality settings I'm not sure, which information is needed to answer the question, but I can provide it if you ask for it. Update with Object properties


Main camera transform.forward becomes up and down when looking from above The camera script is a 3rd person orbit camera, when I look straight it does what it supposed to do which is walk in the direction the camera is pointing, but when the camera is looking down from above the player, the camera's forward is now up. This means when I press W to go forwards I go into the ground and when I press S it goes upwards. Here is my movement script private void FixedUpdate() float x Input.GetAxisRaw("Horizontal") float z Input.GetAxisRaw("Vertical") Vector3 moveDirection Vector3.zero moveDirection Camera.main.transform.right moveDirection Camera.main.transform.forward moveDirection.y 0 Rotation if (x ! 0 z ! 0) anim.SetBool("Walking", true) if (x ! 0) transform.rotation Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(moveDirection), 0.4f) else transform.localEulerAngles new Vector3(transform.localEulerAngles.x, Camera.main.transform.localEulerAngles.y, transform.localEulerAngles.z) else anim.SetBool("Walking", false) Moving if (Input.GetKey(KeyCode.LeftShift) amp amp !idle) anim.SetBool("Running", true) rb.position z Camera.main.transform.forward Time.deltaTime runSpeed rb.position x Camera.main.transform.right Time.deltaTime runSpeed else anim.SetBool("Running", false) rb.position z Camera.main.transform.forward Time.deltaTime moveSpeed rb.position x Camera.main.transform.right Time.deltaTime moveSpeed while I'm asking, the movement script gets doubled when two keys are pressed, how do I fix it while keeping the same functionality of my current movement script?


Best approach for destructible car in Unity I'm developing a simple racing car game. I'm wondering what is the best approach to manage visually car destruction. For instance i think one option (expensive) is to build car 3d model with 'separate' mesh, each for any component (bump, door, glass) and relative cooliders.. Other options ? Thanks


Unity Bullet spawns in wrong position in client I am making a multiplayer game with prefab shooting, but unfortunately the prefab sometimes spawns in the wrong position when I shoot from a client. The bullet tends to spawn in a location where the player was a few miliseconds ago, making that the bullet sometimes spawns inside of the player which killing the player in the process. For shooting, I currently have this code setup to instantiate the bullet void Update() if (Input.GetMouseButtonDown(0)) float angle GetComponentInChildren lt Weapon gt ().angle CmdShootBullet(angle) rigidbody.AddForce(Quaternion.AngleAxis(angle 180, Vector3.forward) Vector3.right (bulletPrefab.GetComponent lt Bullet gt ().force 7.5f)) Command void CmdShootBullet (float angle) GameObject bullet Instantiate(bulletPrefab, firePoint.position, Quaternion.identity) Bullet bulletScript bullet.GetComponent lt Bullet gt () bulletScript.shotBy gameObject bullet.GetComponent lt Rigidbody gt ().AddForce(Quaternion.AngleAxis(angle, Vector3.forward) Vector3.right bulletScript.force) NetworkServer.Spawn(bullet) And this is the setup for the location of the player and the gun. The top one is the player, the bottom is the gun. My guess is that it has to do with lag, that the player position does not update soon enough, so how would I make it that the bullet spawns in the position of the player in the client rather than the position of the player in the host?


Target Lower API Level than Package or Plug In Requirements I am working on a project that I want to use local mobile notifications for Android using Unity as game engine. I want to reach as much as users I can, so I want to target API level 16 for the lowest Android API level. As expected, when targeting Android API level 16 for a build, build fails with that error Execution failed for task ' processReleaseManifest'. Manifest merger failed uses sdk minSdkVersion 16 cannot be smaller than version 19 declared in library androidnotifications release C Users Tumay Varel.gradle caches transforms 2 files 2.1 71d39d4badfde5815e850866bcf079c9 AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion use a compatible library with a minSdk of at most 16, or increase this project's minSdk version to at least 19, or use tools overrideLibrary "com.unity.androidnotifications" to force usage (may lead to runtime failures) In documentation , it is explicitly saying that the package supports Android 4.4 (API 19) and higher API levels. I can handle this problem by targeting lowest API level 19, however I want to ask Is there a way to use this package or any other package or any plug in for required and higher API levels while not using for lower API levels than requirement at the same project?


Why is Vector3.MoveTowards only working on a single frame? I have three laptops in my scene and I am trying to bring them to front when I click on them. I am able to recognize which laptop is clicked by using the code below, but it doesn't move to the focus position in a single click it moves only one frame so I have to keep clicking it. void Update () if (Input.GetMouseButtonDown (0)) RaycastHit hit Ray ray Camera.main.ScreenPointToRay (Input.mousePosition) if (Physics.Raycast (ray, out hit)) if (hit.transform.name "Laptop 1") Debug.Log("Laptop 1 is clicked") Laptop1Trans.position Vector3.MoveTowards (Laptop1Trans.position, FocusPointTrans.position, moveSpeed) else if (hit.transform.name "Laptop 2") Debug.Log("Laptop 2 is clicked") else if (hit.transform.name "Laptop 3") Debug.Log("Laptop 3 is clicked") else I tried moving the move part to a method but still same behaviour. Are there any workaround?


Dissolve object starting from the bottom I'm currently getting into using the new "Unity Shader Graph"s and have made an OK dissolve shader that looks like this My next goal is to move this effect so the object dissolves bottom up. This is where I'm stuck. I tried blending this effect with another effect that just fades the object from the bottom up but this does not create the effect I am looking for ( 1 is the fade effect, 2 is the two shaders blended together) The end effect should look something like this How can I achieve this effect? Answers do not have to be specific to Unity and a good answer should include the thought process to creating this effect, not just code or pictures of a shader graph.


Unity3D Disable player input but not character movement? I'm trying to code a dash air dash for a 2D platformer. In my character controller's FixedUpdate(), I have various if statements that cause certain actions when a button is pressed. To disable player input while the dash was happening, I tried putting Dash() in an IEnumerator with a simple test code like this IEnumerator Dash() if (player.GetAxis("Horizontal") lt 0) thePlayer.GetComponent lt HeroController gt ().enabled false yield return new WaitForSeconds(0.5f) move move 2 thePlayer.GetComponent lt HeroController gt ().enabled true But since the character's physics are inside the character controller, both the player's input and the character's movements are stopped when the controller is disabled. How can I disable inputs while still allowing the character to dash?


Box2D Soft Body Wheel in Unity3D I was watching this video made with IForce2D, its about creating soft bodied wheels in box2D. http www.youtube.com watch?v F aDMZUVw0c I wanted help in being able to increase the Radius of the Wheel gradually. I tried increasing the natural distance of spring joint (Distance Joint) between central body and outer body. But since outer bodies are connected by revolute joint, which force the outer bodies to not change their positions. I then changed the Anchor Points of Revolute Joint to match the increase in Radius of Wheel. Now, the outer bodies start moving away from center body towards their natural Distance. But gradually some outer bodies rotate and move away from each other. Check out this video i made showing what i have done https drive.google.com file d 0B CQHvLBg5TQNlBEZXpRaVc5MDQ edit?usp sharing Note I am using Unity3D 4.3.4 with 2D Physics, Gravity is Off. Any ideas?


How does Unity pick which sprite atlas to load? I plan to use sprite atlases for my 2D game. All my animation is sprite animation so I'm going to use sprite atlases for my characters' sprites. My question is, if I put the same sprite in two different atlases, how does Unity decide which atlas to load? EX I have a sprite atlas per level that contains the background for that level. Sometimes, there's space left over in the atlas. So, if I want to put a sprite, which already exists in another atlas, in the empty space for that level's atlas, how does Unity know not to load both atlases?


How can I use a coroutine and GetAxis to rotate a game object? For the sake of learning about coroutine, I want to convert the following to a cleaner Update that just calls a coroutine. How would I do that? using UnityEngine public class Controller MonoBehaviour public float speed 5f private float deltaX void Start() deltaX transform.localEulerAngles.x void Update() deltaX Input.GetAxis("Vertical") speed deltaX Mathf.Clamp(deltaX, 90f, 90f) transform.localEulerAngles new Vector3(deltaX, transform.localEulerAngles.y, transform.localEulerAngles.z)


Why can't we put GameObject's into a NativeArray and pass them to a Job? I just started using the Unity Job System. It has a lot of limitations. You have to use NativeArray with it and NativeArray doesn't allow many types, notably GameObject's. It says there is a bug that you have to use non nullable types. Why can't the job system operate directly on game objects?


Unity and the problem with calling functions from other scripts I'm not sure how everyone handles this, but I'm running into lots of instances where I want to call a nonstatic script from another script which forces me to add the nonstatic script to the gameobject that also handles the other script. Such as, I would have two classes in different scripts public class Example1 MonoBehaviour public void someMethod() public class Example2 MonoBehaviour public void anotherMethod() if I wanted to call anotherMethod from someMethod, I would need to do this public class Example1 MonoBehaviour private Example2 exampleTwo void Awake() exampleTwo gameObject.AddComponent lt Example2 gt () public void someMethod() exampleTwo.anotherMethod() Is this really how everyone is working? It just seems extremely long and complicated, making me attach a whole bunch of scripts to one gameobject at runtime, and then I run into a whole bunch of issues with multiple copies of each script (such as with mousedown functions or input functions).


How to save variables into a file unity I've wanted to save progress of my game (i don't have the code , sorry) without using PlayerPrefs. If it's possible with UnityEngine.


Writing a glow shader I'm trying to learn writing shaders. And I've pieced together something that is kinda working. I want to create a transparent glow around a sphere. The problem I have is that I can't seem to alter the transparency of the glow. I tried experimenting with ZWrite off but that doesn't give me the desired results. The red part around the sphere is the glow. But I'm unable to change its alpha. I'd would also like to change the "blurriness" of the glow. How would I do that? EDIT so I did some more tinkering. I've changed the blending to Blend SrcAlpha OneMinusSrcAlpha and enabled ZWrite off. This allows me to change the alpha. The problem with this is that the inside of the object is also colored by the glow. I just want the glow around the circle. not inside. Shader "Custom HoleShader" Properties holeColor ("Color", Color) (1,1,1,1) glowColor ("Glow Color", Color) (1,1,1,1) glowSize ("Glow Size", Range (0.0,5)) 1.0 glowOpacity ("Glow Opacity", Range(0,1)) 1 SubShader Tags "LightMode" "ForwardBase" Pass CGPROGRAM pragma vertex vert pragma fragment frag uniform float4 holeColor uniform float4 glowColor struct appData float4 normal NORMAL float4 vertex POSITION struct v2f float4 pos SV POSITION float4 col COLOR v2f vert (appData v) v2f o o.pos mul(UNITY MATRIX MVP,v.vertex) return o float4 frag(v2f i) COLOR return holeColor ENDCG Tags "LightMode" "ForwardBase" "Queue" "Transparent" "RenderType" "Transparent" Pass ZWrite Off Blend One OneMinusSrcColor Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM pragma vertex vert pragma fragment frag uniform float4 holeColor uniform float4 glowColor uniform float strength uniform float glowSize uniform float glowOpacity struct appData float4 normal NORMAL float4 vertex POSITION struct v2f float4 pos SV POSITION float4 col COLOR float3 viewDirection float3 normalDirection v2f vert (appData v) v2f o float4 pos v.vertex (v.normal glowSize) o.pos mul(UNITY MATRIX MVP,pos) return o float4 frag(v2f i) COLOR return float4( glowColor.rgb, glowOpacity) ENDCG


How to write a PBR Unlit Shader in Unity? I have a REALLY specific case here I have an Texture (a webcam), that is used by a shader to pickup a few x,y colors at the cordinates, and renders to a Custom Render Texture, that is later fetched (download pixel color information from GPU to CPU), and I can handle the algorithm from there. The thing is, once I upgraded the project to PBR (Physically Based Rendering), all my Unlit scripts become PINK, and they stopped working. This is a special case because It doesn't need to appear on the screen It acts as a "Compute Shader", but with backward compatibility to old phones It works well without PBR, but once PBR is enabled it becomes pink and stops working It doesn't need to reflect, refract, output pixels or anything to the "Screen", only to my Custom Render Texture so that I can fetch it later. The algorithm doesn't fits on a Graph based programming (it has iterations and etc) Well, I didn't find documentation on how to write custom PBR shaders and here I am.


How to make a car follow a path? I have a 2D game and my goal is to make a car follow a path (the road in the picture) and rotate in the same time. I tried a plugin in the assets store but it didn't work well for me and i had difficulties making work as intended. If you have any suggestions, i ready to listen. Thanks for help in advance.


What is the right approach for using foot ik for characters in slopes(Specially when in walk or run)? i use unity but this question applies for any third person controller or enemy controller. i need to use foot ik on slopes(any condition and any kind of slope) to place foot on right places. as i considered some important third person games, it seems they only use ik when character is idle and not moving otherwise no ik is applying and leg animations run purely. i use the same approach and result looks good enough but im looking for applying when character is walking or running. as i looked, some people disable ik when leg is going up and enable it when its coming down. some other do a raycast from foot bone to the ground to check foot need ik on little distance to ground. but all of these are prototypes and has flaws. can you give me a good approach that works best in all conditions?


How can I reuse objects without depending on prefabs? I have several "frames" in a scene, each frame holds a different image. These frames all hold the same scripts and are in a way instances of the same concept, but the image is different in each frame. I want to find a solution for reusability. If I make a change in the hierarchy or add a script to the frame, I don't want to have to go through all the frames and make the same change. The prefab system works for this case in all ways but one There are desirable differences between the frames that I want to keep (the image for instance). But if I make a change to one frame, and click the "Apply" button, all the settings of the current frame will apply to all other frames, including the ones that are desirable. Is there a solution for this other than "Be careful not to click the Apply button" ?


Character Movement and Collision with Ragdoll Rigidbodies Colliders? I have a player character that I'm moving with a character controller script and it is moved by applying velocity to a Ridigbody. This works when I have a rigidbody component on the player but my character also has ragdoll colliders and rigidbodies on each body parts (set up with Untiy's ragdoll wizard). What I'd like to do is remove the ridigbody and collider that are on the player and use the ragdoll colliders and rigidbodies instead for physics movement and collision. But it's not working! When I use the rigidbody from the skeleton Root and try to apply velocity the character won't move (animation plays but she keeps running on the same spot). What do I need to do to get this working? Another issue is that if I leave the player rigidbody on but remove the large capsule collider I can move the character but collision doesn't work and she runs through static objects. I already tried with convex set to true on static meshes but it doesn't make a difference. Does somebody know what causes movement and collision not to work with the ragdoll rigidbodies and colliders?


How do I fix missing anti aliasing in the Unity scene view and game? Both the editor and the game seem to lack anti aliasing even though quality is set to Ultra. I chose the quot 3D quot project template when I created the project, so I am using the build in render pipeline.


Does Google Play allow an account to log in to the same game on 2 devices? I'm developing an online Android game with Unity. I want all Google Play accounts to have only one session logged in at a time. Do I need to write my own code to disconnect an existing session on new login attempts, or does Google Play already handle this? Edit An idea popped to my mind. I can save the logged in device's state to a a file on Google's Saved Games cloud, and write an instance specific identifier to that file that indicates who has logged on last. And checking file constantly on all instances will allow me to disconnect instances whose identifier doesn't match the one on the file on the cloud. Do you think this is a good idea? I mean, fetching file from cloud every second or so?


Attaching objects on collision in Unity? I'm trying to make a game where the player can connect objects Lego style with objects becoming children of any object they come into contact with, so if the parent object is moved the child is moved too, but the child object can be dragged away to disconnect it. What is the best way to go about doing this?


Do empty Update() methods get executed and slow down the game while playing? From an optimization point of view, is it best practice to delete the predefined update() methods in all my C scripts if there is no code inside them ? On hundreds thousands of GameObject(s) with Update() empty, does the game slow down ? Can they be left empty or is it better to delete them ?


Finding the closest point on a concave mesh (Unity C ) One of my game systems requires that I find the closest point on a generalized mesh, which more often than not will be concave. This prevents me from just using Unity's built in ClosestPoint function, and all other alternatives have some other caveat which prevents me from using them so far. The meshes are dynamically generated, pretty complex, and altered often, so it would be computationally unreasonable to split it into multiple convex meshes, unless there's some way I don't know about which allows fast splitting reattachment of said meshes. I considered checking a sphere around the point, and increasing the size of that sphere until I get a collision, but OverlapSphere and CheckSphere don't give any means to check the point of collision, only to check whether there was a collision at all. Continuing with that train of thought, I tried a Spherecast with the same method and the maximum distance set to zero, but that didn't work either. Spherecasts don't detect any objects which are inside of the starting sphere location, so setting the distance to zero will result in no collision every time. As a workaround to that, I tried setting the distance to a small positive number, equal to the step size which the Spherecast increases by each pass (in my case, 0.2). This almost works, but causes the cast to only detect collision points if I have a general direction to give it. There are two ways I tried to resolve this The first is by just passing in the direction from the point towards the center of the mesh I am trying to find collisions with, and although this works for a sphere, it breaks down for most of my other test cases, and just in a lot of different scenarios (Very concave polyhedra and shapes such as torii being two examples of situations where this method does not work.) The second method I tried was to just take the direction to the closest point on the last frame, and pass that into the Spherecast. Again, works in some situations, but breaks down on large dihedral angles. Neither of these are really sufficient for what I need them for. In terms of the constraints which I have to work under, the point should always be on the outside of the mesh, and the point should never be too far away from the mesh, but other than that there isn't really much else I can guarantee. Both the shape and the topology of the mesh are subject to change over time. Any help would be greatly appreciated, thanks in advance!


In Unity unable to find second github branch I'm using github for unity asset and for some reason I can't find new branch that was created on a different PC. I tried refreshing, fetching, reinstalling asset, reinstalling asset and recloning repository. Strangely, my laptop shows the branch, but not my personal home computer. Any ideas why is this happening?


Using points to unlock next scene in Unity Below is my code and I'm a beginning game designer trying to make my first game for art school teehee! ) I'm not sure how to unlock the next level with a scene I've already made called Rust Room Any ideas? o I also attached the error codes I'm getting! using System.Collections using System.Collections.Generic using UnityEngine.SceneManagement public class Example HUD hud int points const int ScorePrefix "Score " int score public void LoadLevel() if ("Score 45") load the nextlevel SceneManager.LoadScene(SceneManager.GetSceneByName(Rust Room)().buildIndex 1)


Determine which button is at specific coordinates I am implementing a weapon wheel in Unity and I have most of it all worked out, but am struggling with one issue My weapon wheel looks a bit like this one (example only) And mine is for something else, not weapons.. but that doesn't matter. There is no mouse involved.. the idea is to spin the wheel left and right until you've selected the item you want.. the selected one would be the one in the top most position (the example above is the bottom most position, it seems).. Anyway, I have it moving left and right just fine.. the problem now is trying to figure out which button (yes, they are implemented as UI buttons) is currently in the selected position. My initial thoughts are To calculate the center X, Y pair of the quot selected quot location and store those.. When user hits action button to select, then iterate through the 8 buttons I have in that weapon wheel and.. Calculate the current X and Y of each button in the loop If the button overlaps the quot selected quot location, then invoke that button's click() This is proving to be a real pain in the neck though.. for example, I have found that the button transform's positon is always 0,0 until you show the UI at least once.. so I have to use Update() instead of Start().. In addition, trying to calculate the overlap means needing to add width of button to current X and height to current Y and getting pixel width does not seem to be an easy task. Is there some simpler way to do this? How can I have a quot selected quot button on my weapon wheel without too much fuss like this? And if this really is the only way, then please let me know how I can get the pixel width and height of buttons.


Access Single Pass RenderTexture I'm trying to achieve a mirror effect where a second camera renders to a render texture, which is then passed into a shader using SetGlobalTexture. Everything works fine outside of VR, but in Steam VR it seems like the render texture only stores the texture for one eye (left), even with single pass stereo enabled in player settings. How can I access the texture for the second eye? Or rather, how can I access the texture where both eyes have been drawn, one on each half of the screen? What I'm doing at the moment void Awake() mirrorCameraRenderTexture new RenderTexture(vrCam.pixelWidth, vrCam.pixelHeight, 24) mirrorCamera.targetTexture mirrorCameraRenderTexture Shader.SetGlobalTexture(" MirrorCameraRenderTexture", mirrorCameraRenderTexture)


Check which object was activated first How do I check which object was activated before the other? Let's say that there's door to open. To open the door you need to press firstly the second button and then the first button...but not the other way around. I have these scripts for now Switch script (it's on 2 objects that are switches and both objects have colliders with IsTrigger checked) public var IsPressed boolean false public var triggered boolean false function OnTriggerEnter() triggered true function OnTriggerExit() triggered false function Update() if (triggered amp amp Input.GetKeyDown(KeyCode.JoystickButton1)) IsPressed true SwitchCheck script (it's on door that should be opened) public var Switch1 Switch public var Switch2 Switch function Update() if (Switch1.IsPressed amp amp Switch2.IsPressed) Destroy (gameObject) EDIT Let me explain this in detail. If Button1 Switch1 is pressed, door opens to World1.(no Button2 needs to be pressed.) If Button2 and then Button1 is pressed, door opens to the World2.


How is the value of transform.position updated and accessed between different private methods? I followed this YouTube video but I'm still confused about how the code actually retrieves the value of transform.position. I can understand the Camera.main.ScreenToWorldPoint code is to transform the screen position to a position in the world based on the camera's view, and it then uses this to update the transform.position as in the private void OnMouseDrag method. However, I also learnt that since the method is declared as private, the quot transform.position quot cannot retrieve the value of quot transform.position quot in each bracket. So how does the value of quot transform.position quot in private void OnMouseUp, private void Awake get updated, unless I misunderstood the concept? using UnityEngine using UnityEngine.Assertions.Must using UnityEngine.SceneManagement public class GreenBird MonoBehaviour Vector3 initialPosition private bool birdWasLaunched SerializeField private float launchPower 500 private void Awake() initialPosition transform.position void Update() if ( birdWasLaunched amp amp GetComponent lt Rigidbody2D gt ().velocity.magnitude lt 0.1) timeSittingAround Time.deltaTime if (transform.position.y gt 10.00 transform.position.y lt 10.00 transform.position.x gt 10 transform.position.x lt 10) string currentSceneName SceneManager.GetActiveScene().name SceneManager.LoadScene(currentSceneName) void OnMouseDown() GetComponent lt SpriteRenderer gt ().color Color.red private void OnMouseUp() GetComponent lt SpriteRenderer gt ().color Color.white Vector2 directionToInitialPosition initialPosition transform.position GetComponent lt Rigidbody2D gt ().AddForce(directionToInitialPosition launchPower) GetComponent lt Rigidbody2D gt ().gravityScale 1 birdWasLaunched true private void OnMouseDrag() Vector3 newPosition Camera.main.ScreenToWorldPoint(Input.mousePosition) transform.position new Vector3(newPosition.x, newPosition.y)


No intellisense on my classes I've been using Monodevelop's current version and Unity 4. I don't get intellisense on the classes I've created but I do have intellisense on classes that are in Unity's framework. Bug or its just as it is? I use UnityScript class SomeClass extends ScriptableObject public function Test() return "" In another class, when I use a variable typed as this class I get no intellisense.


Get object length and width divided by two? I have googled and found a script for the following task Make the camera move to touched position. However, this script will jump to x and y positions on an object, while i would like for it to move to the middle of the object, and then only be able to jump to others. using UnityEngine using System.Collections public class TapToMove MonoBehaviour flag to check if the user has tapped clicked. Set to true on click. Reset to false on reaching destination private bool flagTouchCoords false destination point private Vector3 cameraDestination alter this to change the speed of the movement of player gameobject public float duration 100.0f vertical position of the gameobject private float yAxis void Start() save the y axis value of gameobject yAxis gameObject.transform.position.z Update is called once per frame void Update() check if the screen is touched clicked if ((Input.touchCount gt 0 amp amp Input.GetTouch(0).phase TouchPhase.Began) (Input.GetMouseButtonDown(0))) declare a variable of RaycastHit struct RaycastHit hit Create a Ray on the tapped clicked position Ray ray for unity editor if UNITY EDITOR ray Camera.main.ScreenPointToRay(Input.mousePosition) for touch device elif (UNITY ANDROID UNITY IPHONE UNITY WP8) ray Camera.main.ScreenPointToRay(Input.GetTouch(0).position) endif Check if the ray hits any collider if (Physics.Raycast(ray, out hit)) set a flag to indicate to move the gameobject flagTouchCoords true save the click tap position cameraDestination hit.point as we do not want to change the y axis value based on touch position, reset it to original y axis value cameraDestination.z yAxis Debug.Log(cameraDestination) check if the flag for movement is true and the current gameobject position is not same as the clicked tapped position if (flagTouchCoords amp amp !Mathf.Approximately(gameObject.transform.position.magnitude, cameraDestination.magnitude)) amp amp !(V3Equal(transform.position, endPoint))) move the gameobject to the desired position gameObject.transform.position Vector3.Lerp(gameObject.transform.position, cameraDestination, 1 (duration (Vector3.Distance(gameObject.transform.position, cameraDestination)))) So this is how the game looks. The script moves correctly, but will jump at different positions when it hits the collider on the lily pads. I could reduce the collider, but I feel like there should be an easy way to get length and width of a collider, and reduce it by 2 to make the camera move directly in the middle. Anyone care to help? Thanks in advance. )


Strange I'm getting exception but the scripts in the exception message are not exist on my pc. What should I do? I'm using unity version 2019.2.5f1 personal I searched on my hard disks the entire pc and none of the scripts in the exception message are exist. And the exception is happens only sometimes. When I stop the game in the editor by pressing the play button the exception is show sometimes and sometimes not. I tried to close and open over agai the unity editor and the project. Still strange. MissingReferenceException The object of type 'ReflectionProbe' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEditor.ReflectionProbeEditor.OnPreSceneGUICallback (UnityEditor.SceneView sceneView) (at C buildslave unity build Editor Mono Inspector ReflectionProbeEditor.cs 651) UnityEditor.SceneView.CallOnPreSceneGUI () (at C buildslave unity build Editor Mono SceneView SceneView.cs 3359) UnityEditor.SceneView.DoOnPreSceneGUICallbacks (UnityEngine.Rect cameraRect) (at C buildslave unity build Editor Mono SceneView SceneView.cs 1935) UnityEditor.SceneView.OnGUI () (at C buildslave unity build Editor Mono SceneView SceneView.cs 2320) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture) (at lt 599589bf4ce248909b8a14cbe4a2034e 0) Rethrow as TargetInvocationException Exception has been thrown by the target of an invocation. UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C buildslave unity build Modules UIElements Renderer UIRChainBuilder.cs 238) UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C buildslave unity build Modules UIElements Renderer UIRRepaintUpdater.cs 66) UnityEngine.UIElements.UIRRepaintUpdater.Update () (at C buildslave unity build Modules UIElements Renderer UIRRepaintUpdater.cs 54) UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at C buildslave unity build Modules UIElements VisualTreeUpdater.cs 72) UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at C buildslave unity build Modules UIElements Panel.cs 637) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C buildslave unity build Modules UIElements UIElementsUtility.cs 240) UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C buildslave unity build Modules UIElements UIElementsUtility.cs 78) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C buildslave unity build Modules IMGUI GUIUtility.cs 179)


Player must places the object in the preset position I want to know how to do like this video https youtu.be 6gouxqSxeG8 At the minute 3 09, the player can put the street vendor in the predetermined location (with the green arrow show that place). Please tell me some keyword about this or video tutorial about how to implement it in unity 2d. Thanks.


I want to clamp each instance of the same prefab to the y axis only I instantiated the prefab "paddle" twice then I tried clamping it to the y axis only using Mathf.Clamp, however, the min and max values end up being applied to both instances of "paddle" and hence they can move in the x axis ok so I'm trying to make a 2d mobile pong game, I have a prefab "paddle" which are the rackets bats which the balls collide with. I instantiated the same prefab twice one on each side of the screen Paddle paddle1 Instantiate(Paddle) as Paddle Paddle paddle2 Instantiate(Paddle) as Paddle paddle2.Init(true) right paddle paddle1.Init(false) left paddle Now i want each of the paddles to only be able to move in the y axis (UP And DOWN). So I tried clamping them with var poss transform.position poss.x Mathf.Clamp(transform.position.x, 1.0f, 1.0f) transform.position poss However, this caused the left paddle to still be able to move to the right and the right paddle to be able to the left( I don't want them to move in the axis at all). This is the file GameManager.cs using System.Collections using System.Collections.Generic using UnityEngine public class GameManager MonoBehaviour public Ball Ball public Paddle Paddle public static Vector2 topRight public static Vector2 bottomLeft Start is called before the first frame update void Start() bottomLeft Camera.main.ScreenToWorldPoint(new Vector2 (0,0)) topRight Camera.main.ScreenToWorldPoint(new Vector2 (Screen.width,Screen.height)) Instantiate(Ball) Paddle paddle1 Instantiate(Paddle) as Paddle Paddle paddle1 Instantiate(Paddle) as Paddle Paddle paddle2 Instantiate(Paddle) as Paddle paddle2.Init(true) right paddle paddle1.Init(false) left paddle void Update() This is the file paddle.cs using System.Collections using System.Collections.Generic using UnityEngine public class Paddle MonoBehaviour Rigidbody2D rb float directionY float speed float height float distance string input bool isRight Start is called before the first frame update void Start() height transform.localScale.y speed 5f public void Init(bool isRightPaddle) isRight isRightPaddle Vector2 pos Vector2.zero if(isRightPaddle) Place paddle on the right of the screen pos new Vector2(GameManager.topRight.x, 0) pos Vector2.right transform.localScale.x Move a bit to the left else Place paddle on the left of the screen pos new Vector2(GameManager.bottomLeft.x, 0) pos Vector2.right transform.localScale.x Move a bit to the right Update this paddle's position transform.position pos void Update() var poss transform.position poss.x Mathf.Clamp(transform.position.x, 8.0f, 8.0f) transform.position poss I expect each paddle to not be able to move in the x axis. Only in the y axis c unity3d mobile


Inventory View Screen Looking to create an inventory screen in Unity, and trying to think of the best way to do it. My current line of thinking is having a few rows of squares for inventory items that are drag and droppable onto a paperdoll, a la Diablo. When dragging and dropping on the items, it would update a 3D model of your current playable object with the items. The menu itself would be easy enough to do with a simple square and a hierarchy of game objects for the items, each responding to mouse hovering over. The problem I am trying to figure out is being able to render the 3D model on the side. Granted, this is a nice to have, and not necessarily a need, but browsing the documentation, the only way I can think of accomplishing this is using a render to texture which requires Unity Pro with a separate camera completely out of bounds of the current space. Anyone have suggestions on how to accomplish this?


How can I disallow the changing of a parent? I want to disable transform.SetParent(Transform) for a particular GameObject. I am not sure where to start, so it is really difficult to show what I have tried. Is this even possible?


surface.Bake() no such command Regarding the code shown in this video at 13 50 When I try surface GetComponent () surface.Bake() I am getting the following error message UnityEngine.AI.NavMeshSurface does not contain a definition for bake and no extension method Bake of type UnityEngine.AI.NavMeshSurface could not be found quot are you missing an assembly reference I am struggling to get the dynamic navmesh working with Unity 2017.1.


Transform components in ECS Many game engines I've seen which are based on an Entity Component System. It has some kind of a Transform Component as a necessary component attached to all of their entities. While this does seem to make kind of sense considering an entity is only some kind of property bag and a collection of components and transformations are world space behavior (hence just part of the composition). I've noticed two other things which are very weird Transform components are used to build up the hierarchy between entities as they have a parent entity as well as child entities Transform components are specialized for only a single kind of world space, e.g. 2D or 3D. Examples The Unity3D engine. Entity children and parents seem to be accessed through the Transform Component of each entity. Also, the Transform Component features coordinates in 3D vectors. The Xenko Game Engine (previously Paradox3D), which can bee seen on GitHub. So, is this a common practice? Best worst practice? What's the reason behind having a fixed Transform component, making the Transform component only suitable for one world space using the Transform component as an hierarchy graph?


Can ARToolKit be used for color detection? I'm trying to make an app that will show an object from different sides, but the target will be too small for any real marker detection. Think of a cube with one or two centimeter sides. The camera distance is not a problem but it has to be at least ten centimeters out or what I'm trying to do won't work. I was wondering whether it was possible to color one side of the cube differently than others and make ARToolKit recognize the color to know which side it's looking at. Is this possible or just not in the range of things ARToolKit can do? If so, is there any kind of AR that can do this.


How do I properly change the value of a prefab'd instance variable? I am currently following a tutorial on how to make a 2D platformer in Unity. The tutorial explains how to make an enemy wave spawner, but it doesn't explain how to make enemies stronger after I have completed a certain amount of waves. So, to explain I have an Enemy class, which has an EnemyStats class in it public class Enemy MonoBehaviour System.Serializable public class EnemyStats public int damage 20 public int maxHealth 100 public int CurrentHealth get return currentHealth set currentHealth Mathf.Clamp(value, 0, maxHealth) private int currentHealth public void Init() CurrentHealth maxHealth public EnemyStats stats new EnemyStats() private StatusIndicator statusIndicator void Awake() stats.Init() statusIndicator transform.Find("StatusIndicator").GetComponent lt StatusIndicator gt () if (statusIndicator ! null) statusIndicator.SetHealth(stats.CurrentHealth, stats.maxHealth) And in the WaveSpawner class I have the method to spawn the enemy private void SpawnEnemy(Enemy enemy) Transform sp spawnPoints UnityEngine.Random.Range(0, spawnPoints.Length) if (CurrentWave 5 0) enemy.stats.maxHealth 20 Instantiate(enemy.transform, sp.position, sp.rotation) In the WaveSpawner you can set a certain number of waves (let's say 5), and after you complete all of the waves I've set them to repeat. So after I beat the 5 waves, I want the 5 waves to repeat and the enemies to be stronger (for example to have their max hp increased by 20). I do that with the line enemy.stats.maxHealth 20 But the problem here is that after this line is executed and I Instantiate the enemy prefab, the prefab changes its value in the inspector. So let's say that the initial value of the prefab was 120, after I beat the 5 enemy waves, the value of the prefab is set to 140. Then, after I reset the game, the initial value of the prefab is 140 and the max health of the first enemies is 140 and not 120. I have tried to not change the maxHealth variable of the EnemyStats class, but instead to have another variable tempMaxHealth and do the changes on it. This doesn't resolve my problem, as other problems arise and I don't know what to do anymore. I hope that you have an answer for me, I would be grateful if that's the case.


Unity Error within Tree Editor I've been making a tree in with the Tree Editor in Unity, and for a realistic effect, I need to make all the leaves face a general direction, the problem is that most of them don't face that direction and are upside down or sideways. So you further understand, i'll add some images. I'd like all the leaves to face in this direction. (Image 1) In here you can see that some leaves are upside down or sideways and i'd like to make all the leaves face the same way. (Image 2) In here you can see the leaf is facing up and this is the way I would like all the leafs to face. Any help is appreciated, thank you.


Load character animation on button press Unity3D I am new to Unity3D and I am going to develop a simple animation application. There is a human character and there are three button Eg "jump", "down" , "roll", I want to bind the animation files with the human character once the player presses the corresponding button. I need your help to know that what are the steps that I need to follow...let me know if anyone has good reference, thank you very much...


Help in 2d platform script Now I finished my 2d game but when I set up it in my mobile it becomes like this so I change some scripts in Maincamera but it's still the same How can I change the screen to become horizontal in my mobile like this? what I need that how can I make it fit my mobile screen.


ReorderableList in Unity with Enums I'm trying to setup a simple ReorderableList in Unity 2017.3 for a list of enums. Adding items workes fine but selecting, dragging and deleting items from the list does not (see gif). Here is my code Serializable public enum RoofType HIP, GABLE, FLAT, NONE UnityEditorInternal.ReorderableList roofTypeList new UnityEditorInternal.ReorderableList(roofTypes, typeof(RoofType), true, true, true, true) roofTypeList.drawHeaderCallback (Rect rect) gt EditorGUI.LabelField(rect, "Roof types") roofTypeList.drawElementCallback (Rect rect, int index, bool isActive, bool isFocused) gt roofTypes index (RoofType)EditorGUI.EnumPopup(rect, roofTypes index ) roofTypeList.DoLayoutList() Any ideas why this does not work? My guess it is because I use enums and not classes but it is not documented anywhere.


Unity3D behaves differently in scene and game view We are having AI being able to shoot. Everything works fine when having them play in Scene view, but when going into Game view the position they are shooting from is different. Does anyone know what could cause this? That the Unity "Scene view" behaves other than "Game view"? Hope there's anyone there to help us out, thanks in advance.


How can I iterate over all entities with a particular component? I'm currently designing a game engine and want to implement my own ECS implementation, so I decided to look around for ideas. Unity has recently updated their engine and seems to be pushing towards using ECS, instead of their original components are systems design. I noticed that Unity has a method called "GetEntities", a generic method which can do something like this public struct SomeComponent IEntityComponent public string Message "Hello, World!" public struct Filter SomeComponent someComponent public MovementSystem EntitySystem public override Process() How can I accomplish something like this? foreach(var entity in GetEntities lt Filter gt ()) Console.WriteLine(entity.someComponent.Message) I like this style of iterating over entities, given a filter for a specific component they need to include. But I'm not sure how to accomplish something like this. If someone could shed some light on how something like this is even possible in C that would be great!


How to add scene after build and deployed in Unity? I want to be able to make new levels after build. I could use a map tool and script but I rather just add scene with all the resource packed with it. But what is the best practice forward?


More loosely coupled way to design this attack and target concept? In my 2d game in unity and c sharp, my friendly units are squares. Each square has a grid on it. Each cell of the grid can have one enemy attached to it at a time. This means that my enemy's targets are not just the friendly game object, but the cell as well. Because of this, I've created a Target class for this (just contains a gameobject and cell). Enemies carry their Target reference so they know where to move to and who to attack. However, my friendlies do not need the cell to target an enemy. Enemies are small and don't have grids on them. I cannot figure out a nice way to make this polymorphic(?) Target concept work without doing checks for quot if cell is not null quot in all of my targeting code. For example, code in my behavior tree for checks like quot HasTarget quot are tightly coupled to check for existence of a gameobject and cell. It just feels wrong. Am I stuck using custom checks and code for an enemy vs friendly target? I tried interfaces but they require the same return types. That differs depending on if they are an enemy or friendly. Something like unit.Itargettable.GetTarget() won't work. Help!


What takes up more processing power between whole character models or models that are pieced together in Unity? In terms of performance when it comes to animation what takes up more processing power Whole character models or models that are pieced together? (1 object vs multiple objects). I also wonder if animating multiple objects allows us to get a better overall animation quality instead of working with one object (especially if we deal with action packed scenes).


A trigger collider in Unity doesn't allow the player to pass through It's my understanding that checking "Is Trigger" on a collider should allow rigid bodies to pass through without collision prevention, but my trigger isn't doing that consistently. The player cannot pass through, but other objects can. The trigger is a cube primitive with "mesh rendered" unchecked so that the cube won't be visible. The cube has a box collider with "is trigger" checked, and also a script. The script currently doesn't do anything except output from Debug.Log in OnTriggerEnter() as a test. Primitives are able to pass through. The test is just a basic Unity sphere with all the default settings, including a sphere collider. The only change was that I added a RigidBody. Imported models also pass through. I have a simple .blend model with a rigid body and box collider. The player does not pass through. The main difference between the player's object and the other imported model is that the player is using a custom mesh collider which is different than the player's rendered mesh. The rendered mesh is the game object and the low poly collision mesh is a child of that object. I've tried several variations, including switching the player from a mesh collider to a box collider, and also moving the box collider to the main mesh rather than a child mesh, but the results are the same. The player stops moving as soon as he hits the location of the trigger's box collider. Any ideas are appreciated. Thanks in advance. MORE INFO Here's a screenshot of the scene layout, with the invisible trigger collider selected. Also pictured is the hierarchy showing that the trigger collider ("Jump Pad Trigger") has no children. On the right is displayed every component that the trigger object has. I've also moved the collider from its original location several times to prove that it's not another object in the scene that the player is colliding with.


Need help with rotating sword around player (Unity 2D) I'm having an issue with rotating an object around another object in my top down roguelike in Unity 2D. My goal is to rotate a sword around a player based on joystick input from a controller (as shown in this image). I have looked around online for any answers, but nothing has helped. All I have so far that is remotely close to what I want is code that keeps the sword attached to the box even when the box moves. void Update() transform.localPosition new Vector3(0, 1.5f, 0) It might be necessary to note that the sword object is a child of the box object. I would appreciate it if anyone could point me in the right direction. Thanks!


How to set the force applied to RigidBody2D depending on the time user holds touch on screen? I trying to make an object jump from 1 point to another point. How far it jumps depends on how long the player holds the touch anywhere on the screen. It jumps when player releases his touch. At the code below,I able to detect the moment player release his finger. if (Input.touchCount gt 0) Touch touch Input.GetTouch(0) Handle finger movements based on touch phase. switch (touch.phase) Finger start touching the screen case TouchPhase.Began print("Start tapping") break Finger leaving the screen case TouchPhase.Ended when finger release, the object jump float rightForce Time.deltaTime 10000 2 float jumpForce Time.deltaTime 30000 2 box2D.AddForce(new Vector2(rightForce, jumpForce), ForceMode2D.Force) break As you can see I able to get the Time.deltaTime which is I assume is how long the player hold the screen. What I want to do is calculate the rightForce and jumpForce added to the object depending on the Time user hold the touch. float rightForce Time.deltaTime 10000 2 float jumpForce Time.deltaTime 30000 2 Because if I use the 2 line of code above, the result will be almost the same everytime. So what is the correct way to determine the rightForce and jumpForce depending the time user hold touch?


Objects aren't rotating in sync This is a follow up question to How to reapply force applied to one object to another object I want to make two objects move, react to collisions and other stuff as if they were one. For example, Objects A and B are entangled. When Object C rams into Object A and starts moving with it, Object B should start moving with it. When Object B hits a wall, Object A should act like it also hit a wall. I tried changing position speed every frame, but this only works when done in one direction. Now, I want all forces applied to any of the objects to also apply to the other objects entangled to it. Edit This is the new code which only fails when multiple collisions happen at once using System.Collections using System.Collections.Generic using UnityEngine RequireComponent(typeof(Rigidbody)) public class EEScript MonoBehaviour public List lt EEScript gt activeObjects public new Rigidbody rigidbody public Vector3 lastPosition Start is called before the first frame update void Start() rigidbody gameObject.GetComponent lt Rigidbody gt () Update is called once per frame void Update() lastPosition transform.position private void OnCollisionEnter(Collision collision) foreach (EEScript entangled in activeObjects) if (entangled this) continue Rigidbody rb entangled.rigidbody if (rb is null) continue rb.velocity rigidbody.velocity rb.angularVelocity rigidbody.angularVelocity entangled.transform.position entangled.lastPosition transform.position lastPosition


Unity3D free in game purchase solution Am making an android game with unity and i want to add an in game purchase feature, i looked around and all the suggestion lead to non free plugins (mainly prime31 plugin) but in the current moment i cannot afford to invest in some of these plugins, does anyone of you have a free solution for this "problem" ? thank you