_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
0 | In Unity, how do I add a MeshFilter to an empty GameObject to generate a procedural model? My code below is modeled after Unity's documentation. When I put the script into an empty GameObject, the error I get is MissingComponentException There is no 'MeshFilter' attached to the "myMesh" game object, but a script is trying to access it. How do I add a MeshFilter (and the other necessary Components) to the empty GameObject in order to generate the model procedurally? using System.Collections using System.Collections.Generic using UnityEngine public class myMesh MonoBehaviour public Mesh mesh void Start() mesh new Mesh() GetComponent lt MeshFilter gt ().mesh mesh |
0 | Unity3D post process unwanted on UI I have scene rendered with a single camera using target texture (a). Second camera is used to render UI and using same target texture (a) as the first one. Third camera takes target texture (a), depth texture and apply post proces. Result is rendered to the screen. How can I apply postprocess only to the output elements that are not UI? |
0 | Fixed distance between character and ground whatever slope value I am working on character moving on any ground meaning whatever slope degree ,the result i got is the character does not moving on just shake in his place the following the code i wrote public float speed 1 bool isMoving Transform childPosition Rigidbody rb private void Start ( ) rb GetComponent lt Rigidbody gt () Update is called once per frame void FixedUpdate () if (Input.GetAxis("Horizontal") gt 0) rb.velocity new Vector3(1f, rb.velocity.y, rb.velocity.z) else if (Input.GetAxis("Horizontal") lt 0) rb.velocity new Vector3( 1f, rb.velocity.y, rb.velocity.z) else transform.position transform.forward Time.deltaTime speed detectRoad() private void detectRoad() Ray ray new Ray(transform.position, transform.up) RaycastHit hit if (Physics.Raycast(ray, out hit)) transform.rotation Quaternion.FromToRotation(transform.up, hit.normal) transform.rotation if (hit.distance lt 0.6f) transform.position transform.up Time.deltaTime else if (hit.distance gt 2f) transform.position transform.up Time.deltaTime This animated gif is about what I want |
0 | How to apply Image effect only on specific part of objects? I need a way to censore part of characters' bodies like Cyberpunk 2077.this is mean I want to apply Image effect only to specific parts of bodies that you can see in the below Image |
0 | Find alternate shortest paths in Unity I'm developing a game in Unity. It's a simple game where the rocket has to reach the point where the player touches on the screen. The movement of the rocket is physics based. When the rocket goes off screen on right side, it appears on left side and when it goes off on left side, it appears on right side. Similar for vertical axis. In the picture above, the user touches on the bottom right corner. The rocket could either rotate and go there (Path 1) or it would directly go up left off the screen and appear on bottom right corner and reach there(Path 2). I want to implement the Path 2. How would it calculate the distances and determine the shorter path and then proceed in that direction? |
0 | After baking my lights again in Unity, my character is black? I had to re bake my scene several times before getting the look that I wanted. This last time, the scene looks great, but my characters are now very dark and the playable character is completely black. He lights up only when the directional light hits him. Saying this makes me realize the problem (sort of) All the spotlights from the room's interior were probably baked while the characters were turned off, making their solution require the only real time light in the scene in order to be seen. Still, I didn't think the characters would be involved in the lightmap data? How do I redo the lights just for characters and moving objects? How can I fix this and keep the scene lighting? |
0 | Draco encoder lossless, is it possible? I'm trying to use the draco library in a Unity project. I've a lot of obj files with models of a person in different positions. When I encode these models with the draco encoder command I obtain a lossy conversion, and a lot of parts of my original models get lost. I tried to play around the parameters qp and cl in order to change the quantization and the compression level, but also with qp at its maximum and cl to its minimum some parts get lost. In this image the left model is the original one. The right model is the one converted with draco encoder by using cl 0 and qp 21. As you can see some parts are missing. Do you have any suggestion on how can I obtain a lossless (as lossless as possible) conversion? |
0 | How can I reduce the performance impact of rendering trees? I'm making a low poly stylized kind of game. I have a terrain with some water, and I want lots and lots of trees I have 10,000 trees mass placed, at the moment. Each tree consists no more than 200 triangles, so they aren't too taxing. The main problem is, there are lakes, and the lakes are quite large. You can't actually see any trees on the other side of the lake, and that looks really bad, especially when you walk there and trees suddenly appear. To fix this, I have to increase the tree distance so that you can see a decent amount of trees on the other side of the lake, but that reduces performance to 40 50fps, and there is hardly anything else in the game yet. I'm using a GTX 1080, if that helps. What can I do to make my game run faster with more trees? |
0 | Updating object's property on Start is visible for a second when game loads I have a world selection scene in which I have GameObjects representing worlds. The GameObjects have default properties when the scene is loaded. For example the world name text is red and each world has a "locked" status. This initial state can be seen in the following screenshot On the Start() method I'm dynamically updating the properties on each GameObject based on values I'm reading from a save file. If a world is unlocked the name text is set to white. If a world is currently selected the name text is set to green. Here's what that looks like at run time The problem is that when the scene is loaded from another scene(e.g. by clicking a navigation button) the initial state of the GameObjects can be seen for a second and then they change to the proper values as dictated by the save file. How can I prevent this from happening? I was under the impression that anything that happens in the Start() method takes place before GameObjects are rendered. Here's some slimmed down code of what my code looks like var worldIcons FindObjectsOfType lt WorldIcon gt ().OrderBy(x gt x.WorldNumber).ToList() var saveFile GameSaveManager.GetSaveFile() if (saveFile null) Debug.LogError("Could not find save file while loading worlds") return foreach (var worldIcon in worldIcons) var savedWorld saveFile.Worlds.SingleOrDefault(x gt x.Number worldIcon.WorldNumber) if (savedWorld null) add world to save file GameSaveManager.CreateWorld(worldIcon.Controller) unlock first world by default if (saveFile.Worlds.Count 0 amp amp worldIcon.WorldNumber 1) worldIcon.Unlocked LevelMapController.LockedStatus.Unlocked.ToString() else worldIcon.DisplayName savedWorld.Name worldIcon.WorldNumber savedWorld.Number var button worldIcon.GetComponent lt Button gt () if (savedWorld.Unlocked) button.interactable true button.targetGraphic.color Color.white worldIcon.Unlocked LevelMapController.LockedStatus.Unlocked.ToString() else worldIcon.Unlocked LevelMapController.LockedStatus.Locked.ToString() |
0 | Help with OnTriggerEntered Canvas UI This seems like it should be incredibly easy and I know there are other posts out there with a similar title, but I promise you I have looked at all of them. All I want is for my canvas that simply says "you win" to appear when I enter an invisible box collider that I have . My canvas is by default set to disabled. public class YouWin MonoBehaviour public Canvas myCanvas private void Start() myCanvas GetComponent lt Canvas gt () void OnTriggerEnter (Collision Collider) myCanvas.gameObject.SetActive(true) This script seems incredibly simple and straightforward, but for whatever reason, when I enter my box, nothing at all happens. Why might this be? What am I missing? As per an answer I also tried public class YouWin MonoBehaviour public GameObject canvas void OnTriggerEnter (Collider Collider) canvas.gameObject.SetActive(true) But had no luck with this either. I've been tinkering to no avail, can you please give me some suggestions? |
0 | Prevent showing movie files after packaging unreal game I developed a game which has some videos inside it. I added videos into my project folder so that I can access them. After packaging, on the folder all videos will be shown as its original format which everyone can play it. How is it possible on release version no one can go to game folder and play it? Maybe some kind of encryption or change format of file which only its game can play it would help it. For example when you have a game on your computer, the only way to see the video is that you play the game and you will see relevant videos in the right time. However, after packaging, all videos will be on a folder any everyone can go to the folder and play it and see videos even without playing game. In Unity after releasing the game, you can't access assets, it will be shown in a file with .resource extension so no one can access it. However, in Unreal Engine, it will show the real file. |
0 | How to select multiple frames from a sprite sheet in unity I have a sprite sheet and cannot figure out how to select multiple frames in unity 5.5 I am watching a tutorial and it doesn't say how to do it. Is there a button I have to press while clicking or is it having to change some settings? |
0 | How can I hide the touch screen joysticks in the main menu? I am a Unity beginner trying to make an app game. How do I hide the touch screen joysticks from showing on screen in the main menu before the game app actually starts? |
0 | Detect Collision on Child Object I've created an obstacle prefab. The Prefab has following hierarchy. The player must die if he collides with Enemy. But It detects collision with parent object. I am also uploading the screen shot of property of enemy(Child Object) and Parent Object. What should I change to let player collide with Child Object (Enemy). |
0 | How can I get the vector3's names to gameobject name? void DrawBox() SpawnLineGenerator(v3FrontTopLeft, v3FrontTopRight, color) SpawnLineGenerator(v3FrontTopRight, v3FrontBottomRight, color) SpawnLineGenerator(v3FrontBottomRight, v3FrontBottomLeft, color) SpawnLineGenerator(v3FrontBottomLeft, v3FrontTopLeft, color) SpawnLineGenerator(v3BackTopLeft, v3BackTopRight, color) SpawnLineGenerator(v3BackTopRight, v3BackBottomRight, color) SpawnLineGenerator(v3BackBottomRight, v3BackBottomLeft, color) SpawnLineGenerator(v3BackBottomLeft, v3BackTopLeft, color) SpawnLineGenerator(v3FrontTopLeft, v3BackTopLeft, color) SpawnLineGenerator(v3FrontTopRight, v3BackTopRight, color) SpawnLineGenerator(v3FrontBottomRight, v3BackBottomRight, color) SpawnLineGenerator(v3FrontBottomLeft, v3BackBottomLeft, color) And the gameobjects name void SpawnLineGenerator(Vector3 start, Vector3 end, Color color) GameObject myLine new GameObject() myLine.name start.ToString() myLine.transform.position start myLine.AddComponent lt LineRenderer gt () LineRenderer lr myLine.GetComponent lt LineRenderer gt () lr.material new Material(Shader.Find("Particles Alpha Blended Premultiply")) lr.startColor color lr.endColor color lr.startWidth 0.03f lr.endWidth 0.03f lr.SetPosition(0, start) lr.SetPosition(1, end) The method SpawnLineGenerator get two vector3 and a color SpawnLineGenerator(v3FrontTopLeft, v3FrontTopRight, color) In the SpawnLineGenerator i'm setting a name for each gameobject myLine.name start.ToString() This give me the name for example ( 2.1, 3.4, 4.9) Nut I want it be the name like this format v3FrontTopLeft ( 2.1, 3.4, 4.9) v3FrontTopRight ( 1.1, 3.4, 4.9) The problem is if there is a easy way to get the names v3FrontTopLeft and v3FrontTopRight and the rest from the method DrawBox instead typing each one. I want to know that ( 2.1, 3.4, 4.9) are the coordinates for v3FrontTopLeft |
0 | Trouble with assigning a model's own mesh to a mesh collider in Unity I'm trying to use a mesh collider on the player's avatar, rather than the box collider. I've added the mesh collider to the game object (which also has a rigid body) and selected the "convex" checkbox. However, the player still falls through all geometry, including Unity primitives, terrain, and other models. In the mesh collider's property box, there's a value for "Mesh", which I have set to "None (Mesh)". I was led to believe this defaults to the model's own mesh, but now I'm not certain. If I change the value to something else from the "select mesh" list, like the cube, the collisions work. When I click over to Select Mesh Scene, the list is empty. I'm assuming I need to add the model's mesh to the list, but I can't find any documentation about that. |
0 | Tile draws pixels from adjacent tiles Whenever I try to draw from the tile palette, this is the result. why does this happen? I have tried messing around with the palette, how the sprite editor has sliced the tiles and played around with the anchors and cell sizes, but to no avail. I found a few threads about offset tiles in the tile map, but it doesn't help at all. Any leads as to why this happens? |
0 | How to create a grid of 3d objects without making them actual GameObjects Very simple question If I'm going to be generating and placing a lot of 3d objects (in this case cubes), that are not going to be interactive, like no collision, no raycasting intersections etc. Should they be GameObjects or is there a lighter solution that doesn't inherit the GameObject blob? Cheers, |
0 | Billboard rendering without distortion? I use the standard approach to billboarding within Unity that is OK, but not ideal transform.LookAt(camera) The problem is that this introduces distortion toward the edges of the viewport, especially as the field of view angle grows larger. This is unlike the perfect billboarding you'd see in eg. Doom when seeing an enemy from any angle and irrespective of where they are located in screen space. Obviously, there are ways to blit an image directly to the viewport, centred around a single vertex, but I'm not hot on shaders. Does anyone have any samples of this approach (GLSL if possible), or any suggestions as to why it isn't typically done this way (vs. the aforementioned quad transformation method)? EDIT I was confused, thanks Nathan for the heads up. Of course, Causing the quads to look at the camera does not cause them to be parallel to the view plane which is what I need. |
0 | ECS Stats, damage types damage calculation Prologue Im quite new to data oriented programming and my goal is to implement a runescape stats damage mechanic. This is quite a pretty complex topic Runescape Mechanics 1 and i havent found any ECS related sources on that topic yet. In the following example we see a bunch of items which modify the weares stats based on a few conditions. This happens in two different variants, either for the damage calculation only, or as a buff. Brine sabre and Brackish blade increase damage against crabs. or Silverlight and Darklight increase ability damage by a scaling of 25 124 against most demons. The exact damage bonus is based on your base Attack and Strength, and the monster's base Defence. The problem Such a RPG system is very complex. There different damage types, different resistences and other stats. Having a strong OOP background and no real experience in DOP, i cant find a suitable architecture to fill those needs. In my current approach every stat is a component. Items and Buffs are structs. A item quot buffs quot its owner and the buff modifies his stats. This works so far, but i have no idea how i could realise the damage calculation, while still keeping it that flexible as it is in runescape. This little example would just be able to buff the stats... not deal, receive or modify the damage itself. The stats public struct Health float max float value public struct MeeleDamage float base float value public struct MeeleResistence float base float value Item amp Buffs public struct Item string name int amount bool equipable List lt Buff gt buffs public struct Buff string name float duration Condition applyable ToBuff stat float value Its also important that an entity can also deal damage to multiple other entities in one frame. How would you implement such an complex mechanic ? Any examples are appreciated ! |
0 | Generating mesh along path I'm currently trying to generate a path along an array of points (Vector3) This is the result I'm currently getting The dark gray points are the given path The red points are the generated vertices And the triangles are obviously the mesh I failed to generate correctly And from the bottom it looks like this, which is odd, because I'd expect all the missing triangles to be at the bottom. But some of them just don't exist here's the code i wrote that generates the path mesh Removed code since there's no need in showing something that doesn't work And here's a quick example of what it looks like when I drag a path SOLUTION FOUND As the accepted answer states, I was skipping triangles in my triangle for loop. Here is my new working code public static Mesh extrudeAlongPath(Vector3 points, float width) if (points.Length lt 2) return null Mesh m new Mesh() List lt Vector3 gt verts new List lt Vector3 gt () List lt Vector3 gt norms new List lt Vector3 gt () for (int i 0 i lt points.Length i ) if(i ! points.Length 1) Vector3 perpendicularDirection new Vector3( ( points i 1 .z points i .z ), points i .y, points i 1 .x points i .x).normalized verts.Add (points i perpendicularDirection width) norms.Add (Vector3.up) verts.Add (points i perpendicularDirection width) norms.Add (Vector3.up) else Vector3 perpendicularDirection new Vector3( ( points i .z points i 1 .z ), points i .y, points i .x points i 1 .x).normalized verts.Add (points i perpendicularDirection width) norms.Add (Vector3.up) verts.Add (points i perpendicularDirection width) norms.Add (Vector3.up) m.vertices verts.ToArray () m.normals norms.ToArray () List lt int gt tris new List lt int gt () Changed i 3 to i for(int i 0 i lt m.vertices.Length 3 i ) if(i 2 0) tris.Add(i 2) tris.Add(i 1) tris.Add(i) else tris.Add(i) tris.Add(i 1) tris.Add(i 2) m.triangles tris.ToArray () m.name "pathMesh" m.RecalculateNormals () m.RecalculateBounds () m.Optimize () return m |
0 | How to get LineRenderer coordinates? I am trying to get the coordinates or positions that are generated at the time I draw with linerenderer, but it gives me an error. This may be a rookie mistake and I am not using the Linerenderer's methods well. I would be very grateful for your help. LineRenderer.GetPosition index out of bounds! UnityEngine.LineRenderer GetPosition(Int32) sendData Figura Trazo(Int32) (at Assets sendData Figura.cs 115) sendData Figura Update() (at Assets sendData Figura.cs 93) public LineRenderer line public static int contadorTrazo 0 void Update() Trazo() void Trazo() line line.GetComponent lt LineRenderer gt () Debug.Log("Trazo " line.GetPosition(contadorTrazo)) contadorTrazo |
0 | Issues loading in AudioSource at runtime using WWW class I am having an issue with loading in an OGG audio file to my project. Basically I want to set my game up so that players can drop audio files into a folder called Playlist in the game directory then they can listen to this music while they play. For some reason my audio clip never becomes instantiated. I have an Audio Source in my scene with this script attached to it. As you can see I have commented out some code for the time being as I am trying to get a simple case of only 1 audio file playing at this stage. So my question is what exactly am I doing wrong here? I have printed out the file path and it comes out as file B Users Matt Development Unity Projects Space Game Playlist 19 Tumbling Dice.ogg which is the location to my audio. However when I print out the audioLoader.audioClip.name it comes out as blank... RequireComponent(typeof(AudioSource)) public class MP3AudioImporter MonoBehaviour private List lt string gt playlist private string musicDir "B Users Matt Development Unity Projects Space Game Playlist " private int currIndex 0 void Start() string songs Directory.GetFiles( musicDir, " .ogg", SearchOption.TopDirectoryOnly) playlist new List lt string gt (songs) StartAudio() void StartAudio() WWW audioLoader new WWW("file " playlist currIndex ) Debug.Log(audioLoader.audioClip.name) audio.clip audioLoader.audioClip audio.Play() currIndex if (currIndex gt playlist.Count) currIndex 0 Invoke("StartAudio", audio.clip.length 0.5f) |
0 | Why are setcolor and color not reset When I do a color exchange directly on the material in playmode, but then I go back to editmode, why do the settings still remain? For example mymaterial.SetColor( quot Color quot , blue) or mymaterial.color blue |
0 | Unity Built In Shader Transformation Explanation Resource I'm working on some of my first shaders and taking a look at the variables included by cginc I see this list of transformation matrices I've watched some beginner talks and I understand what the first one does but pretty much every other one I'm not sure what it does or how to apply it. Does anyone know of a good resource for explaining these transformations? |
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 | What would be the best way to find a Game Object that is closest to another Game Object in unity? I made a 2d space shooter game awhile ago and I want to go back into it and overhaul some things. I'll provide a link to the game so anyone can play and get a better understanding of what I'm trying to do. https your pal drewdle.itch.io starspeed With how the game is currently set up, all the enemies are constantly setting their rotation to be facing the position of the player. I want to go back in and add a co op mode where there are 2 players, however, if I just added a second player without changing any code, the enemies would always be facing Player 1, never directly facing Player 2. I was thinking that I could get around this by giving each enemy an invisible circle with the center at the enemies position that would constantly expand until it hit one of the two players, I could then set the enemies rotation to face the point where the circle collides with one of the players. In theory, this would make it so that each enemy is facing towards whichever player is closest to it. So my question is How could I go about implementing this in unity? Or, is there a better or more efficient way to do this that would yield the same result? I've spent a decent amount of time researching this and I haven't had much luck. All help is appreciated, if you need more explanation just let me know and I will do my best to explain in more detail. |
0 | How can I set up potentially dozens of cameras rendering to targets without killing performance? I'm thinking through how I'd do a particular trick for playing cards with animated 3D faces. Setting up a single card is pretty trivial. I would create another camera somewhere, maybe restrict some layers so it'll only show what I want it to show so I don't have to worry what's behind it, put an object in front of it that is the basis of the card, have the camera render to a texture, and put that texture on a quad (the card) with the same aspect ratio. Now whenever the main camera views the card, regardless of angle, the card displays what the other camera sees. I don't believe this approach would scale well as I'd have to duplicate everything for every card. The way I imagine it, there could be dozens of cards visible at once so every frame would require rending all of them. Even at low qualities that sounds bad for performance. Also the main reason I want to animate cards is to have them respond to input and actions happening to the cards so two instances of the same card won't show exactly the same thing. Another thing is where would I place all these cameras and their models in the 3D space so that they won't see each other? I could put them on top of each other and use layers to only capture what I want but something doesn't feel right about having dozens of layers. How would I begin to pull this off on a scale of dozens of cards? |
0 | Calculate a random position inside a 2D area excluding a subset Given this area X X X X I have a GameObject size 4x4 and inside another GameObject size 2x2. I know how to calculate a random position inside the 4x4 zone (using GameObject position and collider size), but I do not know calculate a random position evading the 2x2 zone. What I am using right now is Calculate position inside 4x4. If that position is inside 2x2 go back to step 1. But it is not a good way to do this. Do you know can I calculate a random position inside 4x4 area evading a 2x2 area? I though generating small GameObjects, 1x1 instead if 4x4. So first select a random of the 4x4 tagged, for examble, as "IsWalkable", and then calculate a random position insided the selected small square. |
0 | Customizing Unity WebGL index.html Hey everyone just some css and styling tips needed! i want to use a game as a 404 page. so i would need on top to be either text or a contact form then some spacing and then the actual game window. iframes dont work that good on mobile devices and by doing a simple div in unity index although on mobile it works rather crude but nice, on desktop the text is going behind the unity game window. any tips please? Note that im adding the style in the index.html and not using the separate css file in the template folder. So to sum up how can i make another div centered in the page and well responsive for mobile above the game container and add a margin on the bottom of that div! Thank you!! |
0 | Is there any way to get PVRTexTool's version from the command line? I am to make an automated task which involves requiring the version of the PVRTexTool that comes with the Unity installed in a machine. Is it possible to get the version of PVRTexTool on the command shell? |
0 | character and camera not moving in the same speed the two scripts below do the similar things, get the key press and calculation the direction after the direction calculated, they multiple with the same speed, say 0.05f, while the character and the camera, do not move at the same speed, and the character move faster than the camera. if i rotate the camera a bit and move the character, the character move even faster than camera. i believe there are something wrong in the variable direction, i would like to like how can i fix it so that both of them can move at the same speed in every direction. Thank you. character movement script animation.CrossFade("moving") direction Vector3.zero myposition transform.position if(Input.GetKey("i")) animation.CrossFade("moving") direction Vector3.forward currentkeydown true if(Input.GetKey("k")) animation.CrossFade("moving") direction Vector3.back currentkeydown true if(Input.GetKey("j")) animation.CrossFade("moving") direction Vector3.left currentkeydown true if(Input.GetKey("l")) animation.CrossFade("moving") direction Vector3.right currentkeydown true if two key press if(Mathf.Abs(direction.x) Mathf.Abs(direction.y) Mathf.Abs(direction.z) gt 1) direction.x 2 direction.y 2 direction.z 2 if direction change if (direction ! Vector3.zero) direction Quaternion.Euler(0.0f, Camera.main.transform.localEulerAngles.y, 0.0f) direction transform.rotation Quaternion.LookRotation(direction) if(currentkeydown) transform.position direction speed and camera script if(Input.GetKey("i")) direction Vector3.forward currentkeydown true if(Input.GetKey("k")) direction Vector3.back currentkeydown true if(Input.GetKey("j")) direction Vector3.left currentkeydown true if(Input.GetKey("l")) direction Vector3.right currentkeydown true if(Input.GetKey("u")) transform.RotateAround(player.transform.position,Vector3.up, 2f) if(Input.GetKey("o")) transform.RotateAround(player.transform.position,Vector3.up,2f) direction transform.TransformDirection(direction) direction.y 0 if(currentkeydown) if(Mathf.Abs(direction.x) Mathf.Abs(direction.y) Mathf.Abs(direction.z) gt 1) direction.x 2 direction.y 2 direction.z 2 transform.position direction speed |
0 | Best way to connect multiplayer users with each other (matchmaking) on a low powered server? OK so I am using unity to make a multiplayer game, but I'm not sure how to connect players with each other over the internet. Unlike other questions, this isn't a general problem of working out how to do UPnp or using unity's matchmaking server. My issue is that my server that I would use is a simple low powered pc (running normal windows 10, no idea how to use windows server). I think it is powerful enough to match players with each other, but not to host more than one or two actual games. The other issue is that I have a residential internet connection with a dynamic ip that changes every few months. However the speed should be ok (150Mb s download, 20Mb s download). Also, I'm not planning to spend money on a monthly basis for a server (like unity's matchmaking service) as I plan to spend as little as possible (So far I've paid 12 to Microsoft for a dev account and I've received a 200 voucher from them so my current spending is 189!) So my question is should I use my server (would it work), are there any online services that are very cheap to use, or is there another way to make this work? Only other thing is I could use the free 20 users at once on unity's matchmaking, but would this limit be too small? EDIT just for information, my game is a simple tank shooter. I was thinking about limiting the amount of tanks in a game somewhere around 8 20. The bullets in my game are physical objects with rigidbodys and they move at a slower speed (if you've ever played tank trouble, it looks like that). The world is in 3D. There is a potential for there to be up to a hundred bullets in a scene at once at the worst. After hosting a LAN world with 7 players connected for about 20 30 minutes, windows reports the data usage being around 3 4MB. |
0 | Apply new default transform values for gameobject I'm not sure if the title is correct. But how does one go about the following I imported a mesh created in blender.When i import the object it is at the desired rotation and scale, however, when i look at the properties of the transform the scale is 100 and the rotation is 89.9123xxxxxxx. Is there any way i can rotate it to the desired rotation, scale it to the desired scale then tell unity that it should update the prefab and set this new rotation as 0,0,0 and the scale as 1,1,1. Reason behind this, is i am tiling a few prefabs, and the rotations are being used.... after a couple of hundred tiles, there are floating point errors. |
0 | How can I customize scrollbar sensitivity in editor property drawers in Unity3D? A custom property drawer, in my Unity 2017.3 project, has code like this in its OnGUI implementation public void OnGUI(Rect position, SerializedProperty property, GUIContent label) ... EditorGUI.BeginDisabledGroup(maxX 0) scrollX (uint)GUI.HorizontalScrollbar(new Rect(xyPos new Vector2(slHeight, normalizedSize), new Vector2(normalizedSize, slHeight)), scrollX, 1, 0, maxX 1, GUI.skin.horizontalScrollbar) EditorGUI.EndDisabledGroup() EditorGUI.BeginDisabledGroup(maxY 0) scrollY (uint)GUI.VerticalScrollbar(new Rect(xyPos, new Vector2(slHeight, normalizedSize)), scrollY, 1, maxY 1, 0, GUI.skin.verticalScrollbar) EditorGUI.EndDisabledGroup() ... But these scrollbars have a sensitivity of 10 (pressing the up down, or left right, buttons will change the current value by 10 in the respective direction). I need them to have a sensitivity of 1. How can I do it? |
0 | How to Change position rotation of a parent while keeping X and Z Rotation Sooo this question is a problem , a evolution by another solution of this problem here How can I change the parents rotation so the childs rotation is looking at a specific direction Basically We have a "Eye" (HTC Vive). We have a "Parent" which is the Parent of "Eye". We can not change the position or rotation of the Eye in code. We can only change the position and rotation of the Parent. 1.We want to modify the Parent Position so that Eye to goes to a certain "Target 1" position. 2.We want to modify the Parent Y Rotation so that the Eye looks at a certain "Target 2" position. 3.While doing this we dont want to modify the Parent X or Z , because this would lead to a Rotated game experience. The Parent Position changes so the Eye gets to "Target 1" position. The Parent Position changes so Y Rotation should look at Target 2 position The Parent X Z Rotation should not modify the Eye X Z |
0 | Switching from software Engineer to Game developer I don't know if this is the right place to ask this. I've been working as a software engineer for 3.5 years so far, mostly web apps, mobile apps, web pages in banking systems, educational, etc but I always wanted to work as a game developer. Currently I have a university degree in CS, and I'm attending a masters degree in Apps design. I've very little experience in game dev (only for hobby), some space shooters and some steps in unity, also I took some courses of blender, and did some simple sprites (those 8 bit characters but animate them is a big problem for me atm.) but I've never gone too far. I know I cannot focus on all aspects of game development, because it is a huge world integrated with different disciplines, but I need to make a portfolio with some of my games at least. (I only have partial prototypes, some of them work, some don't...) I need some advise of people who are in the game business. Which platform framework do you recommend for me ? I already know a bit of Unity and I feel pretty comfortable with it. I can get some assets to work with (models audio, etc), there are some free material in the store, and I have budget to spend on that too if necessary. How do game companies hire people? What am I suppose to aim for a job? I mean this is a world full of disciplines and I need to focus in something particular I guess, I'm a senior frontend developer too, so I guess I should focus on coding. I think portfolio is the best way of showing your work. Any suggestions are welcome! thanks! |
0 | Knowing when an ad was clicked Is there a way in Unity to know when an ad was clicked? Some plugins for different advertising networks have events that fire when the ad was clicked, but if there is no such event how do I know when an ad was clicked? |
0 | Random Range Without Duplicates I have an array of gameobjects (some questions) if player hit some triggers a question from the array is displayed randomly, I want to avoid duplication of displaying questions. public GameObject Q public static int ColliderCounter 0 int WrongAnswerCounter 0 public int i,old private void OnTriggerEnter2D(Collider2D collision) if (collision.gameObject.tag "Obstcle") i Random.Range(0, Q.Length) old i ColliderCounter Q i .SetActive(true) GetComponent lt PlayerMovement gt ().enabled false IEnumerator waitWrongAnswer() WrongAnswerCounter yield return new WaitForSeconds(3f) Q old .SetActive(false) i Q i .SetActive(true) old i And I want to know how to check if all questions are displayed do something. Thanks in advance |
0 | Run a Script at Game Startup in Unity I have a script that is made to run when the game is loading. That script set the resolutions, fullscreen, and loads other screen and important settings and it applies them. I have the script attached to a gameObject in the main screen that have some game and scene scripts. The problem is that everytime that you return to the main scene, that script runs again and cause several bugs. So, there is a way to run a script only at game startup? |
0 | Unity Tilemaps Best practices I'm pretty new to Unity and I just finished some courses and tutorial found in the official documentation. I'm now in the process to apply what I learned so far using different assets from the ones provided with the tutorial, to see if I understood all the material. I'm trying to build a simple top down game with some free asset I found online. My tile palette is composed, among others, of tiles like these Now, in order to create something like this sorry for the quality, I recreated it in gimp since I'm not on the computer where I have Unity now I had to create three Tilemaps under the same Grid. The botton tilemap contains the grass (sort order 2), the middle one contains the fence (sort order 1) and the top one contains the house (sort order 0). My first question is given the tileset I have, is this the most efficient way to obtain what I needed? After having solved this problem I wanted to add a collider to the fence and to the house, but since they are on two different tilemaps I cannot use a composite collider to optimize the collider's layout. Is there another way to do this in a more efficient way? Instead of using tiles for quot interactable objects quot , should I use quot proper quot game objects instead? |
0 | How to make an authoritative multiplayer game deterministic for all clients? I'm starting to create a multiplayer online game, with an authoritative server. As it is, the clients send inputs to the server which do the simulation and then send back to clients the updated state. The game is a top down shooter, so it's fast paced and input lags are not allowed here, so to avoid this I'm doing the simulation on the client too, and when the server update come back I compare the local simulation with the server response. If they are compatible everything is fine, otherwise, the client version is corrected. I was expecting that the client simulation desync at some point, because of all of the variables on physics, floating points, network etc... But this happens much more than I thought. Just by sending the inputs and simulating on the server, the results are very different, even on simple movements, like forwards and backwards on a clear space. Green is local, red is server response I need help on this step, a way of keeping, at least this kind of simple movement, consistent on the server and the clients. |
0 | How to write a unit test in Unity? is there a tutorial and patterns to write unit tests in Unity ? Should we use the classical c way and test the code or should we test the interactions in UI ? If so how? |
0 | How can I prioritize the call order of decoupled scripts? I have a player with many individual components that each handle a behavior such as jump, block, attack, duck, etc.. None of the scripts know about one another. Each listens for a specific input to fire. Some behaviors share the same input depending on the characters state such as ok the ground, in the air. I'm running into issue where the wrong behavior will fire that has shared input (down attack instead of down attack being held down for x seconds). I'm looking for advice on how to manage these behaviors and have more control over what can happen when. I've tried resolving this issue by creating a method that will disable other behaviors temporarily while completing the action and I've changed the script execution order. I thought about adding a discrete player state and restricting what behaviors are able to be performed at any given time but this increases the complexity quiet a bit. |
0 | Unity Augmenter Reality on Android with Video playing Hey sisters and brothers, So, I created an augmented reality marker, which works perfectly, I was able to display 3 shape on the screen with my Nexus 5. I would like to replace my shapes with a Video. So, when the user track on the marker, I would like to start to play a video above the marker as a part of the augmented reality (No full screen playing). I tried to use this video tutorial (https www.youtube.com watch?v YBc3ubr18ks) , but on Android you can't use MovieTexture (they say). My question(s) how can I display a shape above the marker, with a video on it and what it the video format ? When I trying to build the project with mp4, it failing, but when I do with AVI it's okay, but the app crashing. Thank you, |
0 | Unity third person controller and hills So I've been building a game and using the out of the box unity third person controller demo stuff. I found that even the tiniest of slopes seems to stop the "dude" dead in his tracks. Is there an easy way to adjust the sensitivity on the scripts somewhere? I tried messing with the sensitivity options in the input options setup thinking that it might help but it didn't and I don't really want to go messing about in the scripts unless I really have to because i end up complicating my life when I do that. |
0 | Problem with grid generation in Unity 5.1 Using Unity 5.1 and was following a tutorial for generating a grid for a Minesweeper style game. Link to the tutorial for reference http gamedevelopment.tutsplus.com tutorials build a grid based puzzle game like minesweeper in unity setup cms 21361 Tutorial is Unity 4, but I don't think it should matter. Here's my code public GameObject tilePrefab public int numOfTiles 10 public float distanceBetweenTiles 1f void Start () CreateTiles() void CreateTiles () float xOffset 0f for (int tilesCreated 0 tilesCreated lt numOfTiles tilesCreated ) Vector3 positionVar new Vector3(transform.position.x xOffset, transform.position.y, transform.position.z) xOffset distanceBetweenTiles Instantiate(tilePrefab, positionVar, transform.rotation) Essentially, the problem is that when I coded the spacing algorithm, Unity decided to ignore the spacing of 1f, but instead do 10,000. No matter the number I substitute for "distanceBetweenTiles", Unity spaces the cubes by 10,000 points. I'm assuming it has to do with how Unity is handling the float numbers, but I'm not quite sure, considering the number I substitute doesn't seem to matter. I've included a screenshot of Unity running the script and the inspector view of the giant X position. Thanks so much in advance 1 |
0 | Unity Editor Get Mouse coordinates on left click on Scene Editor I need a simple script which does the following When I left click somewhere in the Editor Scene (doesnt matter if there is an object under the cursor or not) Do NOT deselect the current selection in the Inspector. Do not select the object under the cursor. and Just print the mouse X and Z interception with the Y Plane in the Debug.Log() i stumbled on many solutions but somehow i couldnt get this to work. i tried HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)) and Tools.current Tool.None both seem to do nothing ..... X.x EDIT Happens that "HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)) " needs to be inside public void OnSceneGUI() and called every frame to "block" the mouse clicks on the editor. i thought it toggles it off. still the problem of the mouse coordinates persists. |
0 | The A,I can't seems to move strafe on the left continously? void Update() ChasingPlayer() void ChasingPlayer() if (chasing true) transform.LookAt(player.transform) facing player transform.position transform.forward approaching Time.deltaTime going towards player float distance Vector3.Distance(transform.position, player.position) Debug.Log(distance) calculating the distance between player and enemy if(distance lt 10) chasing false transform.position Vector3.left 2f Time.deltaTime Debug.Log( quot STOP! quot ) I want my A.I to approach to the player but when it reaches within 10 feet(?), I want it to stop moving towards the player and strafe move to the left or right from there but instead it just moving in a curve movement that leads towards the player. How should i stop the AI within 10 feet(?) and move to the left right? |
0 | unity and maya how to export import fbx animation with rootmotion and non rootmotion clips? I've started learning about and playing around with animations in Unity and I've installed the Basic Motions Pack by Kevin Iglesias. I wanted to know how they work and to see if I can modify them so I've looked at the animation files which are .fbx. The animation hierarchy in Unity looks like this where BasicMotions Walk01 is the in place animation and RootMotion is the root motion variant which has velocity. I've looked into what root motions are and I think I've grasped what they are, but here's where things have gotten interesting. I've imported the BasicMotions Walk01.fbx into Maya and it looks like this it has a root joint for root motion and the animation moves the rig in each keyframe. So far so good! I've modified the animation so that it plays in reverse, basically made a sketchy reverse walk animation. Exported it to .fbx with the following parameters And then opened that in Unity, however when I import the animation and rig it it only has one clip and it's the Root motion clip, and I can't get the non rootmotion clip. The Root Transform Position (XZ) Loop match is always red and if I don't bake it into pose the animation functions like the Kevin's RootMotion animations, but I don't know how to get the non RootMotion clip. What am I doing wrong here? |
0 | IsolatedStorageException Could not find file I'm trying to save load player data from a file using the persistenceDataPath using the following code private void Save() if (File.Exists (Application.persistentDataPath " playerInfo.dat")) FileStream file File.Open (Application.persistentDataPath " playerInfo.dat", FileMode.Open) data.userExperience userExperience bf.Serialize (file, data) file.Close () private void Load() if (File.Exists (Application.persistentDataPath " playerInfo.dat")) FileStream file File.Open (Application.persistentDataPath " playerInfo.dat ", FileMode.Open) PlayerData data (PlayerData)bf.Deserialize (file) userExperience data.userExperience file.Close () Serializable class PlayerData public int userExperience It works fine if I play the game with Unity Editor. However, on Android, when I try to execute this line of code in Load() FileStream file File.Open (Application.persistentDataPath " playerInfo.dat ", FileMode.Open) I get this error The file does exist since the code pass through the if(File.Exist...) and it works when I try to access the file from the Save() method. I really don't know what it could be since the code that open the file in Save() and Load() is the same. |
0 | Throwing a grabbed object I'm trying to throw the carried object in the direction of the first person controller, but unable to make it. I could make the carried object drop, but the same time i need to instantiate velocity to the carried object, so that i could forward. I'm building up a bowling game and trying to make the ball behave like the same when the player throws the ball. It should hit the alley and move forward to hit the pins. Below is what so far I've tried. using System using System.Collections using System.Collections.Generic using UnityEngine public class pickupobject MonoBehaviour GameObject mainCamera public GameObject empty bool carrying public GameObject carriedObject Camera cam public float distances public float smooth float speed 1000f Use this for initialization void Start() cam GameObject.Find("MainCamera").GetComponent lt Camera gt () mainCamera GameObject.FindWithTag("MainCamera") Update is called once per frame void Update () if (carrying) carry(carriedObject) CheckDrop() else pickup() private void pickup() if(Input.GetKeyDown(KeyCode.E)) int x Screen.width 2 int y Screen.height 2 Ray ray mainCamera.GetComponent lt Camera gt ().ScreenPointToRay(new Vector3(x, y)) RaycastHit hit if(Physics.Raycast(ray, out hit)) pickupable p hit.collider.GetComponent lt pickupable gt () if(p! null) carrying true carriedObject p.gameObject void carry(GameObject o) o.GetComponent lt Rigidbody gt ().isKinematic true o.transform.position mainCamera.transform.position mainCamera.transform.forward distances void ThrowBall() GameObject go (GameObject)Instantiate(carriedObject,transform.forward, Quaternion.identity) pickupable to go.GetComponent lt pickupable gt () to.Throw(carriedObject.transform.forward speed) void CheckDrop() if(Input.GetKeyDown(KeyCode.U)) Drop() void Drop() carrying false carriedObject Instantiate(carriedObject, new Vector3(transform.position.x, transform.position.y, transform.position.z), transform.rotation) carriedObject.GetComponent lt Rigidbody gt ().isKinematic false gameObject.GetComponent lt Rigidbody gt ().AddForce(carriedObject.transform.forward 100) carriedObject.GetComponent lt Rigidbody gt ().AddForce(0,0,1f) carriedObject.gameObject.GetComponent lt Rigidbody gt ().isKinematic false carriedObject null Thanks in advance! |
0 | Unity job system long running task I have a long running task (250ms )that I want to pick up a resultant array from. This job is a path finding service that should run periodically in the background. It's all prototyped in another language using a background Thread. According to the Unity docs, I should call Complete() when I'm ready for the results of this job. However, I don't know when this task will complete I don't want my main thread to wait on this job completing. I want this job to run async and to collect the result from a Nativearray the resultant search array null (if it's a first run and still in process. with concurrent array access protected by a lock. If the job is writing to the array, it should be locked. What's confusing is that most of the Unity job examples seem to use short jobs that last a few frames, then pick up a result in a LateUpdate() or next Update(). My job is much longer running. Since my job uses no Unity API directly, am I correct that standard c Threads seem more applicable for my kind of problem? |
0 | Manual response when 2 shapes made of rectangular volumes collide I have 2 compound objects made of rectangular blocks. One of them (the one that is moving) has a script that listens to OnTrigger callbacks. What I need is to position the moving compound object on the first compound object to make then not collide but stay in contact. As an example you can thing of two "spheres" made of blocks. Both spheres are on the floor. Then I move one of the spheres (still on the floor) and I detect that it collides the other sphere, so, I need to push the moving sphere up to make it not collide with the first one but stay in contact. I have a manual algorithm that make tests on the different blocks of the two groups to push it up enough to make them not collide but it is a bit intensive. Do anybody know if unity physic engine can help here? The main problem is that after I receive the collision I can not move the moving sphere up and recheck manually first of all because there's no Check for rectangles and on the other hand if I want to be notified by the physical engine after I move the moving sphere up (to see if it still collides)I need to wait a new frame which is not feasible in my case. P.S. I'm using unity engine. |
0 | Unity Creating a panel that stretches using anchors Relative newbie to Unity so please excuse any oversights. I have a component (canvas panel) that I'm wanting to add a panel to, so that when the parent component's height changes, the child panel's height changes to match. I've achieved this manually using the inspector (see top half of attached pic) to set the anchor points at min(0.5, 0) and max(0.5, 1) (pivot is unchanged at (0.5,0.5)). I want to create that stretching panel in scripting, and have the following code that results in the bottom half of the attached pic where the rect transform's anchors aren't set at all. GameObject panel2 GameObject.Find("Panel2") GameObject divider new GameObject("RunTimeLine") divider.layer LayerMask.NameToLayer("UI") divider.transform.SetParent(panel2.transform) CanvasRenderer c divider.AddComponent lt CanvasRenderer gt () RectTransform rt (RectTransform)divider.AddComponent lt RectTransform gt () Image img divider.AddComponent lt Image gt () img.color Color.red rt.localPosition new Vector2(0f, 0f) rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 20) rt.anchorMin.Set(0.5f, 0) rt.anchorMax.Set(0.5f, 1) Any suggestions? I've also tried setting the min max offsets and pivot but haven't been able to create what I've got manually in the inspector. |
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 | Animated Energy Combo Bar (Unity 4.6) How could I achieve the animated Combo bar effect used in Ski Safari Ski Safari Adventure time? Preferably with Unity 4.6 UI. General explanations also welcome! Links to videos showing the wanted effect https www.youtube.com watch?v CnfCkqiM890 t 4m46s and https www.youtube.com watch?v aqj61liRJ74 t 7m00s |
0 | Unity Renderer "raycasts" from top down? I'm trying to have objects in a game be selectable only from a top down orthographic camera view. I think having physics colliders might be overkill for that especially because this only needs to be in 2D and not 3D. Is there another method that might be better, such as something like a renderer quot raycasts quot , but perhaps even more performant as it is just from the orthographic 2D top down view |
0 | Textures selectively not applying in Unity On certain imported objects (fbx) in Unity, upon applying a material, only the base colour of the material is applied, with none of the tiled texture showing. This isn't universal on a test model only some submeshes didn't show the texture, while some did. I have tried every combination of import calculate normals tangents to no avail. FYI I'm not exactly experienced with the software or gamedev in general this is to make a small static scene with 3 4 objects max. One model tested was created in 3DSMax, the other in Blender. I've had this happen on every export from Blender, but only some submeshes from the 3DSMax model (internet sourced to test the problem) |
0 | Best client server architecture for a mobile management game? For the past year I have worked on a small company that develops a traditional browser based strategy game, of the likes of Travian or Ogame, but using a more interactive approach like Tribal Wars 2. The game is made in a simple php server without frameworks and a simple mysql database, and all of the game happens in a single static page that is changed through ajax calls and has a map made in pixi.js. The automatic updates are delivered to the client side through polling the server which then queries some specific database tables made for the purpose for changes. While this approach is solid and works, it has 2 big problems Having a mobile app is increasingly more important and there are not enough resources for having two separate codebases. Having a app which is simply a wrapped webview is also not a solution because the performance of a really complex page with a giant webgl map is, while usable, really subpar Polling the server for changes creates a lot of programing challanges that make some simple tasks really complicated and creates a lot of convoluted code if we dont want to hurt the game performance, as we are not going make dozens of database queries every 5 seconds. I want to start developing a game idea that I have that is basically inserted in the same genre and which is going to be, at least initially, mobile only. The real problem here is that after reading a lot on the internet, I am confused on what should be a good client server architecture for me to start prototyping in a way that I do not run in the problems mentioned above. Basically, above all, I want the server to be able to know which page screen state is each client looking at, and be able to send them messages when another client changes something on that specific screen. It would also be nice if the solution is something lightweight on the server side to be able to scale a little. Client side I was thinking about Unity because of being cross platform, of all the environment around it (ads, analytics, a lot of support and answers on the internet), and because I have previous development experience with it. Server side is the real question. Simple http calls will not work and so PHP is out of the equation. I have though about using node.js with socket.io to use websockets solving the polling problem. Is this a good idea? Would it be better to store the game state in a relational or nosql database in this case? Would this work on unstable mobile conections? Lots of people seem to use a c and sockets for unity. Would this be overkill in this situation? Taking this approach how would the data be stored? would it be feasible with a linux server or would I need a windows server? Would this work on unstable mobile conections? Don't know, I'm open to suggestions. tl dr I want to make a mobile management game in unity but am confused what to choose for the server side architecture considering that I want the server to be ablose to send a message to the client without the client asking for it. Is there anything I should take in account? Sorry for the broad question and thanks for the help. |
0 | Unity, interior poly always missing in clothing I've modeled interior polygons but for some reason they do not show up in Unity. I've tried changing import settings for normals to both calculate and import... How do you have a tshirt's interior poly show up? |
0 | Game (Physics) work in Unity Editor Remote but won't on Android? I have a script attached to a car game object that allows the player to tap the screen and then accelerate, the game object has a RB2D and collider set to it , it works fine in Unity Remote , but when I download the APK , as soon as I tap the screen , collisions go completely bezerk and the car just starts ignoring collisions , what's going on? As I need this to work to complete my game , as the player can move side to side with the accelerometer but I also want them to move forward when they touch the screen. Also , my game is 2D. Plus , since then , when the car ( my object) collides with anything else in the scene , it ignores it ( the obstacles just have Box Colliders on them). I had to freeze rotation so it could stop spinning out when it hit soemthing , now it just won't recognize collision at all. What's going on? The code I think is causing the error starts at line 32. I have obstacles the player has to dodge and they all have box colliders and an appropiate script attached to them as well ( so when they collide with my player , it destroys it) I've figured it out , Collision works when I first start the game , but when the player dies and I press "Replay" , it goes crazy. Here's the script that controls the enemy cars spawning , what the hell do I do to fix this? Code (CSharp) using System.Collections using System.Collections.Generic using UnityEngine public class EnemyCar MonoBehaviour public float speed public float acceleration 0.5f Use this for initialization void Start () Update is called once per frame void Update () speed Time.deltaTime acceleration transform.Translate(new Vector3(0, 1, 0) speed Time.deltaTime) void OnCollisionEnter2D(Collision2D col) if (col.gameObject.tag "Coin") Destroy(col.gameObject) I've done everything in the book trying to solve this , re install unity , add different colliders etc. What's weirder is that it is FLAWLESS in Unity Remote and the Editor , these issues only arise when I test out the apk. Here's how my game usually looks when the collisions work. Now when it collides with a car ( on android) , it just ignores it and is slightly pushed back. Help me! Here is my script attached to enemy cars ( the cars that should destroy the player on Collision) using System.Collections using System.Collections.Generic using UnityEngine public class EnemyCar MonoBehaviour public float speed public float acceleration 0.5f Use this for initialization void Start () Update is called once per frame void Update () speed Time.deltaTime acceleration transform.Translate(new Vector3(0, 1, 0) speed Time.deltaTime) void OnCollisionEnter2D(Collision2D col) if (col.gameObject.tag "Coin") Destroy(col.gameObject) Also here is the inspector view of my Player Car Here is the inspector view of an enemy car ( they all have the same things) |
0 | How can I use Body tracking in Android using ARCore or some other libraries? I know that ARCore on Android doesn't support Body Tracking like ARKit does. But is there some alternative or workaround to achieve it? Some other SDKs or Libraries or maybe even if there is some way to do it through ARCore itself? To make it clearer I plan to use something like this in an AR game for Android. I plan to develop it in Unity 2019.4.x. My search result in Google didn't yield a useful result as it gets mixed with ARCore Motion Tracking (which isn't what I am talking about here) or implementation with ARKit. But I got a little hope that there might be some way out after reading this post on Unity Forums. |
0 | How can I draw gizmos and move the drawn gizmos when moving the transform in the editor in scene view? public void OnDrawGizmos() if( thisT null) thisT transform if(!Application.isPlaying amp amp posBuffer ! thisT.position startPosOffset) posBuffer thisT.position startPosOffset if( positionSphereDepth 1) positionSphereDepth positionSphere if( spawnSphereDepth 1) spawnSphereDepth spawnSphere Gizmos.color Color.blue Gizmos.DrawWireCube ( posBuffer, new Vector3( spawnSphere 2, spawnSphereHeight 2 , spawnSphereDepth 2)) Gizmos.color Color.cyan Gizmos.DrawWireCube ( thisT.position, new Vector3(( positionSphere 2) spawnSphere 2, ( positionSphereHeight 2) spawnSphereHeight 2 ,( positionSphereDepth 2) spawnSphereDepth 2)) posBuffer is Vector3 spawnSphereDepth is float The problem is that it's drawing the cube in the center of the scene view window and when I'm changing the transform position the cube Gizmo is not moving. Is there a way to draw the DrawWireCube so it will be position around the transform and when moving the transform that the gizmos draws will move with it too ? |
0 | Endless runner character stops moving unexpectedly I've been trying to make an endless runner game in Unity in which a player moves forward automatically and can move from x to y axis while still moving forward. I do not know how to program so I used a Template. Since then, my player stops moving forward when there is no box collider in front of it. it stops when there is a box collider by the sides and even when it's at the front. It's really frustrating. Below is the script I used using System.Collections using System.Collections.Generic using UnityEngine public class NewPlayerScript MonoBehaviour private CharacterController controller private Vector3 direction public float forwardSpeed public float maxSpeed private int desiredLane 1 public float laneDistance 4 public float jumpForce public float Gravity 20 void Start() controller GetComponent lt CharacterController gt () Update is called once per frame void Update() direction.z forwardSpeed if (controller.isGrounded) if(forwardSpeed lt maxSpeed) forwardSpeed 0.1f Time.deltaTime direction.y 1 if (Input.GetKeyDown(KeyCode.UpArrow)) Jump() else direction.y Gravity Time.deltaTime if (Input.GetKeyDown(KeyCode.RightArrow)) desiredLane if (desiredLane 3) desiredLane 2 if (Input.GetKeyDown(KeyCode.LeftArrow)) desiredLane if (desiredLane 1) desiredLane 0 Vector3 targetPosition transform.position.z transform.forward transform.position.y transform.up if (desiredLane 0) targetPosition Vector3.left laneDistance else if(desiredLane 2) targetPosition Vector3.right laneDistance transform.position Vector3.Lerp(transform.position, targetPosition, 80 Time.deltaTime) private void FixedUpdate() controller.Move(direction Time.fixedDeltaTime) private void Jump() direction.y jumpForce I really dont know what the problem is. I have the character controller and the sphere collider enabled in my inspector for my character and I have only the box collider enabled for my prefabs. |
0 | Unity Mirror client scene.local player.connection to client.client owned object not working in client U hmm I'm new to mirror networking I just wanna find objects that the local player has authority, but it doesn't work on client, is there a solution to this? Well I could make an object tracking script but that will complicate things. This question might look like I haven't research anything, truth is I've searched everywhere there is just no documentation for this |
0 | UniRx Subscribing to ReactiveProperty condition I'm trying to track a cold source with a contiguous range, and every example I've seen involves discrete increments or events that are already handled, so I'm vague on how to apply it. Here's what I have ReactiveProperty lt float gt CurrentAlpha new ReactiveProperty lt float gt (msg.GetComponent lt CanvasRenderer gt ().GetAlpha()) CurrentAlpha.Where(x gt x lt 0.0f).Subscribe(x gt Debug.Log( "CurrentAlpha CurrentAlpha Observed") img.transform.SetParent(null) Destroy(msg) ) I verified the alpha value, but never received notice when it reached 0. What have I mistaken? EDIT Found that it's actually subscribing to the value returned, which will always be 1. The value it receives is outside managed code, so there's no object property to observe, and CanvasRenderer itself doesn't observe it. Is it possible to observe a method's return value? |
0 | Mathf.Hermite not available in Mathf I see here that Hermite should be function in the class Mathf. However, when I try to use it, the compiler tells me that Mathf doesn't contain a definition for Hermite. This is an example float fNewDistance Mathf.Hermite( initialDistance, GoalDistance, fTime) What am I doing wrong here? Thank you! |
0 | How can I detect a long press then activate an animation? How can I detect a long press on a touch screen then activate an animation? And when the finger is released, play another animation smoothly? Let's take for example the main character in Crossy Road when the user presses down, the chicken "squats" and when the user releases their finger, the chicken jumps. Same concept. C . |
0 | Using a state pattern across multiple controllers general architecture advice I'm trying to implement a state pattern having skated by with enums forever and have hit a bit of a wall when it comes to it's implementation in my game. It's a grid based strategy game with an MVC hierarchy. The general flow is InputManager gt CursorManager gt GridManager. So if the player presses "Up", the InputManager will translate that to the appropriate action and notify the CursorManager. The CursorManager will then update the cursor's world position and then then prompt the GridManager to find what's in the hex in order to update the UI with terrain unit info. My new addition is thus having the GridManager change the cursor's state depending on what's in the tile. You pressed up? Let's let the cursor state dictate what happens to the grid. So naturally I created a cursor state object in the CursorManager, but suddenly realized each state needed decent amount of shared information across different the two controllers. For instance, public class FreeCursor CursorState public override void ActionPressed() currState gridManager.selectTile(cursor.position) So this means the FreeCursor state would need reference to the GridManager object, reference to the cursor GameObject, and also a reference to the current state itself. All 3 of those are already in the CursorManager, so it's no problem, just throw them all in a constructor FreeCursor(CursorState context, GridManager gridManager, GameObject goCursor) But d'oh, when gridManager.tileSelected() completes, it should return the new state. So the GridManager should be saying public CursorState selectTile(Vector3 position) ... return new FreeCursor(this) ...Except now we're missing the GameObject and the current cursor state, which aren't accessible in the GridManager. So I could go one or two ways make the GridManager also contain a reference to the context, so it becomes return new SelectedUnitState(this, CursorManager) and changes our flow to be InputManager gt CursorManager lt gt GridManager. Or I could say screw it, throw the cursor state and GameObject into the GridManager and call it day. ...But both feel just wrong? The latter through combining two somewhat distinct controllers the former by making the state be passed it's own containing object like a poor man's reflection or something. Because if I do that, I might as well just use Unity's GameObject.Find(Cursor). Am I wrong to think this? And if so, is the problem with my implementation of the state pattern or the way I've laid out my 'architecture'? tl dr How do you handle a state pattern with data from multiple controllers? Thanks! |
0 | How can I create a mirror with Unity? Can anyone explain how I can create a mirror effect like the one in this YouTube video using Unity Pro? I know that I need to use render textures to do it, but I am not sure how. |
0 | how to save Audio Volume to playerprefs to mute all scenes sounds Please Explain me how to Save or Set Audiolistner or scene Audio to playerprefs to control game all scene sound by a simple Button On and Off .. Please Give Me C sharp Script as a Example To Mute and UnMute Full Game All Scenes Sound from Scene 1. Thanks ..Waiting |
0 | How can I randomize my speeds just once, each time values are changed in the Inspector? private void SpeedUpdater() if (changeSpeedOnce false) foreach (WaypointsFollower follower in waypointsFollowers) if (randomSpeed) follower.speed Random.Range(minRandomSpeed, maxRandomSpeed) else follower.speed speed changeSpeedOnce true I'm calling SpeedUpdater from inside the Update. The problem is that if I'm not using the private flag bool changeSpeedOnce it will give each follower speed a random value every frame but I want that when it's random it will give each follower speed only one random speed value that is why I'm using the changeSpeedOnce flag. but then I can't change the speed in run time when the game is running because changeSpeedOnce is false now. I'm stuck here. From one side I want to give only one random speed value to each follower but I also want to do it any time in the run time when I'm changing the speed value in the Inspector. |
0 | Random Direction Vector Relative To Current Direction I have a 2D vector where the x and y values are randomly generated using a range between 1 and 1 respectively. I use this as the direction to move an object in which works great. var direction Vector2(Random.Range( 1f, 1f), Random.Range( 1f, 1f)) What I would like to do is after some period of time, randomly generate a new direction vector, but this time keep the same "relative" direction that it currently has. Probably within 45 degrees or so on either side of the current direction. So I'd like to randomly generate a new direction vector within a range of 45 degrees on either side of it's current direction vector, and start moving in that new direction. Does that make sense? I'm not quite sure how to go about this, but I'm sure this isn't too difficult if someone could help get me started. Thanks! |
0 | Unity3D, How do I press one key and then cant press another key while the one is pressed? I am making a horror game, and I want to press a key to look up while I am idle, that i've done but if I press the W key it stands in idle but floating forward. How can I disable the W key while I press the F key to look up ? Everything works fine I can press F and the LookUp Animation is being played and if KeyUp on F the Animation goes back to Idle. My problem is if I am in LookUp Animation when I press F, I can also press W to go forward but its floating not walking. I want to deactivate this function so I can just press F when I am Idle. Thanks for help. my Script public float speed 10f public Rigidbody rgb public Animator anim bool walk false Use this for initialization void Start () rgb.GetComponent lt Rigidbody gt () anim GetComponent lt Animator gt () Update is called once per frame void Update () float move Input.GetAxis ("Vertical") anim.SetFloat ("Speed", move) if (Input.GetKey (KeyCode.W) walk true) rgb.transform.position new Vector3(0, 0, 1) speed Time.deltaTime Debug.Log("Walking") else walk false Debug.Log("Idle") if (Input.GetKey (KeyCode.F)) anim.SetBool("LookUpIdle", true) rgb.transform.position transform.position else anim.SetBool("LookUpIdle", false) |
0 | Unity display message upon keypress? Hi I'm trying to get NGUI's HUDtext to display a set of text message one of which being "Try using WASD to move" and displaying "Well done!" upon input of any of the four keys. Unfortunately I'm not well versed in C and am currently stuck and unsure how to implement this. using UnityEngine using System.Collections using System public KeyCode KeyCode.Alpha2 public class Test MonoBehaviour public int seen 123 public HUDText hudText void Start() StartCoroutine(MyCoroutine()) Debug.Log(KeyCode) Tutorial () void Tutorial() while (true) while (!Input.GetKeyDown(KeyCode.Return)) Debug.Log ("Hit return") IEnumerator MyCoroutine() hudText.Add("Welcome", Color.white, 3f) yield return new WaitForSeconds(3) Wait one frame hudText.Add("This is System Defence", Color.white, 4f) yield return new WaitForSeconds(4) hudText.Add ("Try using WASD to move", Color.red, 3f) yield return new WaitForSeconds(3) I would appreciate it if someone could tell me how would I go about doing this. |
0 | How do i draw a ray in unity So i am trying to scrap together something for vr in which the locomotion is about the player holding the direction where he wants to go to(basically planning what he is going to do)while holding down the button a ray is beeing drawn and when the player lets go the character moves until he reaches the end of the ray i tried looking up something but couldnt find anything regarding something like this |
0 | Unity Adjusting 2D physics for different mobile resolutions I created a test project to see how different mobile resolutions affects Unity's 2D Physics. They way I handled the resolutions was to contain all the objects (including non UI objects) in a Canvas and use a Canvas Scaler component to adjust for multiple resolutions. Although this approach is probably not one of the ways the Canvas was not meant to be used, it works well when working with a single orientation. Despite the quick solution to handle the multiple resolutions, there seems to be the issue of the physics acting differently depending on what aspect ratio is being used. Images can be viewed here http imgur.com a p5wmf The green and blue blocks both have the Rigidbody2D and Box Collider 2D components. The floor (big white block) only has a Box Collider 2D component. As you can see from the images above, the different aspect ratios cause the blocks to collide with the floor at different times. Also, when using rigidbody.addforce in the Y direction, the different aspect ratios cause the blocks to jump at different heights. Obviously these issues could cause an unfair advantage in a game with support for several resolutions. So how would I go about adjusting the physics so that the blocks fall and jump at the same rates relative to the different resolutions? Also if there is a more practical way to adjust for multiple resolutions that doesn't involve a plugin and doesn't break physics, let me know! |
0 | Overlap transparent particles without blending? (Unity) I'm trying to create a continuous output of light from an object (like the exhaust of a space ship), and I thought I'd use particles to achieve this. But I'm running into a problem with alpha blending. I'd like to decrease the particle system's alpha over time, but because there's such a high density of particles, they end up evaluating to a solid color for most of the system's duration. This blog post basically shows what I'm trying to achieve https mispy.me unity alpha blending overlap The idea is to use a stencil test to make sure pixels in a sprite particle aren't gone if they're overlapping another sprite particle. Pass Stencil Ref 2 Comp NotEqual Pass Replace Then the author adds an alpha cutoff to make sure transparent pixels on an underlying sprite don't prevent new pixels from being written. half4 frag (v2f i) COLOR half4 color tex2D( MainTex, i.uv) if (color.a lt 0.3) discard return color But this solution requires you to eliminate soft edges, so I'm thinking it wouldn't look good in a particle system. The author also hinted at an alternate solution involving ZTest, but I can't visualize what that would be. |
0 | Script not working (Function not changing value) I have this script that I made for an FPS character. public class Player Movement MonoBehaviour public CharacterController controller public Transform camera public float gravity 9.81f public Transform groundCheck public float groundDistance 0.4f public LayerMask groundMask bool grounded public GameObject joystick public bool isMoving public float speed 12f public float turnSmoothTime 0.1f float turnSmoothVelocity public float jumpHeight public Vector3 yPosition public bool jumpAble true Update is called once per frame void FixedUpdate() grounded Physics.CheckSphere(groundCheck.position, groundDistance, groundMask) if (grounded) yPosition.y 2f jumpAble true Vector3 direction new Vector3(joystick.GetComponent lt Joystick gt ().inputDirection.x, 0f, joystick.GetComponent lt Joystick gt ().inputDirection.y) isMoving direction.magnitude ! 0 ? true false if (isMoving) controller.Move(direction speed Time.deltaTime) yPosition.y gravity Time.deltaTime UnityEngine.Debug.Log(yPosition) controller.Move(yPosition Time.deltaTime) public Vector3 Jump() UnityEngine.Debug.Log(jumpAble) UnityEngine.Debug.Log(grounded) if (jumpAble amp amp grounded) jumpAble false yPosition.y Mathf.Sqrt(jumpHeight 2 gravity) UnityEngine.Debug.Log(yPosition.y) UnityEngine.Debug.Log(yPosition) return yPosition return yPosition The game operates on mobile touch controls, and the Jump() is called when the jump button is pressed. However, the character does not jump when I press the button, even though the function is being called, and the yPoisition is being changed in the function. I know that changing the yPosition should make the player jump, as when I add this code to the Update if (Input.GetKey(KeyCode.Space) amp amp jumpAble) fallDown.y Mathf.Sqrt(jumpHeight 2 gravity) Everything works fine. Why is the new yPoisition value not being passed to Update, and why is this happening? |
0 | How can I play a YouTube video in Unity if given the YouTube URL link? How can I play a YouTube video in Unity if given the YouTube URL link? I am using 2019.4.13 Is there a way to open webpages? |
0 | Problem when importing fbx in Unity made in Blender First I will explain how do I make my object in Blender I want to make an object with a texture that have transparecies (png image). I unwrap my object and then apply the image to it in the UV editor. Then I export my object as fbx. To try the transparecy first I imported a PNG image as a plane on Blender and adjusted the necessary things in order to make work the transparency. You can appreciate the settings I used in the following image Until there is all fine. The problem appears when I import the fbx in Unity. The material that I created with the png image is not well visualized. When I import the fbx object in Unity, this messages appears in the Materials tab What do I have to set here in order to visualize well the image with its alpha channel working? Furthermore, if I try to change the material settings it is impossible because I cannot click the different options as they are disabled Can anybody tell me what I'm doing wrong? I don't know if my error is when creating the material in Blender or when I import the fbx in Unity. |
0 | Lighting changes when loading scene I have a script that changes the levels using Application.LoadLevel (sceneNameToChangeTo) Once a level is loaded using that code when testing with the editor, the lighting changes dramatically. I've checked if something changes in the light or lighting settings, but it doesn't. This is a screen of how the scene looks when I simply press RUN in the scene in the editor Notice the blue tints from the sky etc. This is clearly PBS lighting. Now after I use my code to change the scene to another one and then back to this one, the scene looks like this What am I doing wrong? I am using Unity 5.0.1. This effect does not happen on mobile devices. |
0 | (Hitbox) OnTriggerEnter2D only work if enemy is moving (UPTADE) I am developing a 2D Topdown Rpg Game. I have a problem with trigger colliders. I have button which make active an object and use it like Hitbox when i press button destroy enemy if it is touching hitbox but there is a problem about something. When i press button enemy is destroyed if only enemy is moving when it stop i cant destroy it How can I fix this? This is my hitbox's destroy script private void OnTriggerEnter2D(Collider2D other) if (other.tag quot Enemy quot ) Destroy(other.gameObject) |
0 | How to properly synchronize achievements on Google Play Services? I have a mobile game with achievements on android, so the achievements are using Google Play Services. For a couple of reasons, I must track the progress on the achievements locally (or so I think) because If the user is not connected to the internet Some achievements have complex "step" that the simple increment system provided by the Google Play Service (number of steps, current step) cannot track. When the game starts, the local copy data on the achievements is synced with what is on Google's server. Either both are the same, do nothing the local copy has more progress than what is shown on Google's so update Google data (that happens if you play offline) the copy on Google's server show more progress than locally so update the local data (that happens if you play on a different device) Clearly, there's a way to abuse the system here. Given two players with different achievement progress (Player A (lots of achievements), Player B (few achievements)) they can do the following Using Player B's device, Player B signs out of his account Player A signs in (the current active Google Account is now Player A) Start the game All of Player A's achievements are synced locally (they had more progress than the previous local version of Player B) Player A signs out and Player B signs in Re start the game the local copy will show as more advanced than Player B achievements, therefore they will get updated. How do people deal with this problem? Not care? Key the local achievement progress to the logged in player (which causes some problems)? Not to track anything related to the achievements locally (but how to deal detect being offline?) |
0 | Unity Apply different Near Far clip plane value for different layer I am Lerping the Near value of my camera, from 0 to 38, and it gives this result change near clip plane effect As you see, it gives a nice effect. But now I would like the effect to occur only for one specific layer. How can I do that? |
0 | Tire mesh rotates faster than wheelcollider in Unity I have a car in Unity. Scripts are C . I have noticed that my tire meshes' rotation is faster than whellcollider rotation. I am using this code for wheel rotation flWheel.localEulerAngles new Vector3(flWheel.localEulerAngles.x, flWheelCollider.steerAngle flWheel.localEulerAngles.z, flWheel.localEulerAngles.z) frWheel.localEulerAngles new Vector3(frWheel.localEulerAngles.x, frWheelCollider.steerAngle frWheel.localEulerAngles.z, frWheel.localEulerAngles.z) flWheel.Rotate(flWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) frWheel.Rotate(frWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) rlWheel.Rotate(rlWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) rrWheel.Rotate(rrWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) I found this from here Does anyone know how to fix this? Edit Using AquaGeneral's answer I could able to solve rotation problem. But now front right tire position changed to rear left tire position and rear right tire rotated 180 on Y axis. need help |
0 | How do I stop my skeleton from playing the walking animation? I'm trying to get a Skeleton Model to go from its walking animation to its idle animation using a bool that checks for input. Currently, in game, the skeleton doesn't leave its walking animation and stays in it even when not walking. Here is the code I'm using public class SkeletonMove MonoBehaviour private float velocity 5f public bool isWalking false Vector2 input void Update() GetInput() if (Mathf.Abs(input.x) lt 1 amp amp Mathf.Abs(input.y) lt 1) return Rotate() Move() void GetInput() input.x Input.GetAxisRaw( quot Horizontal quot ) input.y Input.GetAxisRaw( quot Vertical quot ) void Move() controller.Move(transform.forward velocity Time.deltaTime) anim.SetBool( quot Walking quot , isWalking) if (input.x ! 0 input.y ! 0) isWalking true if (input.x 0 amp amp input.y 0) isWalking false |
0 | How to rotate the transform only on the Y? private Update() Here the transform player should rotate facing the opposite direction. Determine which direction to rotate towards Vector3 targetDirection targetToRotateTo.position transform.position The step size is equal to speed times frame time. float singleStep rotationSpeed Time.deltaTime Rotate the forward vector towards the target direction by one step Vector3 newDirection Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f) Draw a ray pointing at our target in Debug.DrawRay(transform.position, newDirection, Color.red) Calculate a rotation a step closer to the target and applies rotation to this object transform.rotation Quaternion.LookRotation(newDirection) |
0 | How to divide sprite sheet, but keeping the in same png? first post here, but couldn't find an exact answer in your database, so guess I'll have to ask. I want to know how it is possible to create a ".META" file for a .png so you can extract individual sprites in a spritesheet without having to save all the sprites in individual .png's. I know it's possible since the developer in the tutorial HERE is using a spritesheet like that. Thank you very much in advance. |
0 | How to get the physical camera sensor size on iOS Android in Unity I'm trying to get the physical camera sensor size on iOS and Android mobile devices for intrinsics calculations. On Android the sensor size should be found in the SENSOR INFO PIXEL ARRAY SIZE (Android CameraCharacteristics API). However I don't find a way to access that array via ArFoundation. I can imagine to write a plug in for that, but I would also require a plug in for iOS so I don't know if that's the right way to go. Is there maybe another (easier) way to get the physical sensor size? |
0 | Unity Exporting and Importing Terrains To provide modding support via Unity editor, I need to export terrains in editor and load the exported terrain in runtime. Is this possible by any manner? |
0 | Unity2D Pressing my mute button twice in order for it to set music back to 1 So far my mute button works, its just that I have to press my button twice (when game is restarted) in order for it to put my volume back to 1. Does anyone knows the problem. Anyway this is my script public bool mute void Start() check if the player has a music volume preference if (PlayerPrefs.HasKey("musicVolume")) if yes, apply it. GetComponent lt AudioSource gt ().volume PlayerPrefs.GetFloat("musicVolume") private void Muted () AudioSource audioSource gameObject.GetComponent lt AudioSource gt () mute !mute if (mute) gameObject.GetComponent lt AudioSource gt ().volume 0 PlayerPrefs.SetFloat("mute", 0) else gameObject.GetComponent lt AudioSource gt ().volume 1 PlayerPrefs.SetFloat("mute", 1) write new music volume preference to persistent storage PlayerPrefs.SetFloat("musicVolume", audioSource.volume) Thank you. ) |
0 | Should I package and sell my game on the unity3d asset store? I'm trying to figure out if I should refurbish and refactor a game I and some friends have made. It's released on kongregate and wasn't a super hit but I feel there's a lot of interesting techniques and solutions going on that new or intermediate developers would like to see. The only thing that's holding me back is that I don't know if people are interested in it at all. Would you be interested in buying the source code and assets for this game? Check it out and you'll see that there's a lot of things happening in the game. If we packaged it and sold it, we would of course tidy it up a bit which would involve more work so I would really appreciate your honest opinion. We've looked around and haven't found actual released games in the unity3d asset store. Maybe we just didn't look enough though. We're thinking of setting a price tag of between 150 and 200 . What's your opinion on this price? And in general, what's your opinion on selling assets and source code? Should I be wary of any legal implications (like my customer licensing my stuff and then forbidding me from selling it)? I posted this over at UnityAnswers as well but I know I rather go here for gamedev questions so I'm hoping other unity devs will drop by here too. Edit Reconsidering after getting some great advice we'll probably rip out the assets only and market those as space stuff or something. We'll then market the assets with the help of some free classes of code showing off some of the examples that were hard for us to do when we were (more) beginners. The unify wiki might benefit from having some of the code that we've done and that isn't all that hard but a bit tedious. If we actually "finish" the game (it is indeed an asteroids spinoff and was never intended to be anything else, apart from some sandbox modes we've been experimenting with) we'll probably sell it with a decent price tag for an indie game like this. |
0 | Animator from another gameobject keeps disappearing from script on play I am working on a gun script and it worked fine until earlier today when I made a change to the script and it stopped working. I put it back, but for some reason now the animator object attached to the script keeps disappearing. using System.Collections using System.Collections.Generic using UnityEngine public class RifleShooting MonoBehaviour private float NextTimeToFire 0f private int CurrentAmmo private bool IsReloading false Space(10) Header("Floats") public float Damage 10.0f public float Range 100.0f public float ImpactForce 60f public float FireRate 15f public float ReloadTime 1.0f Space(10) Header("Others") Space(5) Space(10) Header("Others") Space(5) public int MaxAmmo 10 public Camera FPSCamera public Animator GunAnimations public ParticleSystem MuzzleFlash public GameObject impactEffect public bool AllowedToShoot true Start is called before the first frame update void Start() GunAnimations GetComponent lt Animator gt () if (CurrentAmmo 1) CurrentAmmo MaxAmmo private void OnEnable() IsReloading false GunAnimations.SetBool("Reloading", false) Update is called once per frame void Update() if (IsReloading) return if (CurrentAmmo lt 0) StartCoroutine(Reload()) return if (AllowedToShoot false) return if (Input.GetButton("Fire1") Input.GetButtonDown("Fire1") amp amp Time.time gt NextTimeToFire) NextTimeToFire Time.time 1f FireRate Shoot() IEnumerator Reload() IsReloading true Debug.Log("Reloading...") GunAnimations.SetBool("Reloading", true) GunAnimations.SetBool("IsShooting", false) yield return new WaitForSeconds(ReloadTime .25f) GunAnimations.SetBool("Reloading", false) yield return new WaitForSeconds(.25f) GunAnimations.SetBool("IsShooting", true) CurrentAmmo MaxAmmo IsReloading false void Shoot() shooting script here Also if it helps here is what I see in the console when I try to fire MissingComponentException There is no 'Animator' attached to the "M4A1" game object, but a script is trying to access it. |
0 | Dynamic items in Scrollable Vertical Layout overlap Unity I have followed steps from this tutorial site to create dynamic scrollable vertical layout. I am trying to show 10 prefab buttons in a scrollview dynamically. I can see buttons at runtime, but they are overlapped. ScrollPanel Content Container I am probably missing some components tweaks. Or problem is due to anchors? Please guide me to resolve this issue. Thanks. |
0 | What is a good way to code dialogue creation? I'm thinking of making a single method class something that will handle my dialogue in the game. AKA, something like Main text Choice 1 Choice 2 So I want a method that will able to put different strings into the main text section and also different strings into the Choice options. I've been thinking about solutions, and so far I've come up with just a simple method that accepts parameters for main text, choice1 and choice2 problem being that the strings called will be quite long and I think it looks a little clumsy? Also I won't want to have 2 choices every time, OR I want to have multiple "pages" of dialogue show up before you need to take an action. This would require me to overload methods which may turn out quite ugly? So yeah I don't have a lot of experience with this and method overloading is all I've thought about for now. I've given thought to interfaces abstract classes but I'm not entirely sure if they're even relevant for what I want to do. Any thoughts? |
0 | Unity Unable to blend 2D Light renderers I've followed the documentation on Unity regarding 2D lighting. It said to turn on Alpha blending in the options. But this is how it turns out If Alpha blending is off If Alpha blending is on I'm not entirely sure why it's turning black. These are my settings for the 2D light I've checked my layers, specifically the tile map floor, and it's on the Default layer. I just want my lights to blend well. |
0 | Unity 5 how to toggle realtime global illumination I am using Unity 5.5. Is there a way to enable and disable precomputed realtime GI at runtime? and if so, how can I do it? The idea is that I want to set dynamic lights as a graphics quality option that the player can choose to toggle. |
0 | How can I edit multiple sprites in Sprite Editor at once? I have 100 sprites in one atlas. I want to edit some of them with same values. For example, I want to edit sprite's position no 1 30. Do I have to edit them one by one? Is there any function like Shift drag for selecting several sprites? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.