_id
int64
0
49
text
stringlengths
71
4.19k
0
What size should I scale my sprites to before importing them to Unity? I'm developing a game with an 8bit look. I want to target iOS and Android devices. The real resolution for my backgrounds is 108 x 192. Should I should put them in that same resolution and scale them in Unity using FilterMode or s there a way to make the camera use nearest neighbor? Or should I resize all my sprites before importing to something bigger? And if so to what size? 1920 x 1080?
0
Unet, client is unable to control spawned units I am trying to create a simple table top game with Unet. Right now I am just trying to get simple spawn mechanics working. The issue I am having is that the host computer can spawn and control objects correctly. The object gets instantiated, it gets added as a child to the armylist gameObject correctly. The client is able to see the object move around. Etc. Everything is working correctly it appears from the host side. The client however, can only instantiate a game object then they lose all reference to it. Also when it gets instantiated it does not become a child of the correct object, it is just its own object in the scene without a parent. The host computer can see the object be spawned. I am not sure what I am doing wrong, I have tried reading the documentation but to no avail. Any help would be greatly appreciated. public class PlayerManager NetworkBehaviour SerializeField GameObject tank SerializeField Camera PlayerCamera SerializeField GameObject ArmyList new GameObject 50 private Vector3 placePos GameObject currentUnit void Start () void Update () if (Input.GetKeyDown (KeyCode.A)) Cmd place initial units () Rpc PlaceUnit () Command void Cmd place initial units() currentUnit Instantiate(tank, placePos, Quaternion.identity) as GameObject currentUnit.transform.parent transform.GetChild(0) ArmyList 0 transform.GetChild (0).GetChild (0).gameObject NetworkServer.SpawnWithClientAuthority (currentUnit, connectionToClient) void Rpc PlaceUnit() if (ArmyList 0 ! null) RaycastHit hit if (Physics.Raycast (PlayerCamera.ScreenPointToRay (Input.mousePosition), out hit)) if (ArmyList 0 .tag "ground") placePos new Vector3 (hit.point.x, 1f, hit.point.z) else placePos new Vector3 (hit.point.x, 1.2f, hit.point.z) ArmyList 0 .transform.position placePos
0
Move camera around player while facing player My player has the following hierarchy Hero (GameObject) Model (child of "Hero", centered at 0 0 0) Camera (child of "Hero") The camera should be allowed to change its position around the Model in a circle ("rotate around the center") rotate so that it always faces the Model move up and down move nearer and further from to the Model I know how to do that using Quaternions, but as I'm doing this in a coroutine and using Lerp, I found myself in situations where the camera would get right through the model as this was the shortest path between the destination and the target vector. I would now like to use pure angles (Sin and Cos), preferrably without LookAt. Can somebody share how I would position and rotate the camera according to the angle, perhaps even taking a camera height variable into account as the camera should also be able to move up and down, still facing the player? That would be the bomb!
0
Accessing RigidBody2d from OnTriggerEnter2D(Collider) I have the following script on my water object which, when the Players ship triggers it, the ships gravity is inverted to give the sense of buoyancy. I have added a 'print' statement to prove that the collision is working and that the Name condition check works, which it does. However it throws an error when trying to access the plays ship Rigidbody2D property to then access the GravityScale with the message There is no 'Rigidbody2D' attached to the "Player" game object, but a script is trying to access it. You probably need to add a Rigidbody2D to the game object "Player"... void OnTriggerEnter2D(Collider2D coll) if (coll.gameObject.name "Player") print("Player Hit Water") Rigidbody2D tmp coll.gameObject.GetComponent lt Rigidbody2D gt () tmp.gravityScale 1 Update It turns out this code is fine it was the structure of my gameobjects that was the problem as the Rigidbody2D was in the child object, not the parent. See comments below for details.
0
Handling an item database with procedurally generated items? Let's say you have an item database which has every item in your game. This works fine for regular items like a Health Potion, a normal Iron Sword etc, because these items have ItemID's so we can get an exact copy of this item. But what if we have an Iron Sword with an enchantment ' 5 Fire Damage'? (or whatever) If you were to save that item to a player's inventory, exit the game and load the game, the item will load as a regular Iron Sword, because it still has that ID. Specifically, how would you save that item to a file? I'm using Unity, so to save the Player's inventory, I use PlayerPrefs.SetInt("Inventory " i, inventory i .ItemId ) Would you create a custom item ID for every item with enchantments or is there a better way around this?
0
Unity and Apple TV Remote control sensitivity I'm developing a game for Apple TV and I'm responding to the swipe gesture using if (Input.GetKeyUp(KeyCode.Joystick1Button4)) DoSomething() But the problem is that this is too sensitive, and triggers when the player didn't intentionally swipe. Is there any way to set the sensitivity?
0
How to create button prompts for interactable objects in Unity? I have a class of objects tagged as interactables that my player can interact with when within range. When my player is near them, I want to display a button prompt at the bottom of the screen, along with a description of the type of interaction possible (for example, "inspect", "use", etc.). I want to account for the possibility that the player might be within range of two or more of them at once, and thus allow him to toggle through them, displaying their button prompts in turn. If my player interacts with something which generates a text box or other modal, I want the button prompt to disappear, but to return when the text box or modal is closed. Any advice on how to go about achieving this? I've done it in the past in different engines, but I have always been unhappy with how convoluted my method was. I'd like to hear how others might tackle this. Given how common this kind of thing is in games, I'm surprised I haven't found a good tutorial on it yet. You can be as general or as specific as you'd like in your answer.
0
counting coins after a certain time I am beginner in unity . and now i am trying to write my first game. the game is includes appear random coins in random place on the screen , after passing a certain amount of time.(one coin will be appear and then after for example 2 seconds it will be destroyed and the other coins will be appear in another place ). there is a counter which calculate the number of click on coins which appear in scene and counting number of clicks on screen The coin is a prefab .Now i need to count the number of coins that will be disappear after certain amount of time. can someone help me how i can write the code.
0
Actual Sizes of An Image loaded with a Path I have a method which selects an Image from device. I need to show this image to users. The codes below works fine, does what I need. Texture2D texture new Texture2D(512, 512) texture.LoadImage(System.IO.File.ReadAllBytes(imgPath)) texture.Compress(false) texture.Apply() I just want to know how to change new Texture2D(512, 512) to real size of this Image. Maybe this new Texture2D(img.ActualWidth, img.ActualHeight) Any idea? Additionly is there any way to get original width and height from an Image loaded from a base64String ? byte imageBytes Convert.FromBase64String(base64Str) Texture2D textureImage new Texture2D( 250, 300 ) textureImage.LoadImage(imageBytes)
0
How to solve problem with Terrain Flashing and then disappears when flying away? I am making flight simulator( my first Unity project) , the biggest challenge so far is terrain, so whenever I fly away from it (not that far) the terrain starts flashing and disappears which is just green mountains, so when i come back to it, i have no idea where its position is, but it suddenly appears (again flashing) when I am close , the terrain size is normal but it's on top of a huge other terrain (about 100,000 100,000 which is the max),I tried changing pixel error and base map distance, no change, I looked at big terrain solutions online, but non of them really helped me, Any advice? Thanks
0
Colliding wiith a smooth line of blocks I'm having a strange problem. I'm creating a 2D platformer, and creating the gameplay map by reading a csv file and placing prefabs of the appropriate type on map. One part of the map is a simple straight line of blocks. I can move across them no problem except that there's this particular area where I simply can't move over it. (In the image the blue tiles are the ones I'm colliding with. I added that to help debug it). The block itself is not higher than any other blocks in the rest of the line, comes from the same prefab et cetera. If I remove "Fixed Angle" from the player character block, when passing from this block it'll start to rotate wildly instead suggesting that it's colliding with some sort of edge. Here's the code I'm using to generate the blocks for (int x 0 x lt tiles.GetLength(0) x ) for (int y 0 y lt tiles.GetLength(1) y ) var tile tiles x, y if (tile.HasValue) switch (tile.Value) case TileType.MAIN CHARACTER Instantiate(mainCharacter, new Vector3(x TILE SIZE, y TILE SIZE), Quaternion.identity) break case TileType.NORMAL Instantiate(maintile, new Vector3(x TILE SIZE, y TILE SIZE), Quaternion.identity) break default throw new NotImplementedException("No code for tile value " tile.ToString()) So, what am I doing wrong exactly? Is there a way to tell Unity to ignore these 'tiny' collisions? EDIT 1 If it makes any difference, I'm using BoxColliders2D around each block
0
Unity Easier way to resize group of buttons to the same size I have a canvas with buttons, with a script attached to each button. This script creates an array for buttons and resizes every button to the same size as the longest one in that array (the button with the longest line of text in it). Everything works, but I was wondering is there is an easier, more automatic way for this instead of having to drag every button in every array in the Inspector tab? Any ideas would be greatly appreciated UnityPackage https transfer.sh 6BCDG buttonwidth.unitypackage public Image otherbutton void Start () for(int i 0 i lt otherbutton.Length i ) if (otherbutton i .rectTransform.sizeDelta.x gt gameObject.GetComponent lt Image gt ().rectTransform.sizeDelta.x) gameObject.GetComponent lt ContentSizeFitter gt ().enabled false gameObject.GetComponent lt Image gt ().rectTransform.sizeDelta new Vector2( otherbutton i .rectTransform.sizeDelta.x, otherbutton i .rectTransform.sizeDelta.y)
0
Consume input events in Unity 4.6 How do I consume the input events in the new 4.6 unity gui system? If I click on a button for instance I don't want anything else non GUI related that might be listening for mouse input to react to the event.
0
Optimal solution to render sprites with transparent edges in Unity Since I'm currently developing a 2D game for mobiles, overdraw and drawcall count is my first priority in the design of the application I've thought initially to split each sprite in two parts one where each pixel is fully opaque (to render with cutout shaders in front to back order) and the other part with semi transparent edges (which will be ordered back to front) Since I need to support ES2.0 devices, I can't use texture arrays and I need to fit as many sprites as possible in a single 2048x2048 texture atlas to reduce drawcalls and ensure mobile compatibility, but as you can see from this picture Splitting sprites in opaque and non opaque parts will certainly double the space occupied in the atlas, thus decreasing by half the potential amount of consecutive sprites I can draw in a single drawcall This way, I'm paying drawcalls to reduce overdraw. By rendering the entire sprite with transparent shaders I'd pay overdraw to reduce drawcalls. Am I missing something? Is there a better approach?
0
Most efficient way to achieve the following 2D heat wave background effect? In Unity, what would be the most efficient way to achieve the following heat wave background effect Super Metroid SNES (skip to 34m 5s for those on mobile) http youtu.be yB317FOcU0Y?t 34m5s Obviously one way of doing this is by animating the sprite directly, which actually might be the most efficient way in terms of GPU, but is definitely more labor intensive. Could a shader be created to do this?
0
Changing Pixels Per Unit First off, excuse my ignorance. I am just getting started in game dev. and ran into a little issue. So I had these weird rippling lines going across my screen, and saw in a couple forums that this means I don't have what is called a quot pixel perfect quot game. To fix this, I am supposed to change the pixels per unit of each sprite down to 1. Currently I had it on 32 because that is my sprite size and I am a complete noob. Now, I change it down to one but it completely destroyed my game. Everything that is generated on my map grid is sucked into the center in this giant orb of sprites (I procedurally generate my map off a grid of 1 0s). I am guessing there is just a setting or some such thing that I am missing. Any ideas? Also would be happy with an alternative to remove the rippling lines.
0
Need some advice on how to decide where to implement my enemy behaviours I'm in the middle of writing a platformer game in Unity using C . I have my character, if he presses the kick button his state switches to kicking. During this "kicking" state the character doesn't actually do anything, he only publicly exposes the kicking information such as kickForce etc. The enemies however have a check in their update functions for the players isKicking value, if he is and the enemy lies within the range for being kicked by the player then the enemy has forces applied to itself and such. All this works fine but I've been thinking about future implementation of different enemy types, if I want to implement other types of enemies that do not behave the same this same script will not work. To me this is inintutive, part of me thinks that the kicking behavior should be in the player class, he should retrieve all enemies within the area of kicking and run them through some sort of KickObject method. However this is my very issue, I am unsure of what the cleanest and most straightforward (and easily extendable) way of doing this is. I have this problem in general when it comes to implementing the structure of the game, i don't know the best answer and I feel that often when I am planning things they get much more complicated than I had originally planned for down the line and the structure i had in place starts to fall apart. Any advice on this matter would be greatly appreciated. TL DR For kicking enemies, should the behaviour be applied by the player or is the method of every enemy having its own "be kicked" code the better way to do this. General game development code structure questions.
0
Unity 3D C Shifting beetween worlds? Let's say I want to replicate Planeshifting from Legacy of Kain Soul Reaver in Unity. There are 2 realms Spectral realm and Material realm. The Spectral realm is based on the Material realm, only has the geometry distorted and certain objects fade out become non interactive. In Soul Reaver, it is used as means to go to areas where you normally wouldn't be able to in Material (distorting geometry), to use other powers (such as going through grates). My question is Is it even possible at all to implement this in Unity 3D? (I would need the Scene(level) or the objects to have 2 states somehow that I could switch beetween distort to real time.)
0
Unity3D How to play 360 video without VR mode? i followed the official Unity tutorial to make an inverted sphere and play a 360 video inside it and i managed to do it but the problem is i can't build the project to my phone because it says i have to turn on virtual reality support from player settings but the thing is i don't want to because when i do that it also turns on VR mode(that split screen view). what i want is to play a normal 360 video(full screen) and navigate using the gyro of phone just like Youtube. Youtube provides a button to toggle between headset and non headset mode.
0
Using Quaternions What can I do with them? (without the maths) I am a Game Developer and did not study Mathematics. So I only want to use Quaternions as a tool. And to be able to work with 3D rotation, it's necessary to use Quaternions (Or Matrixes, but let's stay at Quaternions here in this Question). I think it's important for many developers to use them. That's why I want to share my knowledge and hopefully fill the holes I have. Now.... So as far as I understood A Quaternion can describe 2 things The current orientation of a 3d Object. The rotation transformation a Object could do. (rotationChange) You can do with a Quaternion Multiplications Quaternion endOrientation Quaternion rotationChange Quaternion currentOrientation So for example My 3D Object is turned 90 to left and my rotation I multiply is a rotation 180 to right, in the end my 3D Object 90 is turned to right. Quaternion rotationChange Quaternion endRotation Quaternion.Inverse(startRotation) With this you get a rotationChange, which can be applied to another Orientation. Vector3 endPostion Quaternion rotationChange Vector3 currentPosition So for example My 3D Object is on Position (0,0,0) and my rotation I multiply is a rotation 180 to right, my endposition is something like (0, 50,0) . Inside that Quaternion there is a Axis and a rotation around that axis. You turn your point around that axis Y Degrees. Vector3 rotatedOffsetVector Quaternion rotationChange Vector3 currentOffsetVector For example My start direction is showing UP (0,1,0), and my rotation I multiply is a rotation 180 to right, my end direction is showing down. (0, 1,0) Blending (Lerp and Slerp) Quaternion currentOrientation Quaternion.Slerp(startOrientation, endOrientation , interpolator) if the interpolator is 1 currentOrientation endOrientation if the interpolator is 0 currentOrientation startOrientation Slerp interpolates more precise, Lerp interpolates more performant. My Question(s) Is everything I explained until now correct? Is that "all" you can do with Quaternions? (obv. not) What else can you do with them? What are the Dot product and the Cross product between 2 Quaternions good for? Edit Updated Question with some answers
0
UI Dropdown Is it possible to have a custom value type instead of an index? I'm using the UI Dropdown component which lets you set the text of an option (OptionData) only. The value of an option is the index position in the options list, so there is no way to set this. My problem is that I have a dictionary lt string, tile gt that I use to populate the dropdown options, but I would like the value of the option to be the id of the tile class, not the index position. Edit I know I can access elements from the list by using the value (index). list dropdown.value .id But I wanted to see about extending the dropdown with this small change, as I have some other changes I would like to make, but wanted to start with something simple first just to get an idea of what is possile. I do not want someone to post a full code solution. Am mostly after some pointers. Looking at the dropdown class, I don't see how I can extend it to modify some things (value in this case), it looks like I would have to implement by own version? Some code will make this a little clearer I think All tiles into list. List lt Tile gt list new List lt Tile gt (mydictionary.Values) Sort all tiles based on the tile name. list.Sort((x,y) gt x.name.CompareTo(y.name)) Current way to add list to dropdown. for(int i 0 i lt list.Count i ) dropdown.options.Add(new Dropdown.OptionData() text list i .name Tile name (string). ) ) What I want to do. for(int i 0 i lt list.Count i ) dropdown.options.Add(new Dropdown.OptionData() text list i .name, Tile name (string). value list i .id Unqiue tile id (string). ) ) Getting changed value dropdown.onValueChanged.AddListener(delegate Debug.Log(dropdown.value) Instead of the index selected, I want the tile id ) Or if the value is needed internally for some reason, then maybe an extra property that can be set and retrieved. for(int i 0 i lt list.Count i ) dropdown.options.Add(new Dropdown.OptionData() text list i .name, Tile name (string). tile id list i .id Unqiue tile id (string). ) ) dropdown.onValueChanged.AddListener(delegate Debug.Log(dropdown.tile id) ) I took a look at the DropDown class to see if I could extend it and add the "tile id" option in, but I got completely lost on what to do, as I am still quite new to C . https bitbucket.org Unity Technologies ui src a3f89d5f7d145e4b6fa11cf9f2de768fea2c500f UnityEngine.UI UI Core Dropdown.cs https docs.unity3d.com ScriptReference UI.Dropdown.html
0
Would a custom mod built for RakNet be automatically usable with Unity? Context I'm interesting in developing a security module for servers that handle mobile games, and I'd like it to be usable by the most people possible. So I'm trying to decide what server software I want to build it for. I'm looking at RakNet, and it's appealing because it's available two ways independently and as part of the networking solution of Unity3D. So it's software that gets used by developers who want to use Unity3D as well as those who don't. My question if I create a modification that implements my security system inside RakNet, will that solution be automatically compatible with Unity also?
0
How to get the previous value from string array c (Unity) I have this example data Data P ,B ,B ,T ,P This must be something like this But what is happening to me is this here's my code string , table new string 104, 6 string newPreviousValue quot placeholder quot int xIndex 1 int yIndex 0 if (result.Equals(newPreviousValue) amp amp yIndex lt table.GetLength(1) 1) yIndex 1 table xIndex, yIndex result else xIndex 1 yIndex 0 table xIndex, yIndex result So you won't get confuse the result variable is the data generator. What could be missing on my condition? I tried doing something like this if (result.Equals(newPreviousValue) amp amp result.Equals(newPreviousValueTie) amp amp yIndex lt table.GetLength(1) 1) but what's happening here is they're all in y axis falling in line .
0
How can I get the Text component from TextMeshPro ? I'm getting null exception At the top of the screen public GameObject uiSceneText private TextMeshPro textMeshPro Then in the script at some point uiSceneText.SetActive(true) if (textMeshPro.text ! quot quot ) textMeshPro.text quot quot The exception error null is on the textMeshPro on the line if (textMeshPro.text ! quot quot ) textMeshPro is null. This screenshot shows the TextMeshPro in the Hierarchy and I see that the Scene Image object and its child Scene Text both are enabled true. I want to get the text and add replace a new text with the text already in the Text but the textMeshPro is null. The complete script using System.Collections using System.Collections.Generic using TMPro using UnityEngine public class PlayerSpaceshipAreaColliding MonoBehaviour public float rotationSpeed public float movingSpeed public float secondsToRotate public GameObject uiSceneText private float timeElapsed 0 private float lerpDuration 3 private float startValue 1 private float endValue 0 private float valueToLerp 0 private Animator playerAnimator private bool exitSpaceShipSurroundingArea false private bool slowd true private TextMeshPro textMeshPro Start is called before the first frame update void Start() textMeshPro uiSceneText.GetComponent lt TextMeshPro gt () playerAnimator GetComponent lt Animator gt () Update is called once per frame void Update() if (exitSpaceShipSurroundingArea) if (slowd) SlowDown() if (playerAnimator.GetFloat( quot Forward quot ) 0) slowd false LockController.PlayerLockState(false) uiSceneText.SetActive(true) if (textMeshPro.text ! quot quot ) textMeshPro.text quot quot textMeshPro.text quot Here I will add the new text. quot if (slowd false) private void OnTriggerEnter(Collider other) if (other.name quot CrashLandedShipUpDown quot ) exitSpaceShipSurroundingArea false Debug.Log( quot Entered Spaceship Area ! quot ) private void OnTriggerExit(Collider other) if (other.name quot CrashLandedShipUpDown quot ) exitSpaceShipSurroundingArea true Debug.Log( quot Exited Spaceship Area ! quot ) private void SlowDown() if (timeElapsed lt lerpDuration) valueToLerp Mathf.Lerp(startValue, endValue, timeElapsed lerpDuration) playerAnimator.SetFloat( quot Forward quot , valueToLerp) timeElapsed Time.deltaTime playerAnimator.SetFloat( quot Forward quot , valueToLerp) valueToLerp 0
0
SceneManager.LoadScene doesn't seem to be working in Unity IDE I'm in the start screen scene of my game and I'm trying to load the actual game. I use the following code public void LoadGame() SceneManager.LoadScene ("Main", LoadSceneMode.Single) I set this method to be called when a button in the UI is clicked. When testing in the game in the unity IDE, clicking the button doesn't do anything. Is my code wrong, is the IDE screwing up, or will clicking the button never do anything in the ide?
0
How do I convert a humanoid retargetted animation to a generic animation? In my game, I use a Generic Rig model called quot hero generic quot . I have a pistol shooting animation. This animation was created for another rig, so I need to use Humanoid retargetting to use it on my model. To try out how it looks, I copy my quot hero generic quot character, name it quot hero humanoid quot and create a Humanoid avatar for it. Then I set the animation to quot Humanoid quot , put it on an animation controller and put the animation controller onto the quot hero humanoid quot . It works, the animation is now playing on my Humanoid character, but I don't want my character to be Humanoid. I want to bake the animation out for my hero generic character. Unity doesn't provide any built in option to do that. How can I turn this retargetted animation to a generic .anim file?
0
How do I make dialogue only appear once? So I made it so when I walk over a NPC it brings up 12 lines of dialogue, and you press E to get to the next line. When the dialogue is over you can keep pressing E and it will bring the dialogue up every time. I want it so it only brings the dialogue up once. How do I do that? This is my script for it using System.Collections using System.Collections.Generic using UnityEngine public class dialogHolder MonoBehaviour public string dialogue private DialogueManager dMan public string dialogueLines public float questComplete Use this for initialization void Start() dMan FindObjectOfType lt DialogueManager gt () Update is called once per frame void Update() private void OnTriggerStay2D(Collider2D other) if (other.gameObject.name "Shrump") if (Input.GetKeyUp(KeyCode.E)) dMan.ShowBox(dialogue) if (!dMan.dialogActive) dMan.dialogLines dialogueLines dMan.currentLine 0 dMan.ShowDialogue()
0
A python script controlling a Unity game I wish to build a simple game in Unity such that the objects in the game can be controlled via a Python script (or a code in any other programming language). Is this possible? If yes then how? If no then are there any other alternatives to achieve similar results? To make it more clear, say that I have 10 objects in my current scene. What I wish to do is to address each object individually via Python. One way of doing this is setting up keyboard bindings to select a particular object and then using keyboard and mouse events to control this object. But, is there a more cleaner (a native) way of doing the same?
0
How to check in Unity whether tile B can be reached in a straight line from tile A? I'm currently trying to smooth out my A paths based on this article. This is what I want to achieve But sadly I'm stuck at implementing the Walkable method. I don't know how could I check whether a unit can reach tile B in a straight line from tile A. (Let's keep it simple, and currently every unit is 1 tile wide.)
0
Shooting the closest enemy that you can see I'm trying to make my main character aim at the closest enemy that he can see. My issue is with the close range criterion taking priority. If the enemy is near the player but the player can't see him, I'd like the player to look for another enemy inside his range. As you can see in the image, There is an enemy behind the wall. The player is not aiming at him because he can't see him. So far this is correct. But the player is also ignoring the enemy in front of him because he's busy rejecting the one behind the wall. What he should do is aim at the one in front of him, because he can see him and he is inside the player's range. using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.AI using UnityEngine.UI public class clickme MonoBehaviour private NavMeshAgent mAgent public float mark, ToPoint public bool actives, seeEnemy private Transform target public float range, enemyDistance range is player eyes field. public float speed 5.0f public Transform aiming point, playerEye private GameObject targets void Start() targets GameObject.FindGameObjectsWithTag("enemy") target targets 0 .transform seeEnemy false void Update() if (mAgent.remainingDistance lt mAgent.stoppingDistance) actives false if (actives false amp amp playerEye true amp amp target ! null) if (enemyDistance lt range) Vector3 dir target.position transform.position Quaternion lookRotation Quaternion.LookRotation(dir) Vector3 rotation Quaternion.Lerp(transform.rotation, lookRotation, Time.deltaTime speed).eulerAngles transform.rotation Quaternion.Euler(0f, rotation.y, 0.0f) else else actives true updateTarget() end update void updateTarget() GameObject enemies GameObject.FindGameObjectsWithTag("enemy") float shortesDistance Mathf.Infinity GameObject nearestEnemy null foreach (GameObject enemy in enemies) float distanceToEnemy Vector3.Distance(transform.position, enemy.transform.position) if (distanceToEnemy lt shortesDistance) shortesDistance distanceToEnemy nearestEnemy enemy RaycastHit hit can I see my closent enemy or not ? if (Physics.Linecast(playerEye.position, nearestEnemy.transform.position, out hit)) Debug.DrawLine(playerEye.position, nearestEnemy.transform.position, Color.blue, range) if (hit.collider.tag "enemy") seeEnemy true print(" I can see enemy !") else seeEnemy false print("No enemy here!") end foreach if (nearestEnemy ! null amp amp shortesDistance lt range amp amp seeEnemy true) target nearestEnemy.transform aiming point target.transform.Find("aim") enemyDistance Vector3.Distance(transform.position, target.transform.position) else target null aiming point null seeEnemy false enemyDistance 0 end target
0
Agent trying to reach same position as other agents, instead start spinning in place I create units in my game and have a rally point where they should walk to when created, like Age of Empires. My problem is that since they compete for this position after a while, sometimes they end up doing this https gfycat.com decentquestionableandeancondor https gfycat.com densehonoredgalapagosalbatross As you can see one of the guys cant reach the rally point, so he starts rotating. I realize this has to do with stopping distance, but no matter how high I set the stopping distance this eventually becomes a problem when there are many enough units. And if I set it too high they dont walk to the rally point at all, since its not THAT far from the building they spawn from. Is there any way to manage this scenario? i.e just making him go as close as he can, and then stop? My AI Script using UnityEngine using UnityEngine.AI RequireComponent(typeof(NavMeshAgent)) public class BaseAi MonoBehaviour HideInInspector public NavMeshAgent agent HideInInspector public NavMeshObstacle obstacle float sampleDistance 50 Transform mTransform private void Awake() agent GetComponent lt NavMeshAgent gt () obstacle GetComponent lt NavMeshObstacle gt () mTransform transform private void Start() agent.avoidancePriority Random.Range(agent.avoidancePriority 10, agent.avoidancePriority 10) void LateUpdate() if (agent.isActiveAndEnabled amp amp agent.hasPath) var projected agent.velocity projected.y 0f if (!Mathf.Approximately(projected.sqrMagnitude, 0f)) mTransform.rotation Quaternion.LookRotation(projected) lt summary gt Returns true if the position is a valid pathfinding position. lt summary gt lt param name "position" gt The position to sample. lt param gt public bool SamplePosition(Vector3 point) NavMeshHit hit return NavMesh.SamplePosition(point, out hit, sampleDistance, NavMesh.AllAreas) public bool SetDestination(Vector3 point) if (SamplePosition(point)) agent.SetDestination(point) return true return false public void Teleport(Vector3 point) agent.Warp(point) lt summary gt Return true if agent reached its destination lt summary gt public bool ReachedDestination() if (agent.isActiveAndEnabled amp amp !agent.pathPending) if (agent.remainingDistance lt agent.stoppingDistance) if (!agent.hasPath agent.velocity.sqrMagnitude 0f) return true return false public void ToggleObstacle(bool toggleOn) agent.enabled !toggleOn obstacle.enabled toggleOn void OnDrawGizmos() if (agent null) return if (agent.path null) return Color lGUIColor Gizmos.color Gizmos.color Color.red for (int i 1 i lt agent.path.corners.Length i ) Gizmos.DrawLine(agent.path.corners i 1 , agent.path.corners i )
0
I have a game based on combining 2 ingredients to create a product. What is the best way to code this? (Unity) So to go a bit more in depth, in my game, you can combine a variety of ingredients to make a product. For example, you could combine water and dirt to make mud. What I am currently doing to achieve this is by listing each combination possibility that a particular ingredient has. The one thing i managed to do to make it a little more efficient is that I managed to remove duplicates (So for example, if i have coded ingredientA IngredientB Cheese, there isn't another entry for IngredientB Ingredient A Cheese). The problem I have with my method is that it is very annoying adding new ingredients. If i do so, I have to go back to every previous ingredient i have coded, and add it's interaction with the ingredient(s) i want to add. The amount of ingredients I have means this is becoming increasingly time consuming. Is there a better way to do this? This is a Unity game, coded in C . Let me know if you need any further info.
0
How best to structure manage hundreds of 'in game' characters I've been making a simple RTS game, which contains hundreds of characters like Crusader Kings 2, in Unity. For storing them the easiest option would be to use scriptable objects, but that isn't a good solution as you cannot create new ones at runtime. So I created a C class called "Character" which contains all data. Everything is working fine, but as the game simulates it constantly creates new characters and kill some characters (as in game events happen). As the game continuously simulates it creates 1000s of characters. I added a simple check to make sure a character is "Alive" while processing its function. So it helps performance, but I can't remove "Character" if he she is dead, because I need his her information while creating the family tree. Is a list is the best way to save data for my game? Or it will give problems once there are 10000s of a character created? One possible solution is to make another list once the list reaches a certain amount and move all dead characters in them.
0
Unity 5 how to toggle realtime global illumination I am using Unity 5.5. Is there a way to enable and disable precomputed realtime GI at runtime? and if so, how can I do it? The idea is that I want to set dynamic lights as a graphics quality option that the player can choose to toggle.
0
Unity3d Transform rotation(angle) help Im trying to rotate an object 90 degrees to the left but instead of rotating straight left it rotates 270 degrees to the right. Here's the part of the code which controls the rotation rotationDestination new Vector3(60, 270, 0) if (Vector3.Distance(transform.eulerAngles, rotationDestination) gt 0.2f) transform.eulerAngles Vector3.Lerp(transform.rotation.eulerAngles, rotationDestination, rotationSpeed Time.deltaTime) If I try to make the Y axis 90 a.k.a (60, 90, 0) then it rotates constantly to the left. How do I make it rotate straight to the left (90 degrees) ? Thank you.
0
Unwanted jump when landing I managed to make my 3D player character jump (hurrah!) but I get an unwanted jump upon landing. It's not a mid air double jump. If I press space mid air, then after it get backs to ground it immediately jumps again. How can I prevent this? using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMovement MonoBehaviour bool jumpKeyIsPressed float horizontalMovement bool isGrounded Rigidbody rb SerializeField float playerJumpForce SerializeField float movementSpeed void Start() sustituye GetComponent lt Rigidbody gt () por rb!!! rb GetComponent lt Rigidbody gt () void Update() if (Input.GetKeyDown(KeyCode.Space)) jumpKeyIsPressed true horizontalMovement Input.GetAxis( quot Horizontal quot ) private void OnCollisionEnter(Collision collision) if (collision.gameObject.CompareTag( quot Ground quot )) isGrounded true private void FixedUpdate() rb.velocity new Vector3(horizontalMovement movementSpeed, rb.velocity.y, 0) if (jumpKeyIsPressed amp amp isGrounded) rb.AddForce(Vector3.up playerJumpForce, ForceMode.VelocityChange) isGrounded false jumpKeyIsPressed false
0
Duplicating and adding sprites at runtime in Unity I am trying to create a 2D game in Unity in which objects keep falling from top and the player has to dodge them. Suppose I have created a sprite which serves as a single enemy that the player has to dodge.Now I have to create multiple such sprites at runtime so that they can keep on spawning from random positions.Despite searching on the net for quite some time i could not find a clear answer. I am just a newbie and I am just starting to learn game development in Unity so answers in detail will be very helpful. Thanks in Advance.
0
Fastest way to assign sprites to components in Unity I'm using a sprite atlas and Unity's built in sprite editor to tease out the individual images. Specifically, I have a single texture containing lots and lots of icons for armor, and I am assigning those to a Sprite field of a Component. However, the process of manually assigning sprites to the component via drag and drop is tedious. Is there a faster way to do this? Perhaps a way I can bulk assign sprites to a component? Update This is the code of the final solution. In short, the easiest thing to do is to put the texture atlas in the Resources folder and then programmatically access the sprites by name. private void MergeTextureAtlas(string atlasName, Dictionary lt ItemSubType, List lt Sprite gt gt spriteLookup) Sprite atlasSprites Resources.LoadAll lt Sprite gt (atlasName) Assert.IsNotNull(atlasSprites, atlasName) Assert.IsTrue(atlasSprites.Length gt 0, atlasName) int spritesLoaded 0 foreach (ItemSubType itemSubType in Enum.GetValues(typeof(ItemSubType))) string subTypeFriendlyName ItemSubTypeHelper.GetSubTypeName(itemSubType) foreach (Sprite atlasSprite in atlasSprites) if (atlasSprite.name.Contains(subTypeFriendlyName)) if (!spriteLookup.ContainsKey(itemSubType)) spriteLookup.Add(itemSubType, new List lt Sprite gt ()) spriteLookup itemSubType .Add(atlasSprite) spritesLoaded if (spritesLoaded 0) Debug.LogWarning(String.Format( "Found 0 new sprites in texture atlas ' 0 '.", atlasName))
0
Use IPointerEnterHandler with bool function? Im trying to use mouse pointer to detect any UI element on my canvas. when pointer enter any UI element, UI active set true, else UI active set false. Here is my script using UnityEngine using UnityEngine.UI using System.Collections using System.Collections.Generic using UnityEngine.EventSystems Required when using Event data. public class UI AVATAR MonoBehaviour, IPointerEnterHandler public bool UI active public void OnPointerEnter(PointerEventData eventData) Debug.Log("The cursor entered the selectable UI element.") print(eventData.currentInputModule.name) print(eventData.pointerCurrentRaycast.gameObject.name)
0
How can I render extremely large models? I'm trying to build a game in Unity similar to the game Kerbal Space Program where there are large celestial bodies that the player can orbit. I'm running into a few problems though. My first issue is that the larger I make a sphere, the slower the game gets. Secondly, whenever the sphere exceeds a certain size, the rendering engine cuts off part of the planet, which means I can only see half the model. How can I do this at the size that KSP has?
0
How to implement GIF insertion in Unity? "XYZ App doesn't support image insertion here" I'm making an Android App with Unity, which has a chat service in it. And I would like to handle sending images or GIFs via Gboard. Currently when the user selects a TextField, his keyboard comes up, which is let's say GBoard. And now when I click on a GIF or a Sticker, it says XYZ App doesn't support image insertion here So how could I implement it? Or more precisely, how can I define what method will be be called in my application when the user tries to send a GIF? Because my first thought to implement it, is like it's done in all other apps every GIF would be in a separate message, and when the user clicks on a GIF it instantly sends a special GIF message, which will be rendered for example as an animated texture. But how could I subscribe to this event in the first place? Thanks in advance!
0
Unity build report for Android is missing information This is my build report for Android Build Report Uncompressed usage by category Textures 3.4 mb 3.7 Meshes 0.0 kb 0.0 Animations 0.0 kb 0.0 Sounds 0.0 kb 0.0 Shaders 0.0 kb 0.0 Other Assets 13.5 kb 0.0 Levels 21.9 kb 0.0 Scripts 687.9 kb 0.7 Included DLLs 3.9 mb 4.3 File headers 13.2 kb 0.0 Complete size 92.5 mb 100.0 The space used by all the categories does not add up to the complete size of 92.5 mb. The build report in the Unity manual shows full utilisation by the listed categories. Where does the other 91 of the utilisation go?
0
convert clock input into 24 hour format I have stuck in a logical problem I have a third party package of DayNight. It takes hours input(24 hour format) to show dayNight effects in scene My code is to transform 12 hours clock cycle into 24 hours is if (todsky.Cycle.Hour gt 0 amp amp todsky.Cycle.Hour lt 11.97) Debug.LogError("1st") var degree 360 hourniddle.transform.eulerAngles.z var degreeToMintues degree 2 multiply each degree with 2 to get correct minutes ConvertMinutesToHours(degreeToMintues) else if (todsky.Cycle.Hour gt 11.97 amp amp todsky.Cycle.Hour lt 23.97) Debug.LogError("2ndt") var degree 360 hourniddle.transform.eulerAngles.z as rotation is anti clock getting rever degree var degreeToMintues degree 2 multiply each degree with 2 to get correct minutes var MintuestTo24HoursMintueCoverstion 720 degreeToMintues add 720 mintues into current minute in order to get 24 hour format ConvertMinutesToHours(MintuestTo24HoursMintueCoverstion) void ConvertMinutesToHours(float mintues) result TimeSpan.FromMinutes(mintues) Debug.LogWarning(result.Hours " " result.TotalHours " " result.Minutes " " result.TotalMinutes) todsky.Cycle.Hour (float) result.TotalHours Debug.LogWarning("setted hours " todsky.Cycle.Hour) But it is not working correctly . have made a clock GUI(360 degree) and as you know it only show 12 digits format not 24. I am getting clock needle movement which can be change through mouse drag. Needle z position up to 320 degree which means one degree is equal to 2 minutes and i am taking it as input from GUI. I write below code to integrate my clock needle with my DayNight package in order to integrate GUI with package and passing hour parameter into the package but it not working correctly. Problem is that else condition is skipping.
0
Problem with Moving object with touch and make camera to follow the object I watched a tutorial about Unity Mobile From Scratch Moving a 3D Object with Touch in Perspective on YouTube but when I added a camera follow script to follow that 3D object the object keeps moving even I clicked or dragged the ball once. Does anyone know why this is happening? This is the code of moving the ball with mouse or touch from the tutorial if (Input.GetMouseButtonDown(0)) Ray mouseRay RayGenerator() RaycastHit hit if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out hit)) if (hit.transform.gameObject.tag "BowlingBall") obj hit.transform.gameObject objPlane new Plane(Camera.main.transform.forward 1, obj.transform.position) Ray mRay Camera.main.ScreenPointToRay(Input.mousePosition) float rayDistance objPlane.Raycast(mRay, out rayDistance) ballTouchOffset obj.transform.position mRay.GetPoint(rayDistance) else if (Input.GetMouseButton(0) amp amp obj) cameraFollow.enabled false isDragging true Ray mRay Camera.main.ScreenPointToRay(Input.mousePosition) Ray mouseRay RayGenerator() Debug.DrawRay(mouseRay.origin, mouseRay.direction, Color.red) float rayDistance if (objPlane.Raycast(mRay, out rayDistance)) obj.transform.position Vector3.Lerp(transform.position, new Vector3(mRay.GetPoint(rayDistance).x ballTouchOffset.x, obj.transform.position.y, obj.transform.position.z), sideForce Time.deltaTime) else if (Input.GetMouseButtonUp(0) amp amp obj) obj null isDragging false cameraFollow.enabled true And this is the camera script to follow that ball public Transform bowlingBall public Vector3 offset public float cameraSlideSpeed 5f void LateUpdate() transform.position Vector3.Lerp(transform.position, bowlingBall.position offset, cameraSlideSpeed Time.deltaTime)
0
Main Controller dont destroy on load I would like to have a Main Controller class that should exist in many scenes. I used DontDestroyOnLoad and in runtime an object associated with this class is present in hierarchy. However, how can I use this script if its only visible in runtime? How can I assign the coresponding game object to button if I cant see It until I run the game?
0
How to find a valid point if NavMeshObstacle is blocking path? Is there any way to find the closest valid point to my target if a NavMeshObstacle is blocking my agent's path? This point can be any point along the red line in the image above.
0
SRTM data represented in 3D using Unity Terrain I am new to using Terrain height maps in Unity. I'm trying to use real world terrain height data, using sources including The US Geological Survey (files like N24E054.hgt) Google Maps (SRTM hdr files, tfw files, and tif files) I want to import this high definition terrain data into a Unity terrain. In Unity, it seems like terrain can only import Raw data representation. How can I use an hgt file to shape a Unity Terrain?
0
How to make a road terrain for unity game? im making a FP game in low poly style. I want to make some terrains for my game, with roads, trees, rocks, buildings and e.t.c. Unity terrains are not as good as i thought. They allow a good tool for placing multiple objects (like tree to sprite tools, trees mesh copy for perfomance), but the terrain building tool itself is very poor, so i cant use 3d terrain, because there will be no great tools for placing surroundings. So my plan is make low poly mountains, trees, rocks in Blender, then make a simple terrain with hills in unity and just place my surrounding objects on it. I have some troubles, for example roads. I have a road elements, and by connecting amp banding them i can get a really nice road. But how can i make a road on Unity's terrain? For example it could be useful to export unity terrain as a 3d mesh to Blender, then make my roadways and export them in Unity.
0
Using Bluetooth in a Unity3D Game Apart from using a plug in or other third party device, is there anyway Unity can support bluetooth communication between two devices? All of the links I have found seem to relate to third party options which I want to try and avoid.
0
Retrieving an array of images from Firebase Storage As title says I'm trying to get all images on firebase storage and save them to an array which later on i will be using to load them into the scene. i can manage downloading on image so far but I'm unsure of how to make them into an array. This is the code I'm using now to download one image by name and assigning it into a texture variable storage FirebaseStorage.DefaultInstance storageRef storage.GetReferenceFromUrl( url) storageRef.Child( resourceName).GetBytesAsync(1024 1024).ContinueWithOnMainThread(task gt if (task.IsCompleted) Texture2D texture new Texture2D(1, 1) byte fileContent task.Result texture.LoadImage(fileContent) Debug.Log(texture.name.ToString()) selectedText texture if (task.IsFaulted) Debug.Log( quot faulted DOWNLOAD quot ) ) now through that i want to replace my current function which loads all images through the inspector. if (LevelSystemManager.Instance.CurrentLevel lt source.Length) selectedText source LevelSystemManager.Instance.CurrentLevel Source being the array i use from the inspector to load those images into the game scene which then are selected into the selectedTex Texture2D and loaded based on the level, so 0 element in array level0 , 1 level 1 etc. etc. So i was wondering if i have a couple of folders inside firebase with 10 to 20 images each how can i make that source array pull from that folder? And as a result remove the need to have them in the game and of course not setting them through the inspector.
0
Is it possible to get a Vector3 from a single Input Action in Unity's Input System? I'm trying to implement moving up down (R F), left right (A D), forwards backwards (W S) all at the same time using Unity's new Input System. There is an Action type for Vector3, but there doesn't seem to be a corresponding type for it. The way movement works right now means that it would be a lot better to get the whole vector at the same time for it to work smoothly. Is there a way to do this with a single Input Action, or will I just need multiple?
0
How can I make an inventory system in Unity? I am trying to make an inventory system for the game I'm working on with Unity and I want it to expand and compress whenever objects are added or removed. Is there any go to way to do this?
0
Why can't I directly change the position of a prefab using transform.position? (Unity3D) I am relatively new to Unity, and I am currently working on some code. I am trying to change the position of Unity's standard assets first person controller using player.position anotherObject.position offset I'd like to add that I am setting the player's position when it collides with a box collider. However, this isn't working for some reason. I've tried debugging it using print statements before and after the teleportation of the player, and this is what I see Player position (0, 2, 0) Player position after teleport (32, 2, 0) Player position one frame later (0, 2, 0) After one frame, the player returns to it's original position, as if it was never moved. Here is my code, if it will help you better understand my problem. public class PortalTeleporter MonoBehaviour public Transform player The player public Transform receiver Receiving portal private bool playerOverlap false boolean to store whether player touches the box collider on portal void Update() if(playerOverlap) Vector3 portalToPlayer player.position transform.position float dotProduct Vector3.Dot(transform.up, portalToPlayer) if(dotProduct lt 0f) float rotationDifference Quaternion.Angle(transform.rotation, receiver.rotation) rotationDifference 180 player.Rotate(Vector3.up, rotationDifference) Vector3 positionOffset Quaternion.Euler(0f, rotationDifference, 0f) portalToPlayer Offset between player and portal Vector3 pos receiver.position positionOffset print(player.position) player.position pos print(player.position) Triggered when player enters the portal void OnTriggerEnter(Collider other) if(other.tag "Player") playerOverlap true Triggers when player untouches the portal void OnTriggerExit(Collider other) if(other.tag "Player") playerOverlap false Thank you for taking the time to answer my question!
0
Parameter "MoveX" (and "MoveY") does not exist using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMovement MonoBehaviour public float moveSpeed public Animator anim Use this for initialization void Start () anim GetComponent lt Animator gt () Update is called once per frame void Update () if (Input.GetAxisRaw ("Horizontal") gt 0.5f Input.GetAxisRaw("Horizontal") lt 0.5f) transform.Translate (new Vector3 (Input.GetAxisRaw("Horizontal") moveSpeed Time.deltaTime, 0f, 0f)) if (Input.GetAxisRaw ("Vertical") gt 0.5f Input.GetAxisRaw ("Vertical") lt 0.5f) transform.Translate (new Vector3 (0f, Input.GetAxisRaw ("Vertical") moveSpeed Time.deltaTime, 0f)) anim.SetFloat("MoxeX", Input.GetAxisRaw ("Horizontal")) anim.SetFloat("MoxeY", Input.GetAxisRaw ("Vertical")) I an trying to run this with a basic 2D animation in unity personal and I keep getting Warning! Parameter "MoveX" does not exist and Parameter "MoveY" does not exist but it is clearly in the animator as a float.
0
Unity Set quad to angle of floor mesh I have a cursor object (simple quad) that I'm moving around above a floor mesh. The floor mesh has varying heights (hills and such). How can I set my quad to sit at the same angle as the mesh floor? I'm using a raycast to cast down on the position of the cursor and get the angle of the floor mesh using hit.normal, then reflect. RaycastHit hit var rayStart new Vector3(transform.position.x, transform.position.y 5f, transform.position.z) if (Physics.Raycast(rayStart, Vector3.down, out hit, 10f)) if (hit.collider.tag quot Floor quot ) Vector3 incomingVec hit.point rayStart Vector3 reflectVec Vector3.Reflect(incomingVec, hit.normal) cursorSprite.transform.eulerAngles reflectVec (I've left out the position code, that works, its just the angle code that doesnt) I've tried a bunch of variations, altering the reflectVec angle x, y and z but I can't figure out how to get it correct
0
Touch through GameObject, best practice in the game I am doing atm you have an area with monsters. There are two modes to damage monsters tapping on them casting spells on the ground Tapping and damaging a monster works fine. The problem If I have selected a spell and want to cast it on the ground, the monster collider blocks my touch of the ground behind the monster. My solution was to disable the monster collider when I want to cast a spell. GameObject toDisable GameObject.FindGameObjectsWithTag ("Touch") foreach (GameObject g in toDisable) g.GetComponent lt Collider gt ().enabled active And ... it works. Now my question is Is this an adequate solution? They say GetComponent is slow, but I guess with 20 to 30 monsters running around it should be fine? Anything else that could be done? Maybe there is some Unity magic I am not aware of.
0
Implementing online connectivity and multiplayer PVP for a newbie Background I'm a noob programmer looking to create a simple turn based mobile game as a side project. I've pretty much got the game logic down and am left with implementing the online multiplayer PVP portion. More specifically, i'm looking to implementing a system when the player clicks play and will be matched with an opponent in a 1 v 1 format, without any lobbies etc etc. I'm currently trying to develop my game in android studio(i'm new) but am also open to unity if it makes the development easier.(I have no experience in Unity). What i want to know From what i understand,i need to create and host my own server for the multiplayer to run(i.e matching of player to opponent). Do i also need the server to run the game itself or am i able to connect the player to the opponent and simply record the result of the game to my server database? Also, how would i go about creating and running hosting the server? I heard nodeJS is a good choice for writing the server. End Goal I just wanna publish my game onto the app store, IOS store, etc.
0
Attach the UIButton to Component Via Script (C Unity) I want to attach the UI to the MC Streaming Option Script via Code . What i wanted here is that this live onOff will go to the Livestream(MC Streaming Option) without dragging it . And i don't know where to start. PS The MC Streaming Option script is being attached only when the program run MC StreamingOption mcStreamingOption gameObject.AddComponent lt MC StreamingOption gt ()
0
How to add font assets to a Unity based Android app on runtime? I am working on an android app that contains a Unity scene. The unity scene has some TextMeshPro text fields where user can enter information. Users also have the option to select fonts for these text fields. I want to support a lot of fonts. Right now I add all the font assets in Unity. But these font assets add up to increase the app size a lot. I am trying to find out if there is a way to download these fonts at runtime as per the user's choice so that the initial app size is small? Is this possible? I would appreciate any links, tutorials, or help. I've not been able to find any information regarding this so far. Thanks!
0
How to add font assets to a Unity based Android app on runtime? I am working on an android app that contains a Unity scene. The unity scene has some TextMeshPro text fields where user can enter information. Users also have the option to select fonts for these text fields. I want to support a lot of fonts. Right now I add all the font assets in Unity. But these font assets add up to increase the app size a lot. I am trying to find out if there is a way to download these fonts at runtime as per the user's choice so that the initial app size is small? Is this possible? I would appreciate any links, tutorials, or help. I've not been able to find any information regarding this so far. Thanks!
0
Unity Part of the sprite is covered in shadow I have a sprite with Transparent Cutout Diffuse shader. Recieving shadows is turned on in SpriteRenderer. The light is a pointlight and I am using deffered rendering path. However when I am above or right of the object, it is covered in shadow. When I am below or left of the object everything seem to work as it should.If I place the light in the center of the sprite, only a part of the sprite is lit up, the other part is covered in shadow. Maybe it is something with normals? I need to get rid of the self shading effect. Shader Shader "Transparent Cutout Diffuse" Properties Color ("Main Color", Color) (1,1,1,1) MainTex ("Base (RGB) Trans (A)", 2D) "white" Cutoff ("Alpha cutoff", Range(0,1)) 0.5 SubShader Tags "Queue" "AlphaTest" "IgnoreProjector" "True" "RenderType" "TransparentCutout" LOD 200 CGPROGRAM pragma surface surf Lambert alphatest Cutoff sampler2D MainTex fixed4 Color struct Input float2 uv MainTex void surf (Input IN, inout SurfaceOutput o) fixed4 c tex2D( MainTex, IN.uv MainTex) Color o.Albedo c.rgb o.Alpha c.a ENDCG Fallback "Transparent Cutout VertexLit" I found out what unity uses for lambert lightning. Since I use deffered rendering so unity should use function with PrePass prefix. But the implementation of the actual lighning is implemented somewhere else and is it used for all materials, that looks like dead end. Custom Lightning inline fixed4 LightingSLambert (SurfaceOutput s, fixed3 lightDir, fixed atten) fixed diff max (0, dot (s.Normal, lightDir)) fixed4 c c.rgb s.Albedo LightColor0.rgb (diff atten 2) c.a s.Alpha return c inline fixed4 LightingSLambert PrePass (SurfaceOutput s, half4 light) fixed4 c c.rgb s.Albedo light.rgb c.a s.Alpha return c inline half4 LightingSLambert DirLightmap (SurfaceOutput s, fixed4 color, fixed4 scale, bool surfFuncWritesNormal) UNITY DIRBASIS half3 scalePerBasisVector half3 lm DirLightmapDiffuse (unity DirBasis, color, scale, s.Normal, surfFuncWritesNormal, scalePerBasisVector) return half4(lm, 0)
0
Does Unity Pro Play Nice With 'Small' Teams Does anybody know how well Unity Pro plays well with in small teams? Our team makeup is 2 programmers, 1 audio, and 2 graphics peps. How easy is it for somebody to mess up a Unity project? The graphics and audio people will likely only have a simplistic knowledge of Unity, and mainly in regards to only there area. Do the graphics audio even need access to the Unity editor? I've seen the Asset Server and it seems like a very bare bones versioning system. Before people start telling me that they should just learn it (as I agree) this is a rather last minute student prototype project.
0
Press button event instead of onClick() in Unity I want to add a nitro in my arcade game and i want to detect press UI button instead of click. unfortunately only onClick() event is available for UI button what kind of options do I have ? Thank you
0
How to get LineRenderer coordinates? I am trying to get the coordinates or positions that are generated at the time I draw with linerenderer, but it gives me an error. This may be a rookie mistake and I am not using the Linerenderer's methods well. I would be very grateful for your help. LineRenderer.GetPosition index out of bounds! UnityEngine.LineRenderer GetPosition(Int32) sendData Figura Trazo(Int32) (at Assets sendData Figura.cs 115) sendData Figura Update() (at Assets sendData Figura.cs 93) public LineRenderer line public static int contadorTrazo 0 void Update() Trazo() void Trazo() line line.GetComponent lt LineRenderer gt () Debug.Log("Trazo " line.GetPosition(contadorTrazo)) contadorTrazo
0
Exporting prefab includes a lot of unneccessary asset dependencies I just exported one of my assets into a unitypackage. It included all dependencies very nicely so I can use them. Then I tried another prefab, but it included a lot of unrelated assets from all over the project. This is a very simple prefab and I don't know how the clutter is considered to be dependencies. When I click "show dependencies" it brings up the clutter in the project menu. There should be no clutter dependencies whatsoever. It really isn't that complex of a prefab. I also double checked the prefab elements to see if any of them are somehow using the said clutter, they aren't. How can this happen? Is there a way to solve it (other than selective clicking in export menu)?
0
How do I slowly decrease a float from 0.5 to 0? I have a 2D racing game with a track, and the track is repeated with vector2. When I die, I want to slowly stop moving the track, but I do not know how. Here is my code . using UnityEngine using System.Collections public class trackMove MonoBehaviour public static trackMove Instance get private set public float speed Vector2 offset Use this for initialization void Start () Instance this Update is called once per frame void Update () offset new Vector2(0, Time.time speed) GetComponent lt Renderer gt ().material.mainTextureOffset offset Here is my current Inspector view
0
UV Tiling Offset input values from World Position incorrect behavior? I'm using ShaderGraph in 2020.1.0f1. I have some shader experience, but it's all been handwriting shaders. I have experience with node based things of this nature by way of Substance Designer. I'm working on a shader that should allow for seamless visibility between quads by changing the UV offset of a noise pattern based on the world position of the quad. That said, I'm running into two things. This short (0 05) video shows how I'm expecting this to work as the X Y values of the UV Offset are changed, the continuous flow of the noise is smooth. https youtu.be YAd9BtAWVRM So, I add a position node and a split node, feed the world position into the split, and feed R G from the split to X Y of the Vector2 node. That does two things it makes the preview boxes 3D (becomes a sphere instead of a quad), and quot expands quot the apparent tiling I'm guessing this is because the value from the split is a Vector1 rather than a float, though it seems odd that there's no implicit conversion, or that Vector1 values applied to UV Offset would change the actual appearance. So, is this due to it being a Vector1 rather than a float? If so, is there a node that can convert from Vector1 to float? Am I going about this the wrong way entirely?
0
How do I hide UI canvas in c Unity3d? I want to display the final results at last in the game when gameobjects finish the winning(finish) line. For that I am using canvas and in that a panel onto which an image is attached. I have to hide that canvas at start of the game and then show when gameobjects cross the last finish line. How can I do this..? Please if anyone has an idea about this can help me. Thanks in advance )
0
unity apply item animation to character I'm trying to change the attack animation of my player in relation to the attack animation for the item he has in his hand. For example, the default attack animation of my player is puching and once he picked up a sword I want his attack animation to be sword attack, for a hammer a hammer attack, etc .. I searched a lot on the internet but didn't find much, I saw a few post talking about AnimatorOverrideController but I'm not sure if it's what I need because it overrides every animation clip of the AnimatorController. In my case I just want to change the attack Animation Clip. So if you cloud give me some tips about the right way to do it, I would really appreciate because I'm a bit confused. Thanks Edit BTW, I'm in Unity 3d
0
MCS character mouth open is this mo cap animation problem? I have MCS Female Character where I can assigned Mocap to my character. I have downloaded mixamo animation and assigned this to the character but the problem is, the character mouth remains open. I am not 3d artist or animation guy, so here are my question. How can I solve mouth open problem in unity? What is the reason that mouth is open? Either mocap data has open the mouth or what else problem?
0
How to access "move" values from move node in Rain behavior tree? I have a blend tree for the NPC that takes an "input magnitude" value 0 to 1.0 for how fast the character should move...and an "angular input" float negative pi to positive pi for how fast the character should turn. How do I get the rain behavior tree to update these values correctly in the behavior tree "set parameter" leaves? I see that I can set the parameter with some kind of variable name, but I don't see where I can specify that variable with a script...and I don't see how I can access the "move" instructions given from the move node on the behavior tree, and use them to set the variables either. How would I accomplish this steering with Rain?
0
Determining whether a large building should be split into multiple scenes This is about designing a first person retro game in Unity3d. In this game the player would walk around inside a large maze like building that has corridors on 10 15 different floors. Each floor has a corridor that is set up as a square that surrounds all other corridors (which are set more or less randomly, like a maze) on that particular floor. The length of each side of this surrounding corridor is about 100 steps. So, considering that this building would have about 10 15 floors constructed like this, the question I wanted to ask is whether it can be included as a single scene? Or does the answer to this depend also on other factors such as the type of game assets and target devices?
0
Mouse Input Unexplained Behavior Unity3D Input.GetMouseButtonDown(0.....6) in documentation it says that you can pass, 0, 1, 2 as parameter. Input.GetMouseButtonDown. It doesn't accept negative numbers like 1 or numbers 7 . What does 3 4 5 6 do? What input are they calculating? Or can I use these numbers as default for None state? I couldn't find any information about this.
0
When an animation involves movement, where is the movement better to implement? For context, I am using Blender and Unity. Regarding the question, as an example, in some games, when you get hit, your character tucks a bit and gets knocked back a few distance. The tucking animation I want to implement in Blender but how about the knockback distance? Do you move your model in Blender (tuck and knockback), or do you do the tuck animation only (tuck in place) and then handle the knockback in Unity (basically triggering the tuck animation and then moving the model backwards a bit). My question basically is, what's commonly done and if there's any specific reason, why?
0
Instantiate and launch prefab that's overlapping player? I m very new to Unity and C . I m trying to create my first game and I have now invested about 15 hours trying to find solutions to this issue...I m stumped! My player sprite (blue square) needs to launch a prefab sprite (red circle) of similar size appearing to originate from itself. Here is a GIF of what I have so far...I don t want the blue cube to collide and go flying. After clicking and dragging on Player (drag to aim) via OnMouseDrag to set the target vector, I m trying to Instantiate a prefab sprite (Dynamic RigidBody2D, CircleCollider2D) using the Player sprite s position (a Dynamic RigidBody2D, BoxCollider2D) and have it APPEAR to be originating from inside the Player object. Launch is triggered via function called in OnMouseUp. Both objects should immediately come under control of Physics to collide with the environment which will include other moving RigidBody2D objects later. Targeting should allow 360 degrees to include straight into an obstacle allowing rebound effect. Here is some excerpts of my code using System.Collections using UnityEngine public class Teleportation Grenade MonoBehaviour This script is attached to Player and requires projectile prefab. tested with thrust set between 100 and 200. public float thrust public Transform prefab public LineRenderer playerShotLine private Vector2 playerToMouse private Vector2 targetVector ... void OnMouseDrag() Vector3 mouseWorldPoint Camera.main.ScreenToWorldPoint (Input.mousePosition) Vector2 playerToMouse mouseWorldPoint transform.position mouseWorldPoint.z 0f playerShotLine.SetPosition (0, transform.position) playerShotLine.SetPosition (1, mouseWorldPoint) playerShotLine.sortingOrder 3 opposite direction of line renderer targetVector playerToMouse void OnMouseUp() SpawnPrefab () void SpawnPrefab() Instantiate(prefab, new Vector3(transform.position.x, transform.position.y, 0), Quaternion.identity) prefab.GetComponent lt Rigidbody2D gt ().AddForce (targetVector thrust, ForceMode2D.Impulse) This is only one of many, many iterations. It's the gist of it though. I appreciate any insight from the community.
0
import text strings into Unity editor 3D text objects so that Scene View displays them I am having trouble finding a solution to this problem. I want to generate the text for TextMesh.text in a custom application and import into the Unity editor so that I can then scale the text to fit. If anyone could point me in the right direction to simply edit a 3D Text game objects' text mesh.text property from a script so that it is reflected in the scene view in Unity's editor, I would greatly appreciate it! Best Regards, Ben
0
The tile cursor is not on the same tile I selected Here is the image, when I select the tile I want to paint, it paints in the correct box where I want it to be but the white cursor should also be in the same box but it is 2 units to the left? This really makes it difficult to paint the tiles. I'm a beginner in unity and can't seem to fix this problem ( Thank you for your help!
0
My object just automatically "launch" or do stuff without me clicking on my mouse when it respawn? I've already set the ball (my object) initially at the start where I have to click for the ball to launch from the paddle (it's a ping pong game). private void LockBallToPaddle() Vector2 paddlePos new Vector2(Paddle.transform.position.x, Paddle.transform.position.y) transform.position paddlePos paddleToBall For the ball to stick to the paddle Launch the Ball private void LaunchBall() if (Input.GetMouseButtonDown(0)) hasStarted true rbBall.velocity new Vector2(Random.Range( 2f, 2f),speedVelocity) Both of which I put under Update() private void LaunchBall() if (Input.GetMouseButtonDown(0)) hasStarted true rbBall.velocity new Vector2(Random.Range( 2f, 2f),speedVelocity) Now the problem is when my ball hits a certain collider, I want it to respawn the position back to the paddle. So instead of Destroy the game object, I just copy and paste those same methods under collision if (collision.gameObject.tag quot bottom quot ) LockBallToPaddle() LaunchBalls() But now it just launches straight away from the paddle when hit the collision without me clicking anything like what quot Launchballs() quot intended to. What should I do?
0
How can I cast light onto a sprite in 3D environment? I'm making a 2.5D game, where 2D sprites are in a 3D environment. I'm using URP and I have a problem with lighting the sprites. The sprites are lighting up from behind, and not front. I tried with directional, spot and point lights but the result is the same no matter what official shader I use they only light up when they receive light from behind. Front light has no effect whatsoever on the sprites. I spent the entire day looking for a solution but I've got almost nothing. Only solution I saw someone else mention is making the game object with the quot sprite renderer quot on, a child of another gameobject and rotate it 180 degrees on Y. But that is not an option for me cause I'm using custom scripts to rotate that game object already. So can there be a custom shader? Can one be created using shadergraph maybe? I know some others have faced the same problem but did anyone really solve it? Thanks.
0
Unity Android game all squashed in center of screen (portrait layout), help I'm developing a demo for Android game in Unity with portrait layout. I used the ViewportHandler script found here (How do you handle aspect ratio differences with Unity 2D?) and it worked well. Yesterday I updated Unity (foolish move I know, two days before deliver of a project!!) to 5.4.2f2 (was using 5.4.1f1). I don't know if that is the reason but now I can in no way get my correct layout again. Sure, it is portrait but all squashed in the center and taking about one third of the screen, rest just background camera colour. Things looked well yesterday but now I'm in big trouble ( Any help would be greatly appreciated!
0
How Do I Play An AnimationClip I want to play an animation but it seems that in The new version of unity it is harder. I have an AnimationClip but I don't know how to play it. I have been looking at this for 2 hrs now and i cant get it to work. using UnityEngine using System.Collections public class FPSCamera MonoBehaviour public float lookSensitivity 5 private float xRotation private float yRotation private float currentRotationX private Animation walking void Start() DONT KNOW HOW TO FIND AND START WALKING ANIMATION void Update() yRotation Input.GetAxis("Mouse X") lookSensitivity xRotation Input.GetAxis("Mouse Y") lookSensitivity xRotation Mathf.Clamp(xRotation, 90, 90) transform.rotation Quaternion.Euler(xRotation, yRotation, 0)
0
Build Unity from C script I'd like to build and package all the ports of my Unity game through a scripting system. Linux and Windows work fine through the Unity command line options, but there is none for WebGL. For WebGL, the only existing solution seems to be its BuildPipeline. There is a gist with some sample code that has been referenced quit a few times. I changed its content to look like this BuildPipeline.BuildPlayer(scenes, ". WebGL Test", BuildTarget.WebGL, BuildOptions.None) and call it with unity editor beta executeMethod WebGLBuilder.build (Btw, is there a way to call this method from within Unity? It doesn't help I have to restart Unity each time I want to test if the script works). It will fail with the following error Assets Scripts WebGLBuilder.cs(18,3) error CS0103 The name BuildPipeline' does not exist in the current context Error building Player because scripts had compiler errors I also tried to use the BuildPlayerOptions class instead but no success. How do I get WebGL to build automatically?
0
Using shared memory instead of marshalling for C native plugins in Unity? So I'm a C developer who has been playing with C for a week or two in order to get acquainted with Unity, and I'm curious about the marshalling process used to transfer data for use in C native plugins. From what I can tell, the general consensus is that while using effective C plugins can be a performance increase for computation heavy tasks, the marshalling process of transferring data can be significantly slower than the potential gains provided by the C flexibility. I'm familiar with how shared memory works in C and it appears C has the functionality required to use the buffers as well. From what I understand, the process of marshalling is slow due to copying, creating buffers and transferring chunks from one memory segment into another. Even though there's the problem of cache coherency when operating in shared memory, it may be less than the cost incurred by marshalling. I'm sure I'll have to do some experimenting. Does anyone have thoughts or experience with using shared memory or marshalling in Unity who could weigh in on the question?
0
Switching from software Engineer to Game developer I don't know if this is the right place to ask this. I've been working as a software engineer for 3.5 years so far, mostly web apps, mobile apps, web pages in banking systems, educational, etc but I always wanted to work as a game developer. Currently I have a university degree in CS, and I'm attending a masters degree in Apps design. I've very little experience in game dev (only for hobby), some space shooters and some steps in unity, also I took some courses of blender, and did some simple sprites (those 8 bit characters but animate them is a big problem for me atm.) but I've never gone too far. I know I cannot focus on all aspects of game development, because it is a huge world integrated with different disciplines, but I need to make a portfolio with some of my games at least. (I only have partial prototypes, some of them work, some don't...) I need some advise of people who are in the game business. Which platform framework do you recommend for me ? I already know a bit of Unity and I feel pretty comfortable with it. I can get some assets to work with (models audio, etc), there are some free material in the store, and I have budget to spend on that too if necessary. How do game companies hire people? What am I suppose to aim for a job? I mean this is a world full of disciplines and I need to focus in something particular I guess, I'm a senior frontend developer too, so I guess I should focus on coding. I think portfolio is the best way of showing your work. Any suggestions are welcome! thanks!
0
How to make a 'Picture book Cutscene' in Unity 2D with simple 2D images? I'm trying to implement a simple cutscene system in my Unity game, preferably one that allows cutscenes to play at the start and end of each of the levels. What I was imagining was pretty similar to A Hat in Time's 'storybooks' from it's time rifts, but full screen and advanced with a single key. The images are simple and comic like, and I was wondering how to implement such a feature since it feels like it's a bit different to Unity's pre existing Timeline system, as there isn't many moving parts. How do I go about approaching this problem? At least, I don't know how to get the project to a state where a person can press a key to turn to the next page (whether or not there's a visual transition to the next is optional) and once it's done, to start the actual level scene. Do I still use the Timeline for this? I know I could potentially use an empty game management prefab in order to set up when to play the cutscenes, however.
0
How should I store trading cards? I'm working on a Magic esque TCG in Unity. Currently, the cards themselves are all prefabs I have a Satyr Archer prefab, a Candle Wisp prefab, etc. This works fine for now, since I only have a few cards, but by the time I get to several hundred, I feel that this may become unwieldy. Are prefabs a good way to store a large list of cards? Should I be making those prefabs using an XML document and a script?
0
Unity strange clones behavior I am setting up a grid of tiles (2d sprites) in Unity with this code public class Grid MonoBehaviour public GameObject slot public int gridW 9 public int gridH 9 private GameObject , grid new GameObject 9, 9 void Awake() for(int y 0 y lt gridW y ) for(int x 0 x lt gridH x ) GameObject gridSlot (GameObject)Instantiate(slot, new Vector3(x, y, 0), Quaternion.identity) gridSlot.transform.parent transform grid x,y gridSlot I then would like to have printed on the console the x,y coordinates of an individual tile when clicked on it. This is the script attached to the tile prefab public class Tile MonoBehaviour void Start () void Update () if(Input.GetMouseButtonDown(0)) Debug.Log(transform.position.x " " transform.position.y) Yet when I click on a tile I get printed the coordinates for ALL of the tiles on the grid. Why is this happening? Is there something very basic I am missing...? Thanks!
0
Can a material be created from a gameobject in Unity? I am trying to manually create snowflakes in unity, after I created a snowflake in the unity scene, is it possible to create a material out of it?
0
Unity Multiplayer functionalities or Google's plug in? I want to add multiplayer matches to a game I'm making for Android PC, and something echoed in my mind would the network functionalities Unity provides work in Android? I ask this because Google has a free plug in for their services, but Unity also offers possibilities. Also, using any of the above, do I need to pay to rent a server? Or, for example, since we need a paid developer account to register our game at Google Play Store, the servers are part of the deal?
0
How to figure out what's moving my GameObject? I have a GameObject as part of a complex scene with a handful of interconnected parts, that's moving when it shouldn't be. I've tried running under the debugger and setting breakpoints on all of the script points that are supposed to move its Transform, and ensured that none of them are firing. There seems to be some "spooky action at a distance" going on, some rogue script doing something I don't want it to be doing, but I can't for the life of me figure out where it is. What I'd really like is some way to set a "breakpoint" on the object's Transform that will break me into the debugger when it gets moved by any script, but that doesn't appear to be supported. Is there any way to figure out exactly what it is that's moving my object around when it shouldn't be? (And before anyone says "trial and error, disable components and see when it stops moving," I already know exactly which component to disable to make it stop moving. Unfortunately, that isn't helping track down the problem because the movement isn't coming directly from that component's MonoBehaviour script.)
0
Reading data from files in Unity on Android I have successfully read in and written level data using .dat files on unity PC builds, but compiling for android stops me from being able to read in information from the resources folder. I was under the impression that when it's compiled the resources folder was still accessible? I could create a .dat file in the persistent data path but that means hard coding the information only to serialize it, rather than the data originating from the .dat file itself. How can I include this data within the apk without hard coding it? Here is my code, working on PC Stream file File.Open("Assets Resources levelData.dat", FileMode.Open) levelData (LevelDataFile)bf.Deserialize(file) file.Close() Edit for context, the level data is very simple as this is just a puzzle game, and each level will just have a few starting positions and obstacles etc, and there will be 100 levels, hence I'm not doing a scene per level.
0
Can I write plugin extension to Unity editor? Is there possiblity to write my own plugin extension to Unity editor ? I want to write plugin to generate map for me from xml file.
0
Unable to save player data in a binary file within Update() method I'm trying to save player life within a binary file in Application.persistenceDataPath. I've written a method to store the player life public void SaveLife() BinaryFormatter bf new BinaryFormatter () FileStream file File.Open (Application.persistentDataPath " playerInfo.dat", FileMode.Open) PlayerData data new PlayerData () data.savedLife life bf.Serialize (file, data) file.Close () The problem is that when the SaveLife() is called OnApplicationQuit it works. Instead, if I call it within an Update() method of a class, it doesn't work. The Update() method is called when a certain event is triggered void Update() if (life lt 20) if ( certain event is triggered) SaveLife() lifeTimer Time.deltaTime if (lifeTimer lt 0) ResetLife () The container class for the data is Serializable class PlayerData public int savedLife What could be the problem?
0
How to code simple Goomba like AI for 3D Platformer? I'm making a 3D Platformer and have an enemy similar to a Goomba in terms of AI. How do I get the enemy to walk around and then follow the player when they're in range?
0
How do I increase object movement speed after some time? I'm new to Unity, and am making a game where an object goes up, falls down and is destroyed. This object has been instantiated. I want to increase the object movement speed by 1 after 10 seconds, but not by more than 12, because the object moves off screen. How do I do that? This is what I have, so far using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class DestroyScript MonoBehaviour public Rigidbody2D rb private float destroyTime 2.0f private int speed 8 void Start() rb GetComponent lt Rigidbody2D gt () Destroy(gameObject, destroyTime) void FixedUpdate() transform.Translate(Vector2.up speed Time.deltaTime, Space.World) transform.Rotate(0, 0, 1) Thank you for your answer and sorry for my incomplete question actually object are spawned. here is the spawned script public class SpawnItems MonoBehaviour public Transform SpawnPoints public GameObject Coins float createRate 1.5f, createRateTimer float rateIncrease 0.1f, intialCreateDelay 1.0f int callCounter 0, callBeforeRateIncrease 15 Use this for initialization void Start () createRateTimer createRate intialCreateDelay private void Update() createRateTimer Time.deltaTime if(createRateTimer lt 0) CustomInvoke() void CustomInvoke() int spawnIndex Random.Range(0, SpawnPoints.Length) int objectIndex Random.Range(0, Coins.Length) Instantiate(Coins objectIndex , SpawnPoints spawnIndex .position, SpawnPoints spawnIndex .rotation) callCounter if(callCounter gt callBeforeRateIncrease) createRate rateIncrease callCounter 0 createRateTimer createRate
0
Continous repeatable object image moving horizontally unity3d I want to move objects on the screen horizontally. And the user has to pop the object by touching it. When user touch it, it gets destroyed and new object comes randomly. For experimenting, I used Unity's Scroll Rect to move them. What can be the best solution for this.
0
Unity Animation Change the "Transition Speed" between 2 animations during runtime I need to change the Transition Duration per Runtime. I just didnt find a way to do access it. I found questions with similar problems though (links below) those didnt work for me because they accessed it to change it via editor script. But I need it in runtime. Is that even possible? https stackoverflow.com questions 29315507 unity 5 access modify animatorcontroller from c sharp script in editor
0
New Unity version copies the settings of previous version I use Ubuntu 20.04. When I download a new version of Unity 3D through Unity Hub, this new version automatically takes the settings of the previous version. I have installed Unity 2020.1, and I am facing the same problem. I created a new project, but it written in 2020.1 that I used preview package. I didn't even installed any package in Unity 2020.1. I did install preview package in 2019.4. But I didn't even open the project with 2020.1. I only have one project with 2020.1. The new project I just created. I asking help because I faced this issue when I first installed 2019.1, 2019.2, etc. How can I flx it? Thanks
0
How can I properly display the distance with the unit in a string on the UI? I wrote a script for distance of car and I don t know how to make distance like this Distance 156Km. I wrote this code distanceText.text ((int)distance).ToString() "Km" It works only from 1 to 9 when it goes to 10 Km, it disappears but if I write it like this distanceText.text ((int)distance).ToString() " Km" It show like this from 1 to 9 "5 Km" and from 10 to 99 "99Km" but when it goes to 100 Km and above, it disappears. What code should I write for this to show always Km after the distance. And I have one more question. I have a gameover canvas and I'd like in gameover canvas to show the final distance I make with PlayerPrefs but it doesn't work. Here it shows how it does not work
0
Playing different particle effects in Unity on the same ParticleSystem The question really sums it up What is the best way to use one particle system for playing different particle effects? The scenario GameObject is picked up and it starts playing a simple indicator particle effect. If the GameObject is placed on a special platform it will play another particle effect. I have very little experience with particle systems how would you do this?