Questions tagged [unity]

Unity is a cross-platform game creation system that focuses on easy art pipeline process. It consists of a game engine and an integrated development environment. The game engine's scripting is built on Mono.

Filter by
Sorted by
Tagged with
0
votes
1answer
53 views

Smooth behaviours at high Time.timeScale

When I set the Time.timeScale in unity very high, many scripts seem to do werid things (because of the high deltaTime they use for their logic). Is there an option ...
1
vote
1answer
51 views

Render order for 3D meshes

I want to highlight a certain item in an inventory. It is a 3D scene although it looks a bit 2D. That is confirmed. To do do that I have create a cube with a very small z scale (so that it looks like ...
0
votes
1answer
73 views

How can I snap player-constructed objects in a 3d world together?

I m trying to build minecraft type of game with more complex builds like that of fortnite, so I wanted to start with the best practices i have to follow to create those builds. the blocks in ...
1
vote
1answer
44 views

How to add noise into a texture?

I'm working on a Heat Map generated from Perlin Noise. So far I've got 2 different outputs. Let's go step by step: The result should be something like this: This is the Perlin Noise I've got, easy ...
0
votes
1answer
41 views

Unity3D - Finding every subclass of monobehaviour in current project with reflection

I am trying to find all types that inherit from monobehaviour inside my Unity project. So not the instances of them but the actual types in the assembly. I've tried this little piece of code and I don'...
0
votes
1answer
39 views

How do I make a GameObject carry across only 2 specific scenes?

I have a GameObject in my main menu and help scenes that I want to carry across both scenes but be destroyed on all other scenes. I am having multiple issues with it such as it wont destroy on other ...
0
votes
1answer
19 views

Unexpected velocity changes in unity

I have a character that moves with a rigidbody. When I jump, it looks fine, but sometimes, my character boosts up while in the air and shoots out of the map very quickly. I checked, and when it ...
1
vote
3answers
2k views

How can I exclude a range of values when generating random numbers?

If you are using Random.range to generate values, is there any way to exclude some values within the range (for example: pick a number between 1 and 20, but not 6 ...
0
votes
1answer
295 views

Unity2D Multiplayer - Spawning player at user's end

I am currently into a 2d mobile multiplayer project. Its going to be a 2 player game for now. So the host and the client are the only players. I am using Unity 5.4 and the default multiplayer ...
5
votes
1answer
3k views

What is the order of execution, when calling an instantiation method, in Unity?

In my GameManager script, I instantiate a player game object, and call another method like this: ...
0
votes
1answer
19 views

Method call order & instantiated component instances

I want to call things in a specific order. I'm trying to lay the foundation for my online game. Each player will have its own game object ("avatar"), which is instantiated at runtime. Each of these ...
0
votes
0answers
10 views

How can i show interstitial admob by click button moving to the next scene in Unity?

How can i show the interstitial ad admob in the action of click button to move in to the next scene, I'm already trying something which one you will see in bellow. *first method i'm creating a ...
1
vote
1answer
43 views

Loading a heavy scene behind some loading screen in unity

Is there a way to load a heavy built scene behind a loading screen in unity to not make the game look like stuck loading the scene rather show the player some loading bar that would help the player ...
1
vote
1answer
28 views

Debug.Assert Behavior in Unity

Is this normal behaviour that Unity continues to run after a condition in a Debug.Assert statement was NOT met when I launch the game within the Editor? I can see ...
2
votes
1answer
511 views

Unity5 TextAsset not functioning in WebPlayer

Preface I am working on a 2D Platformer in Unity5 utilizing TileMap techniques. I have a working system to read "Room Tile Data" from JSON files with the Unity <...
1
vote
1answer
414 views

In Unity/UNet: How do you properly spawn a `NetworkPlayer`?

In Unity/UNet: How do you properly spawn a NetworkPlayer? Right now, I'm doing it like this from inside a NetworkManager ...
0
votes
1answer
36 views

Error Handling in Unity

I try to understand what's the best way to handle error conditions in Unity. In a lot of places I've read that throwing exceptions is a bad thing. Unfortunately, I have not found any guidance on Unity ...
3
votes
2answers
1k views

Cardboard VR Mode rendering black in Unity

I've searched around and seen this problem is quite common, but none of the fixes I've read have resolved the issue: If VR Mode is enabled in the GvrViewerMain prefab, the scene will render as just a ...
0
votes
1answer
715 views

Google Play Games not working with Unity

I have been having real problems getting the Unity plugin for Google Play Games to work. At one point it was working great. Could login, write to leaderboard and save/fetch games. Suddenly it all ...
1
vote
1answer
37 views

How to fix double click problem in this code?

Please see the gif below to better understand what's going on. On first click they all work normally but after first click I have to double click them to select them. I'm not a advanced developer so ...
0
votes
0answers
14 views

Why is my TouchScript gesture event not firing?

I am using TouchScript (v9.0) with Unity (2018.2.14f1) and am struggling with getting the Flicked gesture event to fire. I created an empty game object with a few ...
4
votes
2answers
138 views

unity / blender — positioning items / clothes on character

I'm aware that in Unity, when you want to add (e.g.) a weapon to a character, you parent it to the "hand" bone of the character etc... Well I'm trying to add a hat to a character in unity when it's ...
0
votes
1answer
18 views

Unity - Access animation clips/motion of an animator

So I have an animator on my GameObject. I need to change the animation clip/motion of different states in my animator to the one I assign in my EditorGUILayout.ObjectField. Problem is, I have no idea ...
0
votes
1answer
15 views

Instantiate player prefab using player data

When my scene loads, I want to add my prefab to it along with its components. Here is what I mean: scene loads player gender is determined via playerprefs or playfab sdk player prefab is loaded and ...
0
votes
2answers
39 views

Changing animator via scriping

I am using the following code, my intention is whenever the 2 objects meet the animator boolean changes and when leave change back to its original setting. But it doesnt seem to work. ...
1
vote
2answers
59 views

Unity 2D: Smooth ease-out movement on grid

I'm trying to create a grid movement in Unity, as where the player will ease-out on a tile when stopping, but I can't seem to get it right. I need a little nudge in the right direction for how to ...
1
vote
2answers
86 views

Unity pattern for multiple game views

What are some proven and preferable patterns to realise multiple "screens" in the game? Not in the sense of displays (monitors) but "views" within the application. Say it's a Civ/Heroes-type game. We ...
0
votes
0answers
23 views

Unity 2D game object moving up in curve?

How can I make a rigidbody2d game object moving up curve like the attached screenshot?
2
votes
2answers
4k views

Writing and reading Computebuffer in a Shader

I'm trying to write into a Computebuffer in the fragment shader, but it doesn't work. Its pretty hard to get the Depth-Value in the Compute Buffer, so it would be so easy to just use the Pixel/...
0
votes
1answer
40 views

The camera goes up and down when following a rolling sphere

I have this CameraController script attached to my camera, to follow a sphere that moves using WSAD. ...
1
vote
1answer
136 views

Avoiding GC Allocation in Unity UNet API

I'm trying to profile the game using Unity Profiler, I can see in the Hierarchy tab that there's an 18.3 KB correlated to ...
3
votes
1answer
1k views

How do I get the networkId of an object?

My clients have a way of spawning "defense" barriers and I would like to limit the number of defense barriers per client to 1; A way of doing this is to destroy the old defense (if any) and then spawn ...
0
votes
1answer
39 views

Selling Android game with using Google Play Games

I'm making an Android Game that using Google Play Games for authentication, and storing user data to cloud. Originally I planned this game as free, and put some in-app-purchasement stuffs in it, but ...
0
votes
1answer
66 views

Is it really more efficient to have a local variable for transform here or is Rider being over-zealous?

I'm just going through a quick C# / Unity crash course (coming from Java) and I recieved a warning about "Repeated property access of a built-in component is inefficient" while working in Jetbrains ...
3
votes
2answers
4k views

Screen Space vs World Space Canvas

When should I use one over the other? I'm pretty sure I understand the key differences, but I'm not sure which use cases would prefer one over the other. For example, let's say I have objects on the ...
0
votes
1answer
37 views

Errors when building game to any platform

As a newer Unity user, I've never had this problem before. I looked around on the internet and didn't find any help except to reimported all my assets which did not help. I get these errors when ...
0
votes
1answer
31 views

Unity: Bizarre Physics FixedUpdate Lag spikes

So I have this large forest of around 2M tris: Same chunk selected with view on the whole level: It's been generated within Blender and exported as fbx into Unity. Exporting each tree as an ...
1
vote
1answer
135 views

In Unity, how do I set constant player numbers such that all network clients agree on them?

We are currently writing an online game in Unity. The essential idea is that it is structured like a split-screen, couch co-op game, with the online being offered as an extension to allow multiple ...
0
votes
1answer
18 views

How can I apply UV mapping in parent space?

I'm trying to apply UV mapping in parent space - ie. taking into account the object's own transformation matrix but no matrices further up the transformation hierarchy. For example, I'd want to be ...
0
votes
1answer
1k views

Finding the closest point on a concave mesh (Unity C#)

One of my game systems requires that I find the closest point on a generalized mesh, which more often than not will be concave. This prevents me from just using Unity's built in ClosestPoint function, ...
0
votes
2answers
30 views

How to access specific child indices (directly, not using tags or searches)?

I have a game object whose prefab is structured a very specific way. It is a conveyor belt. I intend to arrange them end-to-end and animate them all at once using a script. Right now I am trying to ...
0
votes
1answer
71 views

Unity not redrawing sprite, after sprite change

I am making a game where the player mines dirt by walking on it: So, I created a scene and added a bunch of dirt to a grid, from a dirt prefab. When the character walks on a square, it is supposed to ...
0
votes
1answer
30 views

My script to play the intro scene the first time the player hits play from the main menu wont work

The script I am using determines if it is the players first time hitting the play button and if it is it will load the intro scene, but if they have played before it will take them strait to the game ...
0
votes
1answer
34 views

Unity 2D launch player towards mouse location

few notes: I'm new to game development I'm not new to developing (1 year of front end web development) I'm trying to get my character to launch towards mouse left click button (which I understood to ...
2
votes
1answer
116 views

Load order of networked objects in Unity

I am making a 2D RTS, and am trying to get a multiplayer version working. I've run into some problems with the order that scripts are getting executed. For the host everything runs fine, but when a ...
1
vote
1answer
38 views

Edit existing editor inspector?

I want to write custom inspector for one of my scripts. All I want to change is input method for one of the strings to popup (so instead of writing whole string everytime I choose it from premade list ...
0
votes
3answers
34 views

Player going out of boundaries

So, I been following up the Space shooter tutorial on Unity, I had an issue where the project was acting up with an alpha version, so I was able to get a version that worked on a old release and ...
0
votes
0answers
13 views

Colliders along the edge of the sprite

I am trying to make a collider along the edges of my sprite, something like what an outline shader does. I tried adding a polygon collider 2D as you can see below but it doesn’t take the shape of the ...
0
votes
1answer
41 views

Struggle with resetting coroutine

A little bit of context; I'm still not experienced at this, I'm creating a 2D platformer and this is my enemies script (some part of it). This is supposed to be a minatour, which charges towards the ...
0
votes
3answers
57 views

Instead of using yield wait for seconds can I use a UI button for async?

the code below is the code I use to load my game scene ater the intro animation plays. The way it works is that it preloads the game scene because it is big enough it takes time to load and activates ...