As of May 31, 2023, we have updated our Code of Conduct.

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
11 votes
3 answers
4k views

Preventing a Combination of Rigidbody Jump Force & Bounce Magnitude in Unity3D

I'm building a fairly simple marble racing game in Unity3D. The ball is a 3D physics object that moves only on the X and Y axes. It has the ability to roll left and right, and to jump. Pretty basic ...
Ransom's user avatar
  • 111
11 votes
4 answers
3k views

Why do prefabs speed up loading?

I have a scene with a massive terrain. It took a long time to load (approximately 60 seconds) when I pressed play. I am in the editor. I prefabbed it. Now it only took about 5 seconds to load when ...
Evorlor's user avatar
  • 5,407
10 votes
2 answers
4k views

Generate random number in Unity without class ambiguity

I have a problem in Unity (C#) where I would like to create a random number. I wanted to use System.Random (reference: using ...
Sandra's user avatar
  • 111
10 votes
7 answers
9k views

How best to structure/manage hundreds of 'in-game' characters

I've been making a simple RTS game, which contains hundreds of characters like Crusader Kings 2, in Unity. For storing them the easiest option would be to use scriptable objects, but that isn't a good ...
paul p's user avatar
  • 370
10 votes
5 answers
13k views

Why can't I use the operator '>=' with Vector3s?

I am trying to get a rectangle to move between two positions which I refer to as _positionA and _positionB. Both are of type <...
Javier Martinez's user avatar
10 votes
3 answers
4k views

How can I shorten the length of time spent on finding a path using my A* pathfinding code?

I am working on a game where the player and enemies move between discreet tiles, with only orthagonal movement (like pokemon). The game also runs on a turn system, so the player makes a move input, ...
Kyle34562345's user avatar
10 votes
3 answers
3k views

Execute a function for ten seconds and disable it for two seconds

I have a particular function which I am calling in Update function. For the first ten seconds, the function should get called in Update function, then it should get disabled for next two seconds, then ...
MrRobot9's user avatar
  • 321
10 votes
2 answers
9k views

Why do Unity layer masks need to use bit shifting?

I've finally figured out why my layer masks for my ground collision code weren't working. I was using NameToLayer() to get the layer I needed, but layer masks use ...
Space Ostrich's user avatar
10 votes
4 answers
17k views

How to synchronize a game with music

You may be familiar with ryhtm games as Dancing Line, Geometry Dash, or even Guitar Hero. They have something in common : every single action in the game is synchronized with the music. My purpose is ...
Shashimee's user avatar
  • 1,220
10 votes
2 answers
2k views

Season Change Reveal Effect

I was watching the teaser trailer for Seasons After Fall, and I was struck by the effect they use to transition between seasons (around 21-24 seconds): The level art, including the background and the ...
Jessca Stone's user avatar
10 votes
3 answers
15k views

Unity Android versus android SDK

I am familiar with Unity and in the process of learning android SDK when the announcement about unity android basic came out. What would be the advantages and disadvantages of using the android SDK ...
lathomas64's user avatar
  • 1,352
10 votes
2 answers
21k views

What's the difference between Update and FixedUpdate in Unity, and should I bother?

I was told to use Update() for graphics and FixedUpdate() for physics, but sometimes my inputs won't register when I use ...
Tokamocha's user avatar
  • 427
10 votes
1 answer
2k views

Finding the correct speed for AI to turn to reach goal

I have a ship that travels at max speed maxSpeed and can turn rotationSpeed degrees per second. The ship always moves in the ...
weichsem's user avatar
  • 515
10 votes
3 answers
31k views

Is there a way to display navmesh agent path in Unity?

I'm currently making a prototype for a game I plan to develop. As far as I did, I managed to set up the navigation mesh and my navmeshagents. I would like to display the path they are following when <...
Sladix's user avatar
  • 223
10 votes
2 answers
4k views

Is white the best base color to start with when planning to shade sprites within Unity?

I'm looking into prototyping a game in Unity which will consist of solid square sprites / tiles. I figure I can represent different types of objects with different colors for each of the tiles in the ...
SpartanDonut's user avatar
  • 2,937
10 votes
2 answers
5k views

problem with git on a unity project

I tried to version control my project folder with git. When it came to pull the project from the repository, though, something went wrong: apparently scripts are missing and the prefabs and kind of ...
zhed's user avatar
  • 328
10 votes
3 answers
18k views

Unity: "inconsistent line endings" dialog shows up ever time I open VS with unity

Everytime I open a script file from unity with visual studio this dialog shows up about normalizing the line endings? What does this mean? I click Yes every time but still can't get rid of it. It only ...
Mark S's user avatar
  • 203
10 votes
1 answer
15k views

Animator Bool or Trigger?

I'm wondering about these two things. for what is better to use Bool rather than Trigger ? If i'm going to use Trigger, I should use it for what ?
user43474's user avatar
  • 537
10 votes
1 answer
34k views

How to create gui image with script

So I've been fiddling around with the new UI system recently -- and one problem I have is adding images of my sprites to the ui. I know I can create a prefab of an image gameobject with the sprite ...
nachime's user avatar
  • 261
10 votes
1 answer
587 views

Getting a 2D "pixel" cloud to follow a mouse

I'm working on a 2D game trying to get a "cloud" of a few hundred tiny cubes or discs to follow my mouse cursor without overlapping each other. However, using the physics engine introduces ...
Autio's user avatar
  • 203
10 votes
3 answers
8k views

What am I suppose to use instead of Unity Resources if I have to load and unload sprites at runtime?

I recently read this guide posted in the Unity website about Resources. It is clear from the get-go that it is discouraged to use Resources unless you are ...
Saturn's user avatar
  • 1,701
10 votes
1 answer
17k views

How can I get all DontDestroyOnLoad GameObjects?

I need to Destroy all DontDestroyOnLoad GameObjects. But in order to do this, I first need to find them all. I would prefer to automate this, opposed to having to ...
Evorlor's user avatar
  • 5,407
10 votes
3 answers
6k views

Can I run my own loading script during the Unity splash screen?

Can I load data in the background while the Unity splash screen is up? If so, how? I am trying to run code during the splash screen, not just load assets. I have not been able to find any ...
Evorlor's user avatar
  • 5,407
10 votes
1 answer
17k views

Angle between two points

I have a character who walks to random points in my room in Unity. The problem is he always faces one direction, I want to write in C# a piece of code that will get the direction the character is ...
Darren's user avatar
  • 151
10 votes
2 answers
2k views

Prototype experience: Unity3D vs UDK [closed]

Has anyone yet prototyped a game in both Unity3D and UDK? If so, which features made prototyping the game easier or more difficult in each toolkit? Was one prototype demonstrably better than the ...
LukeN's user avatar
  • 309
10 votes
2 answers
7k views

How do I flatten terrain under a game object?

I've got a script that makes a terrain object and paints it with textures, but I'm having an issue. When I attempt to place game objects (such as the simple water object that unity provides), I use a ...
Rapida's user avatar
  • 201
10 votes
4 answers
1k views

Calculating missile trajectory around orbits before shooting

I'm building a game with Unity3D. It's a Gravity Wars clone. Both player and AI turrets shoot missiles at each other (giving an Angle and a Power variables), trying not to crash missiles on planets. ...
Onofrio's user avatar
  • 101
10 votes
2 answers
5k views

Unity Occlusion Portals: What and How?

(Here I eat my words on Meta about posting Unity questions on Unity Answers... since that site is less responsive than this one.) Unity provides cell-based Occlusion Culling (via Umbra, I believe). ...
Engineer's user avatar
  • 29.3k
10 votes
1 answer
8k views

Can you embed a Unity3d mobile project into an existing native mobile app?

I am creating an application for both Android and iPhone that will have a few mini games in it. I would like to create the non game section in native Android and iPhone. My question is, is it possible ...
Bobbake4's user avatar
  • 315
10 votes
1 answer
7k views

Inline sprites in Unity's text?

How can I use different materials when using the tag for Unity's rich text syntax? I want to be able to have sprites that are inline with my text without having to create custom fonts. Here's what I ...
James Linden's user avatar
10 votes
1 answer
189 views

Why Can't I duck reverb on the mix bus in Unity?

i'm surprised there is so little documentation on this issue. But i'm trying to duck the audio on all the mix buses in Unity so that you can clearly hear the VO of the game. Now it works great except ...
Selcuk Bor's user avatar
10 votes
1 answer
1k views

How do I manually draw a part of a sprite sheet?

I'm working in Unity, and I'm finding that the animator isn't working for what I'm trying to do, in my 2D game. I want to build a specific animation, using sprite sheets, and be able to reuse the ...
Shaun's user avatar
  • 201
10 votes
2 answers
2k views

How to save the Mesh from an Interactive Cloth at runtime in Unity?

At the start of a scene I have GameObject called 'sheet' positioned above a 'ball' GameObject. The sheet has an Interactive Cloth component on it and a Cloth Renderer. The Mesh for the Interactive ...
RebDev's user avatar
  • 213
10 votes
2 answers
2k views

How to project a foam trail on dynamically changing mesh

I am trying to create water, and right now I got it through dynamically generating waves on a mesh. But now I want to make my boat manipulate these waves, and cause a Kelvin Wake on top of this. ...
Dimitri mx's user avatar
10 votes
1 answer
2k views

How can I Implement spin in billiard game?

I'm not sure that you played billiard or snooker before.if you played you should know about spin. but anyway if you don't know about it you can see it in this video I want to Implement spin like this ...
Seyed Morteza Kamali's user avatar
9 votes
4 answers
17k views

Why doesn't my C#6 code compile in Unity?

Why can't Unity work with C# 6 code? It always gives me compiler errors. Here are some code examples: ...
H. Pauwelyn's user avatar
9 votes
1 answer
7k views

How can I adapt A* pathfinding to work with platformers?

I have an A* implementation that works in "top down" situations where gravity is not taken into account for pathfinding. But, I am looking to modify to work in a 2d platformer situation. I am using ...
toinfiniityandbeyond's user avatar
9 votes
4 answers
4k views

Should Unity lifecycle methods be annotated with the UsedImplicitly attribute?

Does annotating Unity lifecycle methods with the UsedImplicitly attribute improve the readability of your code? For example: ...
sonnyb's user avatar
  • 596
9 votes
2 answers
2k views

How to make a field visible (attachable) in the inspector but inaccessible through code (private-like)?

Let's say I have a variable named button of type Button which is of course ...
Jacob's user avatar
  • 2,522
9 votes
4 answers
17k views

What are the differences between using GetComponent<Transform>() and this.transform?

I've been reading some example code and working on my own stuff in Unity. I've been seeing a lot of GetComponent<>(), and often this will be done for the ...
Gnemlock's user avatar
  • 5,233
9 votes
3 answers
14k views

What is the difference between transform.translate and rigidbody.velocity?

I've been tying to understand what the difference between these two methods of moving a rigid body are. Both seem to move the object at a constant rate and both operate on a RigidBody. So what's the ...
Robert's user avatar
  • 594
9 votes
1 answer
41k views

Unity 5 2D drawing sprites programmatically

How can I draw sprites in Unity 5 programmatically ? I am looking for something similar to spriteBatch.Draw() in XNA. The results I get when I search about it are ...
dimitris93's user avatar
  • 1,297
9 votes
2 answers
25k views

Button stays highlighted after being clicked - Unity3D 4.6 GUI

Sometimes, after clicking a button created by unity's new UI Button, the button stays in its highlight state. Note that Button script has Color Tint set as it's <...
Varaquilex's user avatar
9 votes
3 answers
28k views

How to dynamically create an UI text Object in Unity 5?

I have been searching for something that should be simple, but Unity 5's documentation on that is fairly outdated. What I want to achieve is to be able to create UI Text totally from script, i.e. ...
Kim Shutter's user avatar
9 votes
5 answers
40k views

Tiling of a material, independent of its size

I am using Textures and Materials to tile my sprites, for instance when building a wall in my game. The problem with this is that everytime I resize the plane or size of my game object, I have to ...
Enrique Moreno Tent's user avatar
9 votes
3 answers
16k views

How can I create a custom PropertyDrawer for my Point struct?

I created a Point struct: [System.Serializable] public struct Point { public int x; public int y; } I am trying to ...
Evorlor's user avatar
  • 5,407
9 votes
2 answers
8k views

Why does Unity3D crash in VirtualBox?

I'm running Unity3D in a virtual instance of Windows, using the Virtual Box software on Linux. I have guest additions installed with DirectX support. I've tried using Windows XP SP3 32-bit, and ...
Brigand's user avatar
  • 193
9 votes
2 answers
3k views

Coroutines in series

How would i go about stacking up a series of Coroutine calls that should be executed one after the other? I have tried getting a flashing color effect looping a series of color lerps in a coroutine ...
Daarwin's user avatar
  • 829
9 votes
1 answer
3k views

Moving texture according to position in shader

Divinity Original Sin have beautiful particle effect , When I move around game I see galaxy through particle that move according to my position.how can I make like it? you can see this effect here: ...
Seyed Morteza Kamali's user avatar
9 votes
2 answers
15k views

Best way to interpolate player movements in a very fast paced Unity game?

In my Unity online multiplayer game players move very fast and I currently use Lerp to interpolate between their last position and current position: ...
idn's user avatar
  • 171

1
3 4
5
6 7
318