_id
int64
0
49
text
stringlengths
71
4.19k
0
Networking and Timing issue I have been trying to use the low level API for UNET and the focus of this problem is this NetworkEventType recData NetworkTransport.Receive(out recHostId, out connectionId, out channelId, recBuffer, bufferSize, out dataSize, out error) This line is supposed to take in information from many different clients and sits within Update() function. I haven't actually started coding anything in yet... But the point is, if the clients are all transmitting data to the server at a rate equivalent to Update() then this line of code will not be able to (I think?) receive all of them at once (10 clients vs 1 server). So is there a way to not lose any of the incoming data and process them accordingly?
0
Improving the look of a character with solid parts inside a translucent jello exterior So my problem is a bit hard to explain. I have a character made out of a jello shell, with an internal skeleton. So let me introduce you to ma boi quot Chonker McJello quot The problem is, that I want a rich green slightly transparent jello, without loosing too much details and quot whiteness quot on the internal skeleton. If I turn the transparency or saturation of the jello down, the jello looks ugly, if I put the jello as I want, the Skeleton looses too much details turns green. I have thought of different approaches, but do not really know how to achieve the effect I want. Single sided emission Is there a way to make the jello glow internally and light the skeleton up? The emission should only come from the backfaces. Doing something with the render layers, like rendering the skeleton with transparency on top of the jello again, to make it appear quot less affected quot by it's color Everything I have in mind sounds easy but is propably pretty complicated and I don't have a lot of experience with shadergraphs and unity's hdrp. If you have any idea how to achieve the desired effect (maybe not in the way I thought) I would really appreciate your help! Thanks a lot!
0
How to make colliders for a darts board in Unity? I was wondering how to make a darts board in Unity? Of course it doesn't make triangular objects, or non symmetrical boxes as far as I know, so I would make the board mesh in Blender or something like this. But how would I be able to detect where a dart had hit the certain area? Until now I have only used box, sphere and capsule colliders
0
How can I convert screen space to GUI Space View Space? Is there any way available to convert screen space into view space as like in the following figure
0
How to create reel slider with mobile controls How can I create a reel slider with mobile game controls so that it looks something like this? The slider is normally non visible, and can be accessed if I slide my finger from the right side of the screen to the left. The slider allows me to switch my current weapon and use items in my inventory. This is my current setup in Unity. I can figure out the inventory portion of the slider, as there are many tutorials out there on an inventory system, and how to make the slider move based on touch, using something similar to a mobile joystick script, but I can't figure out how to make the slider so that it Can quot jump quot from icon to icon (not have the slider be completely fluid prevent it from stopping in between item icons) Detect what item slot the slider is currently on (in the case of the example, the item that will be used is the icon in the center of the screen. Make the icons more transparent the further away it is from the icon in use (I'm guessing that I would have to set the alpha channel value in the color settings of the item to a lower value, but I'm not sure how to detect the icon in use and count how many icons away the other icons are from the one in use.
0
Placing units on isometric map (2D) I'm making a map editor for further RTS game (2D), something like the first StarCraft Editor. Terrain tiles will be a rhombuses. So I'll probably just make an 2D array with intigers, that corresponds proper tiles. Then, after creating the terrain, you'd probably like to add some units and structures to map (especially if you're making a scenario). I'm not sure how do I check if the unit can be placed somewhere. I decided to make units almost independent from terrain tiles like in StarCraft (1), so the units are not placed in any grid. I'll give a simple image As you can see, those green tiles represent a passable area (grass, let's say), and a blue one impassable (for example water). That stickman in a box is our unit. You can place it only in green area. That means the box can't go outside the green rhombuses. I have some ideas how to achieve this, but I'm not sure which one would be the most optimal. 1) Since I work in Unity, I could add a collider to every tile. That will be very simple to do and will probably have terrible optimalisation in maps 256x256. 2) Math. I can calculate if any of those boxes crosses tile's borders. If so, I'll have to check if all those tiles are passable. It won't be that easy to programme (well, for me at least) and... yeah, here comes my dillema. Am I right that it would have much better optimalisation? Is it worth the effort? What about saving this map? I can easily save the array with tiles, but how can I do it with units? Just save their positions or is there a better way to do it? EDIT I've tested the first idea (I've written script to create 256x256 map that will be probably the biggest, and to move a camera). The map generates quite long (comparing to tiles without collider), but after that there isn't much difference in performance (it doesn't mean it won't cause problems when I add more features than moving a camera )). I can also attach colliders only to impassable tiles, not all. This should improve the performance even more. Still not sure if that's a good idea. EDIT 2 I've just realised how bad my idea was. Let me visualise this So if you consider not the whole rectangle, but only a circle, it's not only easier to implement, but also more reasonable. You can now convert rhombus' vertices' position from isometric to cartesian like B lint said CartX ( 2 IsoY IsoX) 2 CartY ( 2 IsoY IsoX) 2 You can also do it with circle's center point. Radius is equal to half of square (rhombus) side length OR sqrt(2) square side length (when square is inscribed in circle). So now I have a square grid and a circle. How can I check if all squares that this circle lays on are passable? What's the most optimal way to do it?
0
Applying movement to a Rigid Body Isometric in Unity 3D I'm making an isometric dungeon crawler. I initially used transform to get isometric movement and things worked well, but I couldn't use collision which meant it was unsuitable. So I'm now trying to use Rigidbody and I'm having some weird issues. First of all, this is the code I currently have public class CharControllerRigid MonoBehaviour SerializeField private Rigidbody characterRigid private Vector3 inputVector void Start() characterRigid GetComponent lt Rigidbody gt () void Update() inputVector new Vector3(Input.GetAxis("Horizontal") 10f, characterRigid.velocity.y, Input.GetAxisRaw("Vertical")) transform.LookAt(transform.position new Vector3(inputVector.x, 0, inputVector.z)) private void FixedUpdate() characterRigid.velocity inputVector I have two issues First, how do I get the movement to work on an isometric plain? Second, how do I get the movement to work in all directions? Current when I move left and right the movement is good, but up and down are really slow in comparison.
0
InvalidCastException when instantiating a prefab on the network using Photon As stated in the title, I get this error when I try to instantiate a game object using Photon InvalidCastException Cannot cast from source type to destination type. NetworkingPeer.DoInstantiate (ExitGames.Client.Photon.Hashtable evData, .PhotonPlayer photonPlayer, UnityEngine.GameObject resourceGameObject) (at Assets Photon Photon Unity Networking Plugins PhotonNetwork NetworkingPeer.cs 3069) PhotonNetwork.Instantiate (System.String prefabName, Vector3 position, Quaternion rotation, Int32 group, System.Object data) (at Assets Photon Photon Unity Networking Plugins PhotonNetwork PhotonNetwork.cs 2493) PhotonNetwork.Instantiate (System.String prefabName, Vector3 position, Quaternion rotation, Int32 group) (at Assets Photon Photon Unity Networking Plugins PhotonNetwork PhotonNetwork.cs 2437) GunController.EquipGun (.Gun gunToEquip) (at Assets Scripts Gun GunController.cs 38) GunController.init () (at Assets Scripts Gun GunController.cs 19) NetworkPlayer.Start () (at Assets Scripts Network NetworkPlayer.cs 20) Old, working code equippedGun Instantiate(gunToEquip, weaponHold.position, weaponHold.rotation) as Gun equippedGun.transform.parent weaponHold New code, using Photon equippedGun PhotonNetwork.Instantiate(gunToEquip.name, weaponHold.position, weaponHold.rotation, 1).GetComponent lt Gun gt () equippedGun.transform.parent weaponHold (I do GetComponent, as normal instantiate returns Object and PhotonNetwork.Instantiate returns GameObject) equippedGun is by default an empty variable of type Gun gunToEquip is again a Prefab variable of type Gun that gets passed into the function. (PhotonNetwork.Instantiate takes in the name of the prefab, not the actual prefab, thus gunToEquip.name) In this particular case, gunToEquip is the default gun that fails to instantiate, which is set by the unity inspector weaponHold is just a transform variable, again set by the inspector. I somehow managed to fix it for my player prefab, I have no idea how. I was just changing and reverting stuff until it magically worked. How can I resolve this error? Not sure if it is the problem, but I've attached the prefab settings
0
Working with Blender (Model individual objects or scenes?) I've been working in Unity for awhile but I'm pretty new to making my own models. I'm using Blender since it seems like a pretty good tool for the job. Let's say I am making a simple scene in Unity with a table that has a cup and plate on it and some chairs. Assume I want to be able to move each of these objects around independently from the other objects. Does this mean that when modeling in Blender, I have to model each object individually and import them separately in Unity? It would be nice sometimes to be able to model entire scenes in Blender, but if stuff in the scene isn't intended to be static, then there is no way to treat parts of these scene as objects and manipulate them individually in Unity right?
0
Trees swaying in the wind using Tilemap I am working on a top down, tile based game (think 2D RPG). However, I would like to have trees that sway in the wind and shake a little if the player bumps into them! How should I approach this? Is it achievable with trees that are composed of tiles and part of a tilemap? Or should I exclude my trees from the tilemap and turn them into game objects instead? If I were to turn them into separate game objects, would I then manually tweak their rotation position to achieve the sway and shake, or is there some form of shader I can use?
0
Disabling and re enabling the clicked child objects I am currently working on 2D platform game. The following script adding the child objects inside the array and identifies the child object I click on and checks the tag on it. Now I don't know how to disable the child object that I have clicked and I want the disabled child object to be re enable when I click on another child object inside the same parent object. Any help would be appreciated. public class SelectedPlatform MonoBehaviour public GameObject platform void Start() Transform children new Transform transform.childCount for (int i 0 i lt transform.childCount i ) children i transform.GetChild(i) void Update() if(Input.GetMouseButtonDown(0)) RaycastHit2D hit Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero) if(hit.collider.gameObject.tag "Platform") Debug.Log ("Target Position " hit.collider.gameObject.transform.position)
0
Unity procedural smooth normals I have a Unity project, which heavily relies on the marching cubes algorithm. Because this algorithm doesn't return the triangles in order, I can only index them in the order they are present in the vertices array. For example vertices Vector3(0, 0, 0), Vector3(1, 0, 1), Vector3(1, 1, 0)... triangles 0, 1, 2, 3... Because of this, Unity's RecalculateNormals method doesn't work properly and it gives me the following result Is there anyway I can make the normals smoother? Keep in mind, that I need to possibly recalculate these vertices everytime the values change, so I can't rely on very heavy methods.
0
Raycasting to AddForceAtPosition goes to the wrong direction I'm trying to get my coin object's Rigidbody to move whichever way it was swiped on by the user through RayCast void Awake() coinRigidBody coin.GetComponent lt Rigidbody gt () void Update() foreach (Touch touch in Input.touches) if (touch.phase TouchPhase.Began) firstTouchPos new Vector3(touch.position.x, touch.position.y, Camera.main.nearClipPlane) if (touch.phase TouchPhase.Moved) lastTouchPos new Vector3(touch.position.x, touch.position.y, Camera.main.farClipPlane) if (touch.phase TouchPhase.Ended) Vector3 firstTouchWorldPos Camera.main.ScreenToWorldPoint(firstTouchPos) Vector3 lastTouchWorldPos Camera.main.ScreenToWorldPoint(lastTouchPos) Vector3 diffWorldPos lastTouchWorldPos firstTouchWorldPos direction3D diffWorldPos.normalized power diffWorldPos.magnitude (force Time.deltaTime) Ray firstTouchRay Camera.main.ScreenPointToRay(firstTouchPos) Ray lastTouchRay Camera.main.ScreenPointToRay(lastTouchPos) RaycastHit hit Debug.DrawRay(firstTouchRay.origin, lastTouchRay.direction firstTouchRay.direction, Color.red, 50.0f) if (Physics.Raycast(firstTouchRay.origin, lastTouchRay.direction 100, out hit)) Vector3 hitLocation hit.point if (hit.collider.tag "Coin") projectedVector Vector3.ProjectOnPlane(direction3D, plane.normal) coinRigidBody.AddForceAtPosition(projectedVector power, hitLocation 5) throwCoinObject.throwWithForce(power, hitLocation, direction3D) The Code is working but my only problem is that it goes only in a certain direction? And it seems that direction is manipulated by how the camera is facing the objects. I just want it to hit the first touch origin then move to the direction the swipe was made. Help would be really appreciated
0
Animation doesn't play in one state I have created an Animator and two sprite based Animations. Both Animations preview correctly. In the Animator, I have created two states and two transitions between them based on a Boolean parameter. In the GameObject's script, the Boolean value is set based on distance to the player. When the player is far away Animation A plays and when the player is close Animation B plays. However, while the transition from Animation A to B happens correctly when the player gets close, I only see the first frame of Animation B and it doesn't animate. If while in Play mode I preview Animation B (using the Animation window controls), it animates correctly. Meanwhile, Animation A always plays correctly when it is supposed to. What could cause this behavior? How can I get Animation B to play during runtime and not just when previewing? What's going on? Edit Some screenshots. quot Saw slow quot is quot Animation A quot above, and quot Saw fast quot is quot Animation B quot . Animator Animator State Slow Animator State Fast Transition slow to fast Transition fast to slow Animation Slow Animation Fast The code is very simple bool trigger playerDistanceSqr lt (activeDistance activeDistance) animator.SetBool( quot IsFast quot , trigger)
0
Move gameobject from fixed position to pointposition following curve Unity2d I want to move the object from the fixed position to the mouse position according to the curve as shown in the illustration. The altitude is the same and the horizontal distance is equal.
0
Extending control remapping script to work with mouse buttons I have created a default key map for my game, however I have also included an option in the settings where the player can change the key bindings. My issue is if the player clicks on the button for shooting, which is defaults to mouse0, or aim on mouse1, then click on another key, they can never go back to mouse0 or mouse1. I am unsure of how to include all the mouse buttons scroll wheel into the viable buttons the player can choose from. Here is the part of my code that deals with the changing of the keys private void OnGUI() if(curKey ! null) Event e Event.current if (e.isKey) keyBinds curKey.name e.keyCode curKey.transform.GetChild(0).GetComponent lt Text gt ().text e.keyCode.ToString() curKey.GetComponent lt Image gt ().color normal curKey null
0
Unity Light Baking for Best Balance between Performance and Visuals I'm trying to optimize my Unity game. I have static objects, dynamic objects and (only) static lights. I wish to fully pre compute lighting and shadows for the static objects while still maintaining realtime lighting and shadows for dynamic objects, and making them work together seamlessly. From the documentation Realtime "Unity calculates and updates the lighting of Realtime Lights every frame during run time. No Realtime Lights are precomputed." So, If I set it to realtime, I'm not really optimizing anything, am I? Mixed "Unity can calculate some properties of Mixed Lights during run time, but only within strong limitations. Some Mixed Lights are precomputed." It's unclear what "some properties" are and what would the consequences be. Baked "Unity pre calculates the illumination from Baked Lights before run time, and does not include them in any run time lighting calculations. All Baked Lights are precomputed." This will work for static objects. However, dynamic objects will look as if there are no lights in the scene. From what I see, Mixed would be what I need, but I would still have to adjust its sub modes in the Lighting window which is non trivial for me Subtractive Its description suggests it would solve all my problems and still be a nice optimization. However, static objects don't seem to receive dynamic objects' shadows or the other way around either. Baked Indirect, or Shadowmask Does not seem to pre compute direct lighting for static objects, throwing away performance gains. The final question is what method will lead me to the best performance in Unity with these requirements There are static and dynamic objects that both need to be lit by direct lighting Both static and dynamic objects should be able to cast and receive shadows from each other All lights are static Indirect lighting is not important in this case
0
Unity transform.position question Looking at example code for mesh deformation in unity https answers.unity.com questions 746673 sine wave mesh deform with different directions.html And i see theyve used public Transform Target1 public Transform Target2 void CalculateWaves () waves 0 .Direction Target1.position transform.position waves 1 .Direction Target2.position transform.position And i dont understand the difference between Target1.position and transform.position without any reference to an instance. Arent they the same thing. And how does transform.position function without a reference.
0
Can a Game Engine be built into a Game Engine? This confuses me as the title says "Mostly Civilized A Hex Based 4x Game Engine for Unity Part 1" Unity is a Game Engine, and he is building a game engine for a game engine. Did he word this incorrectly, or is building a game engine into a game engine a real thing?
0
Array but with a name for every element (value) Say I have 10 different types of grenades, I would like to create one variable, to allow me to set the number of grenades given from the inspector, I could create an array with 10 integers and set the number of grenades there, however it would be much easier for me if every element of the array (10 in total) had a name next to its value in the inspector so I could clearly see which grenade type am I assigning the value. Is there any variable type or something that would allow me to do this? If so what is it? And how can I create what I want? Thanks in advance! If more information better explanation of some aspect is needed ask.
0
Weird windowed resolution can't seem to change without changing the name My game is windowed, and when I set the resolution in the build settings (960x540 16 9 Windows standalone), and build it, it works as intended, but from then on, I can no longer change the resolution (can change it in the editor, and it also saves, but when I build it, it is still the original res (960x540))unless I change the Product Name as well. When I change the product name, I can change the resolution, build it, and it will change, but then it is stuck as well. When I change back to the first name, the resolution automatically change it the resolution for the first name (960x540) (it doesn't show up in the editor, only when you build it.) So basically Name1 960x540 Name2 1280x720 Name3 1024x576 etc So you can change the resolution every time you change the name and build it, and that name is stuck with that resolution (no matter what you change it to in the editor later). I am fairly new with unity, so am I missing something very basic here? Thanks for any help!
0
score and high score system for multiple levels I'm trying to create a scoring system for a game with multiple levels. For this I'm using the binary formatter instead of playerprefs (I read online that playerprefs are not that secure). I have created the system but whats happening is that the score is not resetting to 0 when I load a new level. If in one level the score was 10 and I start some other level, the score in this level starts from 10 instead of 0. This is the code I have so far public class ScoreIncrease MonoBehaviour public Text scoreTxt public int score void Start() LoadScore() void Update() if (Input.GetKeyDown(KeyCode.Space)) Save() public void Save() score scoreTxt.text "Score" score BinaryFormatter bf new BinaryFormatter() FileStream file File.Open(Application.persistentDataPath " scoreContainer.dat", FileMode.Create) ScoreContainer scoreContainer new ScoreContainer() scoreContainer.score score bf.Serialize(file, scoreContainer) file.Close() public void LoadScore() if(File.Exists(Application.persistentDataPath " scoreContainer.dat")) BinaryFormatter bf new BinaryFormatter() FileStream file File.Open(Application.persistentDataPath " scoreContainer.dat", FileMode.Open) ScoreContainer scoreContainer (ScoreContainer)bf.Deserialize(file) file.Close() score scoreContainer.score scoreTxt.text "Score" score Serializable public class ScoreContainer public int score How can I change this so that each level has a separate highscore and all levels have a start score of 0?
0
Unity map size limit? Does Unity have a map size limit and if there is what is the limit? Is there a way to work around it? I am making a open world zombie survival world and I want to make a really big map. Thanks!
0
Which image effect is this? This is a screenshot from RE7. I have once seen the same image effect in Unity, but I don't remember the name I'm not talking about AA or DOF here, I mean this grainy greenish thing, I don't know how to describe it... At first I thought the name was something like quot Anisotrophic filtering quot , but that didn't bring up anything that looked like it. Can anybody tell me the name of the effect that I see here? Edit It can be seen in the start screen of this video, too https www.youtube.com embed aaN3MNb9ij0?feature oembed Both screenshots look pretty similar to me, so I guess it's the same effect? Edit 2 The pixels seem to shift into red blue the closer they get to the edge of the screens. I have drawn red arrows to region where this effect is very visible to me. These pixels appear as quot shifted quot to me. I think this effect is more visible at the edge of the screen. Thank you.
0
C Unity Getting which function affects a GameObject I have this little code that moves a GameObject over time public void Move(Transform from, Transform to, float overTime) StartCoroutine( Move(from, to, overTime)) IEnumerator Move(Transform from, Transform to, float overTime) Vector2 original from.position float timer 0.0f while (timer lt overTime) float step Vector2.Distance(original, to.position) (Time.deltaTime overTime) from.position Vector2.MoveTowards(from.position, to.position, step) timer Time.deltaTime yield return null Which is easy as it is, I plan to use it for UI animations. However, things get interesting when I wish to use this for a bit more complex animations, or I want it to stop upon restart. More complex animations I click a button which then moves to the side and bounches back. For this I need to know when the exact same method finished moving the button so I can restart it to bounce back. Stop upon restart Say I hover my mouse over a button which moves then. However, if it's still moving, I want its current animation to stop, and a new one to start. For both of these I need to know which function affects which GameObject so I can manage that. Question is, how? Shall I use one script on each of the animated components which affects only that one? Or if I could use only one script on the whole Canvas, then how?
0
Unity Android Immersive mode leaving a black bar in the soft key area? The black bar is not hiding anything. Everything is drawn above it. But the black bar is there in place of the soft keys even when they are hidden. I don't know how to hide it and render using whole screen. The bar is only visible with device having soft keys not for device with physical keys. I have set the Screen.fullScreen true. Unity 2018.3.4f1
0
Need help with using Player Prefs to save number of coins collected I'm using unity 3D to make a game where the character collides with coins in order to collect them. When playing the game, the player should start out with zero coins and each time he collides with a coin, the amount should increase by one. On a main menu scene, the total number of coins (that have been collected across multiple games) should be displayed. The total number of coins is being displayed on the main menu but once in the gameplay scene, the total number of coins is being displayed there too (where it's supposed to start at 0 and then increase by 1 each time a coin is collected). Here is the script I use for when the player collides with a coin using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class CoinScript MonoBehaviour void OnTriggerEnter(Collider target) CoinScoreManager.coinAmount 1 Destroy(gameObject) Here is the script I use to manage the UI and coin number in the game play scene using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class CoinScoreManager MonoBehaviour public static int coinAmount public Text coinText void Start() coinAmount PlayerPrefs.GetInt( quot CoinAmount quot ) void Update() coinText.text coinAmount.ToString() PlayerPrefs.SetInt( quot CoinAmount quot , coinAmount) Here is the script I use to manage the UI and total coin number in the scene with the main menu using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class MainMenuController MonoBehaviour int coinAmount public Text coinAmountText void Start() coinAmount PlayerPrefs.GetInt( quot CoinAmount quot ) void Update() coinAmountText.text coinAmount.ToString() I think the problem is in the second script shown above. In the Start function I'm calling the coinAmount which is the same variable used to show the total coin number. I think that's the problem but I'm not really sure how to fix the problem as I'm still kinda of new to Unity and programming. Please let me know if there's anything else you need to know about the game in order to figure out how to fix this. Thanks for your help!
0
Unity3d 2017 trail renderer behaving weird Please see the screenshot I attached, I am trying to make skid marks using trail renderer, but one side of trail is going upwards just after it renders, it was working fine Unity 5.4, but when I upgraded it to 2017, it is behaving like this.
0
C (Unity) Use a method common to multiple classes with the same base class The Problem I'm building one of those empire kingdom building games and so I am trying to create an efficient way of making a "ResourceManager" class handle the games resources (wood, food, iron, stone). I currently repeat a function 4 times to do the same thing. Attempt 1 I created a "Resource" class (abstract) and derived the four resources from it. In each resource there are multiple methods which are similar Example Food.CS new public static void AddResources(int amount) Player.currentFoodSupply amount foodText.text Player.currentFoodSupply.ToString() Compare to Iron.CS new public static void AddResources(int amount) Player.currentIronSupply amount ironText.text Player.currentIronSupply.ToString() The AddResource() function is static because I have other scripts (like buildings, when they get upgraded) needing to communicate with each resource. The base building class currently has a method like this public void DeductResources() Food.DeductResources(FoodCost) Wood.DeductResources(WoodCost) Iron.DeductResources(IronCost) Stone.DeductResources(StoneCost) This seems like it's so repetitive that there needs to be a more efficient way to do this. Attempt 2 A "ResourceManager" class that anything to do with the 4 resources can go through this one script. I can update that one script instead of numerous scripts that does something with the resources. Where I am undecided is this one public static void DeductResources(Resource resource, int amount) if(resource.GetType() typeof(Food)) Player.currentFoodSupply amount resource.resourceText.text Player.currentFoodSupply.ToString() else if (resource.GetType() typeof(Wood)) Player.currentWoodSupply amount resource.resourceText.text Player.currentWoodSupply.ToString() else if (resource.GetType() typeof(Iron)) Player.currentIronSupply amount resource.resourceText.text Player.currentIronSupply.ToString() else if (resource.GetType() typeof(Stone)) Player.currentStoneSupply amount resource.resourceText.text Player.currentStoneSupply.ToString() It looks like it works and I can't see a way around calling the above method 4 times as I need to know how much food or wood to add or deduct. Does anyone have any suggestions please on how to improve this code call the method once? I'm always willing to learn! Thank you
0
Slow down in the same time over different distances I'm trying to slow down a object over different distances in the same time, say 3 seconds. My slow down code is. function lerpSpeed (speed float, lerpSpeedTime float) incomingFlightSpeed flightPathScript.flightSpeed i 0 while(i lt 1) i Time.deltaTime lerpSpeedTime i Mathf.Clamp(i, 0, 1) flightPathScript.flightSpeed Mathf.Lerp(incomingFlightSpeed, speed, i) yield So I call it with. waypointScript.lerpSpeed(1,(totaFlighpointsDistance flightSpeed)) In the picture below I've draw a bezier curve and at the last 8 flight points (the red and yellow spheres) I want to start the slow down from the yellow sphere to the last red sphere. I get the distance in between each of the last 8 flight points and total them up to give me the total distance, I understand to get the time it will take to travel that distance is time total distance speed, but as I'm slowing the speed in my function above this will not work. And because every bezier curve I generate is different, some stretched out, with total distances sometimes ranging from 30 to 8. So I'm a bit stuck here, thought I'd get this one, but unless I'm missing something simple I can't get my head around it, so any help would be greatly appreciated, thanks.
0
How to prevent a cube from falling through a plane in Unity I am trying to prevent a player cube from falling through the plane (Battleground) in Unity, but after adding Mesh collider to both the cube and plane, as well as adding a rigidbody, nothing seems to work. The only way I can prevent this from happening is by locking the y axis of the cube, but this is a problem because I am adding in a jumping ability, and the player needs to be able to fall of the map. Is this something I can do within the Unity editor, or do I need to make a script that does that. To verify, all 3 colliders have "Is Trigger" Enabled, the platform is not designed to be moved, so the X, Y and Z of both the plan's rotation and position are locked, and the material for the colliders are all default. Each of the cubes and the plane's material are custom (Not the collider's material). The X, Y and Z of the cube's rotation are locked. Both cubes have the tag 'player' The code for player movement is using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMove MonoBehaviour private Rigidbody rb Use this for initialization void Start() rb GetComponent lt Rigidbody gt () Update is called once per frame void FixedUpdate() float h Input.GetAxis("Horizontal") 5 float v Input.GetAxis("Vertical") 5 Vector3 vel rb.velocity vel.x h vel.z v rb.velocity vel
0
Are there performance benefits to using WaitForSeconds vs checking elapsed time in FixedUpdate in Unity? I was considering that perhaps just checking the time and then doing some work in the Update function might look cleaner than calculating how long to wait for and calling yield new WaitForSeconds() on two interleaving processes, so I became curious whether there is a huge difference between the two options. Doesn't WaitForSeconds just work by calling an iterator after a certain amount of time has elapsed? So I assume that a timer is checked on each update, and when the time has elapsed, the IEnumerator's movenext function is called. However, I thought it couldn't hurt to ask someone just in case there is some huge difference in performance.
0
How to implement Microwave Signals in Unity? I need to implement microwave signals for object detection in Unity. I know there are raycast sensors in Unity, but can microwave signals be simulated or can a proxy of microwave signals be created in Unity using the raycast sensors?
0
Setting up a shader for RTS construction grid visibility (around cursor) I've set up a shader, thanks to the good help of DMGregory over at Draw animating grid with terrain deformation and variable colors here's what I got so far here's what it's supposed to look like here's what my shader code looks like as it stands forgive my non 2K screen it's only a 1080p but this is the full shader. here's each bit in isolation here's the main options for the node If I set surface to transparent... I get a much better result yet still not what I want because the grid area fades out immediately instead of staying at the center of the cube also the corner clearly has a green and red line overlap when line should only ever be red or green. this is the mock file that I'm currently using for buildable and non buildable area it's 256x256 (the size of my map) for now because I want to start small (where 1px maps to one unity square on the terrain of 1 unit) before I move on to the real deal which should be a 3584x3584 Texture 2D (where 1px corresponds to 1 14th of a unity unit). I want my grid to be 1 14th of an digit. eg cell one is (in diagonal) from (0.0f, 0.0f) to (0.14f, 0.14f). I've got preliminary code which will serve to generate this texture 2D programmatically editable2DconstructibleMap new Texture2D(256, 256, TextureFormat.RGBA32, false) constructionGrid GameObject.FindGameObjectWithTag( quot GridViewer quot ).GetComponent lt MeshRenderer gt () fill texture color corresponding to navMesh for (int x 0 x lt editable2DconstructibleMap.width x ) for (int y 0 y lt editable2DconstructibleMap.height y ) NavMeshHit hit if (NavMesh.SamplePosition(new Vector3(x 1.0f, 0f,y 1.0f), out hit, 1.0f, NavMesh.AllAreas)) editable2DconstructibleMap.SetPixel(x, y, Color.white) else editable2DconstructibleMap.SetPixel(x, y, Color.black) constructionGrid.sharedMaterial.SetTexture( quot BuildableMask quot , editable2DconstructibleMap) Here I'm using the navMesh which itself is automatically generated based on terrain slope. I target each point of the map and see if it falls in or out of the navmesh. Instead of redrawing this texture 2D when a building is placed and placement becomes impossible. I think I'll simply programmatically edit the 2D texture to add the new black pixels whilst the navmesh will be updated independently. Anyways, I guess the green red overlap issue comes from my texture2D being currently too small, but if I don't know yet what one pixel corresponds to, I'll have trouble getting this right. Update so changing the texture to one of 3584x3584 did not help. I still have the exact same behavior. So basically what did I get wrong in following the instructions from the other answer?
0
Prevent Unity click go trough Canvas I'm currently facing this problem If I click on a Button on my Canvas, the currently selected Unit moves towards the location under the Button. Is is there any option to solve this? I'm using the A Project for this. Sadly, I can not provide a lot of things I've done so far as I absolutely have no clue how to solve this problem. If I disable the Button Option "Raycast Target" ist still moves to this position but holds a bit earlier. Also, adding this as check didn't work if (!EventSystem.current.IsPointerOverGameObject() ) I also checked if the Raycast hit's the layer of the GUI My Movement code so far public override void MouseClick(GameObject hitObject, Vector3 hitPoint, Player controller) base.MouseClick(hitObject, hitPoint, controller) if (hasAuthority amp amp player amp amp player.human amp amp currentlySelected) if (hitObject.name "Ground" amp amp hitObject.name ! "UI" amp amp hitPoint ! ResourceManager.InvalidPosition) float x hitPoint.x float y hitPoint.y player.SelectedObject.transform.position.y float z hitPoint.z destination new Vector3(x, y, z) Debug.Log("Start Move") StartMove(destination)
0
How manage multiple images in Unity? I'm new in Unity and creating a game. So I have a class PicManager in which I have to load my images(sprites) from assets into a List and then use them in my game. What is the proper way to load multiple images from a folder in Assets? I know, that I can use Sprite sprites Resources.LoadAll lt Sprite gt (texture.name) But this article of Unity says not to use Resource folder.
0
Processing Vs Memory Optimization I'm creating a game with a lot of elements. Should I store all components that I'll eventually access on class variables (memory) or should I access them when running the script(processor)? Example private SpriteRenderer sprite void Start () sprite GetComponent lt SpriteRenderer gt () public void StartMovement() sprite.doSomething() VS void Start () public void StartMovement() GetComponent lt SpriteRenderer gt ().doSomething()
0
how do I instantiate a prefab that adds to the score text in c ? Hello I'm working on a game with random generation, a dungeon crawler of sorts. i need to be able to have an object that when instantiated, adds to the score(the goal is to find all of them as the dungeon is created around you)this is the script for the orb cube. public Text score public int scores Use this for initialization void Start () scores score.text scores.ToString() public void Update() score.text scores.ToString() public void OnMouseDown() Destroy(gameObject) scores when an object is added it won't add to the score.
0
Turning around an enemy when hitting a wall or after x time I have an enemy that is supposed to go in one direction and after hitting the wall or if a certain amount of time passes, it should turn around and go back. After hitting another wall, it should turn around again and keep doing this in a loop.
0
Is it allowed by social platforms to promote a game in exchange for in game currency? I have a mobile game that uses a a hint system. If the user needs help to solve a puzzle they can get a hint by watching an ad. I'm interested in offering some hints, let's say 5, if the user presses a Facebook Twitter button and posts some predefined text on those platforms something like quot I've been playing X game, check it out quot . I haven't seen many games that have something like this. For those more familiar with App Store and Play Store publishing guidelines, is there anything against such behaviour?
0
Unity2D jumping inconsistancy I'm tinkering with a unity2D sidescroller, and am trying to make a player controller to jump. However, when I tell my character to jump, it sometimes jumps twice the distance, and I don't know why. Below is my controller script using System.Collections using System.Collections.Generic using UnityEngine public class PlayerMovement MonoBehaviour public float playerSpeed 10 public float jumpForce 20 private bool ableToJump false public GameObject groundCheck place an empty object slightly below the character where it will collide with any ground Update is called once per frame void Update() if (Input.GetKey("space") amp amp ableToJump) ableToJump !ableToJump GetComponent lt Rigidbody2D gt ().AddForce(new Vector3(0,1,0) jumpForce) if (Input.GetKey("a")) transform.Translate( playerSpeed Time.deltaTime, 0, 0) if (Input.GetKey("d")) transform.Translate(playerSpeed Time.deltaTime, 0, 0) The player is grounded if a linecast to the groundcheck position hits anything on the ground layer. ableToJump Physics2D.Linecast(transform.position, groundCheck.transform.position, 1 lt lt LayerMask.NameToLayer("Wall")) Here is the glitch as it appears when I am previewing the game (watch how the third jump seems to be twice as high). There is no consistency to when it occurs, but it has occurred any time between two in a row and 10 12 between times it happens. I have tried long versus short presses of the jump key (space bar), moving versus standing still, and jumping on different locations. I have also tried disabling animations and waiting between presses versus pressing and holding space, versus pressing space rapidly. The only consistent thing is that sometimes I jump about three blocks (200 x 200px each) high, and sometimes I jump about six blocks high. Any tips are appreciated. Thanks!
0
How to move a player (with camera) towards a target object until camera fill target object? I'm trying to solve this 'algorithm' problem. I have a player and a camera on it. I want to automatically move this player towards a target object and stop it when target object completely quot fit quot my camera. So my question is how can I find target Vector3 player position, and camera rotation (up down) to perfectly quot view quot an object ? Consider that my target objects are simple Box. Thanks Edit X is the quot right quot transform.position to quot full quot see target object
0
Moving panel between two positions smoothly? I'm trying to make my panel moving from one position to another one smoothly. What I get is more faster no matter what I did to make it slower never get slow !! Both Vector3.Lerp and Vector3.MoveTowards did not give me a slow movement. Here is my script public GameObject gunsWindow private Vector3 a, b public bool open use inspector void Start() a gunsWindow.transform.position b new Vector3(100.0f, gunsWindow.transform.position.y, gunsWindow.transform.position.z) void Update() if(open) gunsWindow.transform.position Vector3.MoveTowards(a, b, Time.deltaTime 1) weaponPlane.transform.position Vector3.Lerp(a, b, Time.deltaTime) panel shaking else gunsWindow.transform.position Vector3.MoveTowards(b, a, Time.deltaTime 1) weaponPlane.transform.position Vector3.Lerp(b, a, Time.deltaTime) shaking
0
Unity 3D rotating object around 2 axes rotates it around 3 I am developing a 3D space shooter and I've fount that when triying to rotate the ship using X and Y axes it also rotates on the Z axe. The answer here helped me a lot, but now when I try to rotate on 3 axes I have the same problem on the 2 axes sharing local space. The code I have right now is this float rotZ 1 float rotLeftRight Input.GetAxis("Mouse X") mouseSensitivity float rotUpDown Input.GetAxis("Mouse Y") mouseSensitivity transform.Rotate(0, rotLeftRight, 0, Space.World) transform.Rotate( rotUpDown, 0, 0, Space.Self) transform.Rotate(0, 0, rotZ, Space.Self) Anybody knows how to make all 3 rotations independent from each other? Thanks!
0
How to force Game Center submit score failure What would cause a failure to report a score to a Game Center leaderboard? Currently, score reporting succeeds almost all the time, so I'm trying to force failure so I can fix it. The Game Center documentation says it would fail to report a score if there are network issues. Are there any other scenarios where reporting a score would fail? I'm using Prime31's Game Center plugin for Unity3D.
0
OpenXR device not present in Start or Awake methods in Unity C script I'm developing a VR game using OpenXR in Unity (specifically developing on a Valve Index). When I try to access the input devices through the InputDevices.GetDevices() function, I get 0 devices back when I call this function from my script's Awake() or Start() methods. But when I call the same function from my script's Update() method, I see all the devices (e.g. head set, left controller, right controller). Why can't I see the devices in the Awake() or Start() methods?
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
Is there a difference between using one large mesh with 100k polygons and using 1000 meshes with 100 polygons each? I'm planning on creating a first person shooter for mobile. Now I know that fps games usually have a lot of meshes in the scene (trees, buildings, terrains, etc.). So I've been looking at a lot of Unity optimization tips. One thing I've noticed is that they always say "If you have a lot of objects in your scene, then each mesh must have low polygon count". But how exactly does this help? If I have a lot of houses in my scene and I ensure that each house has very few polygons, wouldn't the total number of polygons in my scene be affecting the performance anyways? Or will my scene be rendered differently now that I've broken up the total polygon count into multiple parts?
0
How can I scale my UI elements to the lesser screen dimension in Unity 5? I want to create a custom mobile pad for my game. The mobile pad consists of two parts (both inside an ui canvas) The D Pad, which will be anchored to the bottom left side. The button group will be anchored to the bottom right side. I would like to resize the element on different resolutions, so that the element (in my case, the D Pad is an image) Has a size of 20 of the minimum of the width and the height. Has pivot of x 0.5, y 0.5. Having anchor of left bottom, its coordinates are (15 , 15 ) wrt the minimum of the width and the height. What I tried is to use an Aspect Ratio Filter in the D Pad image with ratio 1, but it did not work as intended (the coordinates led the image to an unexpected place). Note I am a n00b to Unity. I don't know whether it is right but my Canvas Scaler scales by Constant Pixel Size These images should illustrate what I want to achieve What should I do to make it work like in the pictures? Edit I attached this behavior, based on answer, to handle the change by runtime RequireComponent(typeof(UI.CanvasScaler)) class CanvasSmartScaler MonoBehavior private CanvasScaler scaler void Start() scaler GetComponent lt CanvasScaler gt () void Update() OMITTED CODE here I set the scale mode as in the Editor but right now i am in my mobile device and cannot remember the exact lines if (Screen.currentResolution.width lt Screen.currentResolution.height) scaler.matchWidthOrHeight 0 else scaler.matchWidthOrHeight 1 And attached that behavior to the canvas. However, for my debug exe (just for debug purposes) it always picks the 1 case regardless how do I resize the window. What am I missing?
0
Unity scene performance better to use one scene and toggle what is active? Unity scene performance questions In Unity, were one to have a scene that is basically identical in all but a few ways, would it be better to keep them as separate scenes, or to have them be one scene and have a script run during init to make all the modifications? Such as change the ground material from green to white to make it snowy, and such? If you went the separate scene route, would that drastically bloat the project? would all things be stored twice?
0
Unity Determine direction vector3 from a point in space and an angle in eulers I have a ball positioned as Vector3(x, x, x). I was able to get the direction of the ball to the mouse clicked position with Code (csharp) Vector3 direction Direction (clickPos2 startPos) Where the method is Code (csharp) public Vector3 Direction(Vector3 position) return new Vector3(position.x Length(position.x, position.y), position.y Length(position.x, position.y), position.z) Now I have an angle in eulers and I want that the ball goes to the direction of the angle. But how I calculate it? The game is played in 2d so actually only x and y is needed, z stays the same. Mirza
0
Scaling HUD and Camera I wanted to display an HUD, similar to the strategic games' one (like in DotA 2, Warcraft III, Starcraft II or Age of Empires). I didn't really know how to do it, so I managed to create a Texture Object and placed it in front of the scene. The image attached is the HUD itself, with some transparent "holes" in which I placed the cameras. I don't know if this description explains well what I'm trying to say, so I made this screenshot The HUD is just a png image with a greater z index. The image has three "holes" one for the gameboard, one for the dice, and one for the spells you can see on the right. The holes are filled with the cameras, so we can see the objects beyond the transparency. Everything looks quite nice. But if I change aspect ratio (which was Free Aspect), my layout gets completely screwed up. Notice that the HUD borders are not fully displayed the spells on the right are misplaced, and so are the dice. I managed to get the free aspect resolution, it is 1440x720, a perfect 2 1. But, even if I change my resolution to 800x400, things are not getting better. I've read something about pillarboxing and letterboxing, but I'm not sure that those techniques will help me with this issue. Is there something I can do to resize my objects and my cameras dynamically to fit the screen for every resolution like in the first screenshot? Of course, if you have any other solutions for the HUD, I'll be glad to learn!
0
Simulate wind in a powder game I would like to create a game similar to powder game. I've got a 2d array that stores different types of powder such as sand, water, gas, and fire. I've managed to get these to all move around successfully. I would now like the powders to react to wind. For example if there is fire it should push air upwards. If the air is moving upwards it will move other bits of powder around. The way I've been trying is to have two more 2d byte arrays. One for the wind x direction and another for the wind y direction. The fire will then add an amount to the cells and each update will add the wind x and y to the piece of powder that is on that cell. This almost works but pushes the powder much to fast. The difficulty in doing this is that the powder is on a grid while the wind could be going a variety of directions. What is the most efficient way of doing this?
0
Recognize hand drawn shape I want to ask player to replicate a simple shape (triangle, square, star, anything that can be done in single stroke) with mouse or on a touchscreen. Orientation matters, size does not. Example Can anyone give me directions to what techniques can be used?
0
Both Trigger and Collision BoxCollider2D My Player sprite needs to collide with some objects and be unable to pass through them and in other cases detect when it passes through some object (e.g. some non fatal enemies and some one way barriers). How do I test what an object is and make enforce one collision type or the other?
0
What causes this z position change? This is a follow up on the following thread. I'm applying a code that will move an object just outside the camera's frustum. I have used the same code in other projects, and it worked fine. However, I'm using it with URP now, and I'm experiencing a z position change while I expected only a x position change. And I just don't see why it does that. I have recorded a video here. If I press the button, the cube should be moved to the left only. But it also moves to the back (z position). And this is the script that I have applied to the cube in the video using System using UnityEngine public class PlaceOutsideCamera MonoBehaviour public void PlaceOutsideFrustum(Transform uTransform, bool uLeft) uTransform.position pPlaceOutsideFrustum(uTransform, uLeft) public static Vector3 pPlaceOutsideFrustum(Transform uTransform, bool uLeft) var frustumPlanes GeometryUtility.CalculateFrustumPlanes(Camera.main) Ray ray Plane plane if (uLeft) 1. ray Camera.main.ScreenPointToRay(new Vector3(0, Camera.main.pixelHeight 2f, 0)) plane frustumPlanes 0 else ray Camera.main.ScreenPointToRay(new Vector3(Camera.main.pixelWidth 1, Camera.main.pixelHeight 2f, 0)) plane frustumPlanes 1 float fDistance Mathf.Abs(Camera.main.transform.position.z uTransform.position.z) 2. var borderPoint ray.GetPoint(fDistance) 3. var frustumOutside plane.normal Bounds b BoundsFromTransform(uTransform) 4. var halfDiameter b.size.magnitude 2f return borderPoint frustumOutside halfDiameter public static Bounds BoundsFromTransform(Transform uTransform) try Bounds bounds new Bounds(uTransform.position, Vector3.zero) wir h tten auch einfach new Bounds() nehmen k nnen, meint Manfredas foreach (Renderer renderer in uTransform.GetComponentsInChildren lt Renderer gt ()) bounds.Encapsulate(renderer.bounds) Vector3 nOff bounds.center uTransform.position return new Bounds(nOff, bounds.size) catch (Exception ex) UnityEngine.Debug.Break() return new Bounds() public void OnGUI() if (GUI.Button(new Rect(0, 350, 100, 50), "DoThis!")) pDoThis() private void pDoThis() this.PlaceOutsideFrustum(this.transform, true) Can anybody tell me why my code does this? I just don't see it. Thank you very much for the help! Edit Here is another video that shows the camera position in the Inspector.
0
Best Practices for Locating Clicks I am building a 2D board game in Unity with a static camera pointed down at the game board. During the active phase of each player's turn, I want to detect where they click on the board. Fortunately, the board is laid out in an easy rectangular grid. (Essentially a trio of 5x5 grids). Which of the following would be best practice to implement this? Create invisible colliders for every square on the board and create a translation function that translates those back to board positions (5,3) with Raytracing? Get the translated coordinates of the click and use a function to figure out which square (if any) the click is in using the mouseclick event handler (by calculating which square the grid coordinates fall in)? Make each square a button with its grid identity encoded and use that in its OnPressed function? Edit 4) Some other idea I haven't thought of yet? Experience level I'm just learning Unity, but have written a lot of C (and tons of other code).
0
Unity can't build AssetBundle for iOS From http docs.unity3d.com ScriptReference BuildPipeline.BuildAssetBundle.html, I am using the sample code using UnityEngine using UnityEditor public class ExportAssetBundles MenuItem("Assets Build AssetBundle From Selection Track dependencies") static void ExportResource () Bring up save panel string path EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d") if (path.Length ! 0) Build the resource file from the active selection. Object selection Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets) BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies BuildAssetBundleOptions.CompleteAssets) Selection.objects selection MenuItem("Assets Build AssetBundle From Selection No dependency tracking") static void ExportResourceNoTrack () Bring up save panel string path EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d") if (path.Length ! 0) Build the resource file from the active selection. BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path) To build an AssetBundle. However, whenever I run this on a prefab, I noticed that Unity switches the platform to WebPlayer and THEN builds the bundle. But I need the AssetBundle to be built for iOS and Android I don't need WebPlayer bundles. Why does it keep switching to WebPlayer platform whenever I run this? How can I build for iOS and Android? My prefab is just an object with a Sprite Renderer.
0
Mesh contents get flipped I am using below shader with my mesh object that is showing a webpage. It is showing fine but the problem is the web page has flipped Shader quot UI Default OverlayNoZTest quot Properties PerRendererData MainTex ( quot Sprite Texture quot , 2D) quot white quot Color ( quot Tint quot , Color) (1,1,1,1) StencilComp ( quot Stencil Comparison quot , Float) 8 Stencil ( quot Stencil ID quot , Float) 0 StencilOp ( quot Stencil Operation quot , Float) 0 StencilWriteMask ( quot Stencil Write Mask quot , Float) 255 StencilReadMask ( quot Stencil Read Mask quot , Float) 255 ColorMask ( quot Color Mask quot , Float) 15 SubShader Tags quot Queue quot quot Overlay quot quot IgnoreProjector quot quot True quot quot RenderType quot quot Transparent quot quot PreviewType quot quot Plane quot quot CanUseSpriteAtlas quot quot True quot Stencil Ref Stencil Comp StencilComp Pass StencilOp ReadMask StencilReadMask WriteMask StencilWriteMask Cull Off Lighting Off ZWrite Off ZTest Off Blend SrcAlpha OneMinusSrcAlpha ColorMask ColorMask Pass CGPROGRAM pragma vertex vert pragma fragment frag include quot UnityCG.cginc quot struct appdata t float4 vertex POSITION float4 color COLOR float2 texcoord TEXCOORD0 struct v2f float4 vertex SV POSITION fixed4 color COLOR half2 texcoord TEXCOORD0 fixed4 Color v2f vert(appdata t IN) v2f OUT OUT.vertex mul(UNITY MATRIX MVP, IN.vertex) OUT.texcoord IN.texcoord ifdef UNITY HALF TEXEL OFFSET OUT.vertex.xy ( ScreenParams.zw 1.0) float2( 1,1) endif OUT.color IN.color Color return OUT sampler2D MainTex fixed4 frag(v2f IN) SV Target half4 color tex2D( MainTex, IN.texcoord) IN.color clip (color.a 0.01) return color ENDCG I am using above shader so that the mesh should be shown on top of everyting.
0
How can I create a walking zone logic for my player? First I will show a screenshot and explain the logic I think of and what I'm trying to do In the diagram the circle is the player the big rectangle is the zone area for increase decrease speed movement of the player and the small black rectangle is the target. What I'm trying to do is to add some rules for this case. I'm controlling the player in third person movement with the keys WSAD and the mouse to rotate around looking around. This is the player structure screenshot in the Hierarchy There are few rules I'm trying to set for the player in this specific situation in the game and I want to make it generic so I can add the rules or create this behaviour in any place in the game when I need to. The idea is when the player is getting inside the green zone rectangle facing the target make the player slow down to stop smooth. The green zone is the distance from the target to start slow down only if the player is facing the target. If I rotate the player back facing away from the target in the green zone at any time increase the player speed back to normal speed. The idea is that if in the green zone I rotate the player at any time and move hi he will decrease increase the movement speed. Facing target decrease slowly to stop facing away from target increase the speed slowly to normal.
0
How to create a line renderer with end point as the mouse position, but with a fixed direction I have two objects with a line going from one to the other, like this I want to create another line with a starting point one of the objects and an end point the mouse position, however still facing the second object, which will look like the first line is filling up to where the mouse is. For example, I want to connect the blue shape with the green shape, so I move my mouse from one to the other. The game finds the nearest white line from the cursor and creates another line on top of it that follows my cursor, like this The current script is this. It draws a line from the origin shape to the mouse position, but it doesn't stay on only one direction and instead moves where my mouse goes public class SelectionLine MonoBehaviour private LineRenderer lineRenderer private void Awake() lineRenderer GetComponent lt LineRenderer gt () private void Update() if (ShapeSelection.instance.selectedShape ! null amp amp ShapeSelection.instance.draggingFinger ! null) var originPosition ShapeSelection.instance.selectedShape.transform.position var destinationPosition ShapeSelection.instance.draggingFinger.ScreenPosition lineRenderer.SetPosition(0, new Vector2(originPosition.x, originPosition.y)) lineRenderer.SetPosition(1, new Vector3(ShapeSelection.instance.draggingFinger.GetWorldPosition(1f).x, ShapeSelection.instance.draggingFinger.GetWorldPosition(1f).y, 0)) There is no way (as far as I know) to set a direction of a line renderer in Unity, so how can I achieve this?
0
How to always draw a child mesh in front of its parent mesh I need to display a gizmo like mesh at runtime, and it must be always in front of its target mesh. How can I achieve that?
0
Mouse drag rotation script doesn't work when attached to OBJ model I am new to Unity. I imported an OBJ model and assigned materials to it. I want to rotate it using the mouse in the game, using this script using UnityEngine public class MouseDragRotate MonoBehaviour float rotationSpeed 0.2f void OnMouseDrag() float XaxisRotation Input.GetAxis("Mouse X") rotationSpeed float YaxisRotation Input.GetAxis("Mouse Y") rotationSpeed select the axis by which you want to rotate the GameObject transform.RotateAround (Vector3.down, XaxisRotation) transform.RotateAround (Vector3.right, YaxisRotation) I tried to apply this rotation script to the OBJ asset in my Project folder, but I wasn't able to find an Add Component option in its Inspector. So I dragged it to the Hierarchy panel to create an instance of the object in my scene. I applied my materials again to this instance. Then I added the rotation script using the Add Component button in the Inspector. But when running the game in play mode, I can't rotate it. I verified that the script above works perfectly for the default Cube or Plane primitives in Unity, but not for this imported object. How can I make this script work with my OBJ model?
0
Increment grid by rotation I'm currently working on a grid for snapping objects side by side. My current script is working fine, but only for game objects which haven't been rotated. Here is an example video of the problem https vid.me jN6D The cube at the right has a rotation of Vector3.zero, the left one has been rotated on the Y axis. As you can see snapping works perfectly for the right one, but at 0 15 you can see that the snapping doesn't work well for the rotated cube, that's because I've currently no idea how I can add the rotation in my current script. Here is a snippet of the most important part of code I'm currently using to calculate the grid Vector3 pivotToPoint hit.point nearestGameObject.transform.position float positionX nearestGameObject.transform.position.x Mathf.Round(pivotToPoint.x nearestGameObject.transform.renderer.bounds.size.x) nearestGameObject.transform.renderer.bounds.size.x float positionZ nearestGameObject.transform.position.z Mathf.Round(pivotToPoint.z nearestGameObject.transform.renderer.bounds.size.z) nearestGameObject.transform.renderer.bounds.size.z Vector3 origin new Vector3(positionX, 0, positionZ) Vector3.up 100 if (Physics.Raycast(origin, Vector3.down, out hit, Mathf.Infinity, layerMask)) previewGameObject.transform.position new Vector3(positionX, hit.point.y, positionZ) previewGameObject.transform.rotation nearestGameObject.transform.rotation Maybe some of you guys have an idea how to solve this, it's driving me crazy. p.s. Here is some guy with a similar problem, but I'm very lost when in comes to adding the solution into my code.
0
Multiple updates for Unity animation per one method call I'm trying to do some simulation where I move objects procedurally in a loop within one method call. So instead of using Update(), method I do for example void Simulate(float deltaTime) real logic look a lot different, this is just an example for(int i 0 i lt 1000 i) transform.position direction speed deltaTime ..... The reason I'm doing this is because I want consistent 'framerate' by passing that deltaTime parameter Which is for example 0.01f And each step of that loop I'm taking snapshots on multiple cameras with calling Render() method on them before taking a picture. The movement works fine and I see it on snapshots, but some objects has an animation which should also be updated procedurally. I've tried to do animator.speed 0 and then in the same loop, to test it for (int i 1 i lt 1000 i) ... animator.Play("WalkFWD", 0, i 1000f) for example But animation does not change over that loop. It only works with that Play method when I either make this Simulation() method a coroutine and pass one frame (yield return null), or if I use in Update(). So, my question is it possible to procedurally update redraw animation after normalized time of that animation is set. (without waiting for another frame)
0
Is there a way to run Unity without rendering the scene on the monitor (headless)? I am doing some machine learning and I get my environment from Unity in the form of images but the training is taking too long and it keeps me from doing anything else on my system. Is there a way to hide the simulation rendering? Any help will be highly appreciated.
0
How to write on a Tilemap using a C script? I loaded my tileset asset TileSheet.png using the Tile Palette (Window gt 2D gt Tile Palette). This created the folder "grass tiles" with multiple asset files, one named "TileSheet 168.asset". My goal is to write a script that randomly generates grass tiles within my 128 x 128 tile map. I envision the code looking something like this tilemap.SetTile(new Vector3Int(x, y, 0), "TileSheet " TileNum ".asset) ...where TileNum is a randomly generated integer between 1 and 750 (assuming that's what SetTile even does). Current code using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.Tilemaps public class drawMap MonoBehaviour public Tile grassTile public Tilemap ChessMap Start is called before the first frame update void Start() RenderMap(GenerateArray(128, 128), ChessMap, grassTile) public static int , GenerateArray(int width, int height) int colorControl 0 int cellFig 0 int , map new int width, height for (int x 1 x lt map.GetUpperBound(0) x ) cellFig x 16 if (Mathf.Floor(cellFig) cellFig) if (colorControl 0) colorControl 1 else colorControl 0 for (int y 1 y lt map.GetUpperBound(1) y ) if (colorControl 0) map x, y 0 else map x, y 1 Debug.Log("Map Coordinates x " x) Debug.Log("Map Coordinates y " y) Debug.Log("color " colorControl) if (colorControl 0) colorControl 1 else colorControl 0 return map public static void RenderMap(int , map, Tilemap tilemap, TileBase tile) Clear the map (ensures we dont overlap) tilemap.ClearAllTiles() Loop through the width of the map for (int x 0 x lt map.GetUpperBound(0) x ) Loop through the height of the map for (int y 0 y lt map.GetUpperBound(1) y ) 1 tile, 0 no tile if (map x, y 1) tilemap.SetTile(new Vector3Int(x, y, 0), "TileSheet " TileNum ".asset) Where I need help is the loading of the asset, referencing the asset, and setting of the asset. I only need this script once, because after it's done, hopefully the GameObject can remember (as if I used the Tile Palette tool).
0
Prevent player from jumping on a mesh I am working on a game and I have a mesh that I use to block hallways and prevent the player from going that direction. They are placed vertically with slight angles. I'm having a problem that the player can jump up on these. The player needs to be on the ground all the time otherwise they will be able to avoid dying indefinitely. I have tried moving and rotating and no matter how its placed I can always seem to jump on it. I want to avoid adding more to the scene then what is necessary so I don't want to add another mesh or extra collision of some kind just to keep the player away from those points as that mesh already has collision. Unless it turns out that is actually a good way to handle this. Is there a way I can prevent the player from jumping on these items? Or is there some other way I can handle if the player does jump up on them. Like maybe start damaging the player after a few seconds until they get down? What is a proper way of handling this?
0
Player disappears when it collides with a tagged object I am working on a simple game where the goal is to help a Player catch specific objects with a tag "Present". After taking care of the models, animations I am now working on the collisions and counting UI. For the collisions, on my Player Controller (I am using the ThridPersonUserController from the player Unity Standard Assets which simplified the whole animation process), I added the following functions void OnCollisionEnter(Collision other) if (other.gameObject.tag "Present") Destroy(gameObject) count count 1 SetCountText() void SetCountText() countText.text "Count " count.ToString() if (count 0) winText.text "Thanks to you the Christmas will be memorable!" However, like this, when the Player hits an object with the tag "Present", even though the counting is working properly, the player disappears. I have tried to change the OnCollisionEnter to an OnTriggerEnter, like this void OnTriggerEnter(Collider other) if (other.gameObject.CompareTag("Present")) Destroy(gameObject) count count 1 SetCountText() However when the Player hits the objects with the tag "Present", they don't disappear. My Player has a Capsule Collider and a Rigidbody. The objects with the tag "Present" have a Box Collider and a Rigidbody. Any guidance on how to make my Player stay in scene while removing the other objetcs and reducing the count is appreciated.
0
Assets bundles have higher size than uncompressed sprites I've created a script that generates assets bundles by compressing sprites using LZ4 compression. I need this in order to generate smaller files that I'll download from a server at runtime but after taking a look at those bundles. I've found out that they actually have a higher size than the uncompressed sprites. For example, I've generated a bundle from three sprites that have a size of 201KB together, but if I take a look at its generated bundle, its size is 300KB. This is only one example, there are other bundles that are 6MB but their original files are only 500KB and that doesn't make any sense to me. Can someone point me in the right direction?
0
Editor Window How to create this? I am trying to create this in my editor window but not sure how. Basically a drop down arrow, next to a C icon, next to a toggle, next to a Label with a cog at the end
0
Need help understanding this script I found this script on a tutorial that I want to implement into my game, but I first want to understand what it does and how it does it. The script is attached to a Joystick UI, which has the inner ring button of the joystick as its child. The script makes the inner button of the joystick move within a certain confine, when the player uses the joystick. quot joystickButton quot is the child object. public class Joystick MonoBehaviour, IDragHandler, IPointerUpHandler, IPointerDownHandler public Image joystickButton public Vector3 inputDirection void Start() inputDirection Vector3.zero public void OnDrag(PointerEventData drag) Vector2 position Vector2.zero RectTransformUtility.ScreenPointToLocalPointInRectangle (joystickButton.rectTransform, drag.position, drag.pressEventCamera, out position) position.x (position.x joystickButton.rectTransform.sizeDelta.x) position.y (position.y joystickButton.rectTransform.sizeDelta.y) float x position.x 2 float y position.y 2 inputDirection new Vector3(x, y, 0) inputDirection (inputDirection.magnitude gt 1) ? inputDirection.normalized inputDirection joystickButton.rectTransform.anchoredPosition new Vector3(inputDirection.x (joystickButton.rectTransform.sizeDelta.x 3), inputDirection.y (joystickButton.rectTransform.sizeDelta.y) 3) public void OnPointerDown(PointerEventData drag) OnDrag(drag) public void OnPointerUp(PointerEventData release) inputDirection Vector3.zero joystickButton.rectTransform.anchoredPosition Vector3.zero I did some research and some tests, and from what I understand, if I tap a point within the Joystick UI's RectTransform, the point I tap, quot drag quot , gets converted to a position in the RectTransform of joystickButton. The position is then converted to a vector, inputDirection, which represents the direction and location of my tap. The vector is then normalized, and the joystickButton is moved to (inputDirection.x (joystickButton.rectTransform.sizeDelta.x 3), inputDirection.y (joystickButton.rectTransform.sizeDelta.y) 3), where the vector is pointing to the direction of my tap, and has a magnitude that is 1 3 the length of the side of joystickButton's RectTransform, since all the anchors are centered, and the RectTransform is a square. What I don't get is why I need these lines RectTransformUtility.ScreenPointToLocalPointInRectangle (joystickButton.rectTransform, drag.position, drag.pressEventCamera, out position) and float x position.x 2 float y position.y 2 Is there any purpose to these lines? Converting the 1st one to position drag.position and the 2nd one to float x position.x float y position.y doesn't seem to mess anything up. Also, I didn't notice at first, but not dividing on by sizeDelta on these lines position.x (position.x joystickButton.rectTransform.sizeDelta.x) position.y (position.y joystickButton.rectTransform.sizeDelta.y) does change the result slightly, so if anyone can tell me what function dividing the values does, it would be greatly appreciated.
0
Pausing game with State machine and handling jumps I am adding pause functionality to my upcoming racing game.The players can jump in it. Time.timeScale 0 is obvious solution to pause game.I am avoiding this solution as users can do in app purchases in pause menu and with timeScale to 0 its somehow preventing them. So to overcome that problem I have added state machine pattern to start,pause,resume,finish game. The thing is when I pause game with my state machine pause behaviour it pauses the game properly without any hesitation until the player is Jumping and pause occurs. When player is jumping everything gets pause perfectly,just player falls to ground. So to overcome that problem what I tried was if user pauses game and player is on air the isKinematic on player gets set to to true and game gets pause with player halt on air. The problem with this approach was that when user resume the game ,unexpected jump movement happens, i.e., player does not land on expected position . Example if player on y 10 and game gets pause, with Time.timeScale player will always land on Z 17 ,but with my this second approach player sometimes land on Z 20 ,Z 21 Z 19 etc so my question is how will I do properly pause game with state machine without causing unexpected jump movement.
0
Why is perlin noise generating flat terrain in Unity? I am trying to generate terrain using perlin noise however the terrain being generated is a plateau. Here is the code that I'm using var xlength 65.0 var ylength 65.0 var scale 4.1f var heights new float xlength, ylength function Start () for (var i 0 i lt xlength i ) for (var j 0 j lt ylength j ) heights i,j Mathf.PerlinNoise(Time.time i xlength scale 1000,Time.time j ylength scale 1000) i j gameObject.GetComponent(Terrain).terrainData.SetHeights(0,0,heights) What am I doing wrong here?
0
Is it possible to render project flatten a 3d model onto a 2d plane in Unity? If I have a 3d Object (character) could I use a renderer shader camera mode to essentially render the 3d object as a 2d sprite? Not looking for a full tutorial on this one, I realize its a large question just looking for a direction to head in. My thought on this one is that it would be easier to create a 3d model and move it to a position for a book style game. The character could be posed in a number of different positions. I'd add some sort of outline and Cel shader and outline to get the affect, but in order to get it to view properly on my otherwise 2d game, I would need it to be in a panel or something that could have a quot Sorting Layer quot added to it.
0
If my camera does not change position but rotates, Does adding lerp do anything? If my camera does not change position but rotates, Does lerp do anything? cameraposition Vector3.Lerp(Camera.main.transform.position, Camera.main.transform.position, Time.deltaTime cameraLerp) Camera.main.transform.position cameraposition Camera.main.transform.LookAt(gameobject.transform.position)
0
Is it better to load all of the scene at once or load small parts of it as the player moves? I want to create a lot of detail in my game but I don t want to kill the frame rate tracking all the models and movements (like all the grass). Will loading them in pieces save the frame rate or will constantly loading and unloading models with every step negate any benefits of loading in pieces? I want to only load what the player will see at that moment and nothing else until the player either moves the camera or walks. I also want to know if loading a scene on Unity uses the gpu or the cpu?
0
Unity or Monogame or Gamemaker 2 for an experienced application developer? So i know this question has been hammered down several times but please bear with me. I used to be a C .Net application developer but i am no longer employed, i am pretty good at C . I want to get into serious game development and i dunno where to start, i used to work with unity occasionally which is a very little and i kinda find it clunky, like it works but somehow it does not feel right and feels kinda clunky. But it works with tiled map editor without much of a hassle. I Remember using Game maker studio when i was back in college and i found it very good, its a breeze to work with and even have its own tiled map editor, even seems to have some good tutorials, the only con is its price. I was initially inclined towards Monogame cause of my C background, but i neither have time nor money and resources to support me for long enough time to be able to code every single thing from scratch and i am kinda in a pretty bad situation overall right now. It just takes too much time to do anything even to make it work with a tiled map editor, and there are very few tutorials or documentation to start with. It seems like the only option for me is Unity at the moment, cause of ease of access and how easy it is to work with tiled map editor and lots of tutorials. which one do you guys think is good overall? Please keep in mind that i am currently unemployed and have very little resources to support myself, and i am a programmer so i don't even know how to compose music and do art for the game and i'd prefer if it provides some asserts to be used so i wont waste time in learning stuff when i cannot afford to spend time. I will eventually learn them but not now, its not happening now so i prefer something that comes with some sorta free asserts that can be used (mainly music and art), I mean does it even matter if all i am trying to do is earn a decent minimum living? I just want to make simple 2D NES Snes style games with multiplayer support. Thank you.
0
Interfacing with bill note acceptors in unity What ways are there to interface a unity game with a bill acceptor validator? Usually this type of devices are connecting to a computer using a serial port and communicate over ccTalk protocol. But what ways exist of incorporating this type of devices in Unity?
0
Learning to think like a programmer I'm pretty interested in game development and I've tried a couple of platforms and languages. Including libgdx and game maker studio, all without any real success. I'm currently using unity and it's the farthest I have ever gotten, but it just doesn't feel right. I follow tutorials and learn how to do certain things, but it just feels like I'm a parrot learning a new word I don't really understand what I'm doing just kind of memorizing stuff. I'm trying to become a good game developer, but I just don't know how to practice c in a way where I will gain actual understanding and not just memorize a bunch of syntax. Thanks in advance I really need help.
0
Unity tilemap tiles animation I am beginner in Unity and I have created tilemap using new tilemap system in unity which looks like this I created a script that lets me swap tiles. First I click on some tile and than I choose second tile, after I click second time, tiles swap their positions. Which will than look like this How can I apply some animation to this process? Seems like I have no control over tile object as it is. I can only access TileBase which as I understand is not all information about tile. I can't create any animator controller or access its transform object. I want to add some custom animation when tiles swap their places. Thank you!
0
Create a normal map using a script? Unity I don't have a software that can create normal maps from an image so I usually make a grayscale image and then let unity make the normal map from that image. But I can't save the image to use for later, Instead I have to convert it to a normal map every time I use it. So how would I make a normal map from a greyscale using a script? i prefer c but js works fine.
0
How to differentiate between instantiated objects in Unity? I'm currently trying to solve a way to go about the following problem before I start writing any code (the old fashioned pen and paper way) but I'm not sure how I could achieve the following. I'm going to have an object with a Collider attached to it in my scene. As my instantiated enemies pass through this Collider they will be added to an ArrayList which lets the object in question keep track of the enemies. The problem I can't figure out is how to determine which object is which. I will have a script attached to my main camera which will be responsible for spawning the enemy units, I'll be using a while loop in sudo code it would look something like this. public Transform (Attach the prefab in the inspector) Somefunction() int i 0 arraylist goes here while (i lt 10) arraylist i Newly instantiated object. My object with the collider will then have something like the following OnTriggerEnter() get specific object somehow add to arraylist I can't use the tag function because all the objects will have the same tag, the only thing I assume will be different is the position of the object in the spawn array (ie arraylist 1 arraylist 2 etc.) If I created a public accessor method on the trigger object could I call this method to return a string name or something special that identifies the object uniquely compared to the rest of the objects in the scene or does Unity already do this somehow natively?
0
What's the difference between Update and FixedUpdate in Unity, and should I bother? I was told to use Update() for graphics and FixedUpdate() for physics, but sometimes my inputs won't register when I use FixedUpdate(). It works fine if I use Update() for everything though. Should I bother with FixedUpdate(), or am I doing something wrong?
0
Unity GameView Differrent with CameraView Dont have 3D environments Now on my existing project, if i create new scene, automatically i got my gameview like below above game does not have 3d environments outlook, i'm expecting like below (my old existing scene) Any Idea to solve this ? thanks
0
Game launcher updater download delta diff I'm making a launcher for my game (using Unity3d). I want it to have the following features Compare game version to latest version and update if necessary Check files integrity and update if differences are found Download patch needed files So comparing the game version is easy I just parse a version.txt file and compare it's value to the latest server version. Checking file integrity sounds easy too Make a list of all files in the game folder, order the list, get a checksum and check if it corresponds. Now here's the difficult part Downloading the required files. My first idea was If a file checksum is different, download that file. But unity assets are compressed into large files, so even a simple change will lead to the download of a 2gb file... So I'm now looking for a way do download only the different parts. I heard about VCDIFF xdelta, apparently they can be useful to get a "delta patch" of different binaries. Cool. But how can I compare two folders if one of them is distant, without downloading it all before ? Could torrent be an answer ? How are game unity devs doing this ? Maybe rsync can be useful, but is it safe if hundreds of clients are simultaneously updating using rsync ? I heard about Unity's AssetBundles. Is that useful and is it ok to put ALL my assets in bundles ? How would I display a progress bar in unity showing the rsync progression ?
0
Capsule collider triggered unexpectedly I have an object with a capsule collider on its root, with IsTrigger true (triggered by the player). The trigger works fine, but is also triggered unexpectedly some times when the player walks near the collider, but still way out of its range. See attached image the capsule collider limits are wel within the round circle object. On the right you see that the player has triggered the trigger, while it was far away from the collider. When I run circles around the collider, this will happen sometimes. Location appears to be random and it doesnt happen if the player is further away than say 10 meters. Anyone else have this issue or can tell me what is causing it?
0
How to keep sprite on screen while increasing its width to screen width I have been able to increase the width of a sprite to the width of the screen size, but the sprite exceeds the borders of the screen width to the right or left when I try expanding it when it's not at the center. How can I scale the sprite in such a way that it's width increases on both sides till it occupies the screen width without exceeding it's bounds, regardless of the sprite's initial position? Please see my code below bool isScaling false IEnumerator scaleToX(SpriteRenderer spriteToScale, float newXValue, float byTime) if (isScaling) yield break isScaling true float counter 0 float currentX spriteToScale.transform.localScale.x float yAxis spriteToScale.transform.localScale.y float ZAxis spriteToScale.transform.localScale.z Debug.Log(currentX) while (counter lt byTime) counter Time.deltaTime Vector3 tempVector new Vector3(currentX, yAxis, ZAxis) tempVector.x Mathf.Lerp(currentX, newXValue, counter byTime) spriteToScale.transform.localScale tempVector yield return null isScaling false
0
Change texture settings for each object So I'm kinda new to Unity, but I've used it a couple of times before. Here's my issue I have two cubes with a random texture applied to them (drag'n'dropped something from the Asset Store). These cubes have different sizes, where one is a square and one is a rectangle. I want to set the tiling size to be different on them (because they are obviously stretched on the rectangle), but when I click on one and change it, the settings changes for both of them. This is how it looks right now http i.imgur.com JtubBle.png Is it possible to make these settings unique for each object somehow?
0
Why do I have render problems happening frequently in my Unity scene? I am making vertical endless runner. My platforms are moving down, and the camera and players are remaining in the same location, resulting in the effect of player movement. The obstacles are generated and move in same direction as platforms. The problem is obstacles rendered by the camera is not right. I mean that the obstacles are in camera's FOV but are still visible after some time when they reach the player to close.
0
What method could I use to avoid using a lookup table for each item when loading a players inventory? Let me explain a little about the pickup items and inventory to make this much clearer. Every in world item that can be picked up has a ScriptableObject assigned to it that contains all the information about that item (id, name, description, maxstacksize, sprite etc). When a player picks up an item it gets added to a List lt InventoryItem gt . InventoryItem is a class that gets populated with some of the data pulled from the ScriptableObject (id, name, description, maxstacksize), and also gets an amount property. I want to save the players inventory, but want to simplify the InventoryItem data. So I created an InventoryItemSimple struct that holds the id and amount for each item in the inventory, and then save that list to file. When loading the player inventory, currently I have a BIG list of ScriptableObjects that map to the id. So I am looping over the saved inventory list and matching against the id in the lookup table, and then adding the item to the inventory. I want to avoid this as over time their could be 2,000 unique objects that could be in the world. What's a better method to handle this? If I stick with the lookup table, do I need to worry about how much memory is being used? I don't think my lookup table will ever contain 2,000 elements. But the thought of having one massive list to manage doesn't appeal to me.
0
Why can't I put a source image in my Image component? I can't put an image here as source image, and I have trouble figuring out why. What did I miss?
0
How to make wall tiles overlap floor tiles a bit in Unity3D? Currently my tiles are very strictly placed, there are wall tiles, and floor tiles, and they don't overlap at all. What I want to achieve is to have my walls overlap my floors a bit. So their inner edges doesn't have to be a stright line, but a free shape, with "transparent holes" which show the floor below. Resulting in a much better feeling. My current approach is to have multiple layers. One for the floor and wall (single) tiles), and one above this, which will have the overlapping, decorative parts of the walls. But this methods feels slow and clunky For one wall tile I have to place 9 tiles tileparts to make it look nice. (the tile itself plus the neighbours). It would be better to place just one tile which got overlapping parts
0
Should I be concerned about assets being accessed by dumping VRAM? I have heard many people tell me that a user can dump the VRAM on their GPU and get all the images in my game. Including all "Streamed" images. This includes most of my Menu graphics. How would a user dump their VRAM and get the images? Is there software that does it? Do I need to be concerned that this is possible and should I protect my game from it?
0
Instantiate prefab button inside of panel I have a Canvas GameObject with a panel inside of it and a button prefab of the default button. When I drag the button from my resources folder onto the Canvas in the hierarchy, it places itself where I expect it to, into the panel. However when I instantiate it like below GameObject button Instantiate(Resources.Load("UI Dialogue Button"), new Vector3(0, 0, 0), Quaternion.identity, MyCanvas.transform) as GameObject it gets placed into the center of the screen because of the second parameter. However, I can't set it as a child of the parent because that doesn't happen until the last parameter. It also doesn't feel right to figure out the exact Vector3 to plug in so that it looks like its on top of the panel. Is there a way to instantiate the button onto the panel in code as it works when dragging it from the resources folder onto the Canvas in the hierarchy?
0
Unity3d "random" transform position values on editor Run into some strange behavior on editor position values. https youtu.be DUBpbOUkbfo As you can see we have two cube object with colliders on both and rigidbody on parent. After start play mode parent object editor values sets to some random numbers while transform.localPosition and transform.position is still (0,0,0). This somehow related to parent child physics hierarchy but can't understand how.
0
Replicating Flight Mechanics of Star Wars Battlefront (2015) I'm trying to replicate the flight mechanics from Star Wars Battlefront (2015) in Unity and I can't get my head around what exactly is going on. Specifically, how do I get the camera to behave like this using Unity and C https youtu.be gxZdOUiEiyY?t 1m1s I don't mind if you don't give code, I'm just struggling to understand what happens and when in terms of camera movements and rotation.
0
How to stop rendering a gameObject that has no rendering component in unity I want to stop rendering this gameObject. But the all available renderer.enabled false is not working. Is it because it has no rendering component attached? If so, how can I see it when it is not rendered?!
0
UNITY I want to make my UI text fade in after 5 seconds I know this question has been asked and asked but none of the topics i visited gave me an answer. I'm making a game programmed in c where you control a boat and i want my UI to appear smoothly by fading in after X seconds. May someone help me?
0
Unity Admob EEA checking The Admob plugin for Unity Android does not supply an EEA permission request form like the standard Android plugin does. So, I have created my own and it works great. My only problem is how do I check if I am in the EEA and need to request permission? Again, this feature is supplied for a standard Android app. I know I can make a simple Android plug in and call it but that seems a bit over the top.