Questions tagged [unity3d]

13012 questions
1

votes
1

answer
710

Views

WebSocket Server (Java) cannot read but send to C# (Unity) Client

For a project in university we should build a multiplayer game. Cause I have quiet a lot experience in Unity I want to use it as Game Engine. We have to use WebSockets for communication and json as protocoll to carry the data. So far so good. C# don´t have a default websocket implementation, so I u...
Snubs
1

votes
2

answer
502

Views

How do I serialize ScriptableObjects?

I'm using a save system I don't fully understand but works well. It saves serializable code, but I started using ScriptableObjects as a way to save inventory and it broke and I don't know how to fix it now. This is the code I'm using: [CreateAssetMenu(fileName = 'Attack')] public class PlayerAttckCa...
max anderson
1

votes
3

answer
245

Views

In Unity3d test scripts, how do I call a static function from another class?

I have two files in a Unity3d project. One is a test script that runs in edit mode. The other is a single class with static functions that I'd like to call from the test scripts. here's my test script: using UnityEngine; using UnityEngine.TestTools; using NUnit.Framework; using System.Collections;...
Brad
1

votes
2

answer
1.2k

Views

Reference assemblies for framework “.NETFramework,Version=v4.7.1” were not found

I try to open a Unity3D project with VSCode under Linux (Ubuntu 18.10). The omnisharp extension doesn't load the project, saying assemblies were not found. It may seems very stupide, but i'm don't really used to .Net yet, and i have been stuck with this error for quite some days now. I have been try...
Eyap
0

votes
0

answer
22

Views

Why isn't the AI following the player?

So I have written some code and everything works in it besides the AI following the player. I don't know what I did wrong so any help would be gladly appreciated! public class SharkAI : MonoBehaviour { public float speed; public Transform patrolPoints; private float waitTime; public float startWaitT...
Motm
1

votes
1

answer
22

Views

Unity3D , C# How to save position of objects and restart them later?

Dear StackOverFlow community, I need again your help in field of saving current position of objects in array. I need to save it because I want to restart level and their object to start position. I don't have idea how i can do it .. This is my code of objects and they moving as game proceed so I nee...
Simple aPPS
1

votes
2

answer
33

Views

How to remove window frame in game made in Unity?

So all my problem is illustrated in the title. When the game is launched and (for example) the windowed mode is chosen at the Configuration Window, how can I remove a window frame (where 'minimise' and 'close' buttons situated)? P.S. Maybe there were a solution before I asked but I couldn't find the...
1

votes
2

answer
49

Views

How do I destroy an instantiated game object clone?

I am trying to check if an object appears above a number. And if it does I want to destroy it and recreate it. And if it does not I want to create it. I have tried the following code. It creates the object but does not destroy it. GameObject newGameObject = null; if (x > 3.14) { if (newGameObject !=...
TeachMeEverything
1

votes
1

answer
90

Views

How to propertly proceed adding multiple scripts to a GameObject

My unity project is growing and I'm a little intimidated. I've created a Player that has a ton of scripts that are working together. (It will be even bigger lately tho.) This is how it looks like. All the scripts that the player is compound of inherits from a basic script that just contain some prot...
1

votes
2

answer
79

Views

Since the new version of MRTK i cant build a scene

Since i use the new version of MRTK, i get that building error (Unity 2018 3 12f1). How can i fix that? I had no issues with the old version, but in the old version i couldn't disable the spatial mesh render so it would disappear in my app. https://imgur.com/h6Xt35h The other solution would be, to g...
Leon Homburg
1

votes
2

answer
67

Views

Do People Have Access to Source code after it has been published?

after Unity games are published, are people able to access the source code of the games?
anaksky2k19
1

votes
2

answer
65

Views

How can i re-use a code in monobehaviour class?

First i'd like to give a short version of my question: How can i access another code pieces attached to another game object, or how can i initiazlie a class without have an game object attched. When i making a small game in Unity, i made an unit designer where you give some value such as how many we...
Ice.Rain
1

votes
1

answer
25

Views

How do I rearrange the execution order of solvers in Mixed Reality Toolkit?

MRTK's Solver documentation says that you can 'stack' solvers on the same object and their effects become cumulative. The Known Issues section implies that you can control which order the solvers are evaluated in, and that this can cause differences in behavior. How do I change the evaluation order...
Ecnassianer
1

votes
1

answer
44

Views

why it doesnt pass the Bool variable to another Class?

I wanna to open a door when the player's walks around on the trigger switch so i created 2 scripts and I set my Bool Variable on another Class but it doesnt work here is my Code on First class: internal bool openDoor=false; private void OnTriggerEnter2D(Collider2D door) { if (openDoor==true && do...
awrash pk
0

votes
0

answer
6

Views

Using custom shader results in black image

I use unity 2018.3.5f1. I would like to overlay a custom shader while rendering an image. Following is my onRenderImage Function. void OnRenderImage(RenderTexture src, RenderTexture dest) { // shaderMaterial renders the image with Barrel distortion and disparity effect Graphics.Blit(camTextureHolder...
user1241241
0

votes
0

answer
2

Views

VR Problem : Sprites are flickering on unity and when wearing VR

Whats up guys, I've been developing a Virtual Reality experience to a local museum where people in VR would have to walk through a corridor and each door has a simple 2D animation (Used Dragon Bones to animate it). The problem is: all of the illustrations that are animated have a lot of tiny details...
pedrlops
1

votes
1

answer
1.8k

Views

RectTransform tracking gameObject smoothly

I would like a RectTransform (panel) in Unity 4.6 to follow a worldObject. I got this working, but the movement is not as smooth as I'd like. It seems a bit jagged and it lags behind when I start moving the camera. Vector2 followObjectScreenPos = Camera.main.WorldToScreenPoint (planet.transform.pos...
larsekje
1

votes
1

answer
40

Views

Trying to setParent during update function gives error

I am trying to spawn a star at a set time interval in Unity. But I would like to parent these stars not to clutter my inspector. But when I try to do this it gives 'NullReferenceExeption: Object reference not set to an instance of an object.' I have used this type of code elsewhere succesfully befor...
Mark
-1

votes
2

answer
29

Views

How to break a cube into 2 pieces?

I'm looking for advice how can I break a cube into 2 pieces (in half) like in the picture below. How can I do it in a simple way by code? Do I need to first make one big cube from 2 pieces?
Igor
-2

votes
2

answer
21

Views

How to import number from scene 1 to scene 2?

How can I import number from another scene? For example: scene1 script if(...) { a = 1; } else { a = 0; } How to import a to the next scene?
1

votes
2

answer
2.7k

Views

Unity5, This renderer has more materials than the Mesh has submeshes

In Unity 5 I notice a warning that is not present in Unity 4. Is there any problem with it and how do I get rid of it?
Cù Đức Hiếu
0

votes
1

answer
14

Views

Gun Script Creates Bullet But Bullet Travel in All Different Directions

I am trying to create a gun script however after the bullet prefab instantiates, it doesn't travel in the correct direction(Straight). The function used to create bullets in Shoot() which is called when the Update loop gets the input from GetMouseButton(0). public class CharController : MonoBehavio...
Sage Hopkins
0

votes
0

answer
4

Views

Is there any way to stop the Trail Rotation with Player move?

Actually I'm making a space shooter type game. In which I'm adding trail to my player plane for this I'm using Trail Renderer this is the screenshot of my inspector. Now the problem I'm facing is as and when I rotate my player plane trail also rotate and I don't want that to happen since the player...
Aisha D.S.
1

votes
2

answer
2.2k

Views

How to use Gradle in Unity

Since I want to add Firebase to my Android Game I want to include Google Auth. But I have the following Problem. I need to add some Code to the build.gradle File but I cant find it in my Unity Project. Here is the manual I found from Firebase : https://firebase.google.com/docs/auth/android/google-si...
Rene Ungerer
0

votes
0

answer
2

Views

How do I go about using a server to store and retrieve data in Unity?

I have the task to implement a server into my Unity game which I must use to store and retrieve data. The thing is, I know nothing about servers and online databases. Where do I start? And what are the steps I need to stake to just store and retrieve a couple of stats from the game? Here is the task...
John Nguyen
1

votes
1

answer
65

Views

Switching between guns

Hello I'm trying to make a gun system and everything is working except Switching gun that stored in my GameObject array playerGuns, it always stores it on 0 and when I press another key it disabled every object that created. I want to make it so when you will press 1-4 key on your keyboard it will s...
Netanel
1

votes
2

answer
70

Views

How can I stop the characters rotations once they get to 0 on y?

using System.Collections; using System.Collections.Generic; using UnityEngine; public class AnimatorController : MonoBehaviour { public Animator[] animators; public Transform target; public float speed = 1f; public float rotationSpeed; private bool endRot = false; // Use this for initialization void...
Dubi Duboni
1

votes
1

answer
197

Views

Simply get the scaling of an object inside the Cg shader

Say you have a trivial Unity shader. It does not at all use any texture. It grabs simply the position .. void vert (inout appdata_full v, out Input o) { UNITY_INITIALIZE_OUTPUT(Input,o); o.localPos = v.vertex.xyz; } and then draws a square .. the quad in the example has been stretch about 3:1 usin...
Fattie
1

votes
1

answer
61

Views

How can I make one method to rotate multiple number of characters?

if (waitinganimation == true) { RotateCharacters(animators[2]); } if (!endRot) { Quaternion goalRotation = Quaternion.Euler(0f, 180f, 0f); float angleToGoal = Quaternion.Angle( goalRotation, animators[0].transform.localRotation); float angleThisFrame = Mathf.Min(angleToGoal, rotationSpeed * Time.del...
Dubi Duboni
1

votes
1

answer
48

Views

How to show a jagged array in Unity3d inspector?

I want to make a jagged array to order a group of waypoint systems. My problem is that I don't know how to show the jagged array in the Unity inspector so that I can fill the different arrays with the game objects I want (basically, squares of a board game). The game is a board game with different p...
kaitoren
1

votes
1

answer
98

Views

Can I programatically load scenes in the Unity editor?

I'm using the A* pathfinding algorithm for my 2D game (from my understanding, Unity Nav Meshes don't work in 2D). I would like to be able to pre-calculate navigation grids for all of my scenes, and save them in resource files that can be loaded whenever the player enters a new scene. Rather than h...
Ben Rubin
1

votes
2

answer
45

Views

how to remove a specific game object (that is in an array) from a list?

my goal with the code is to have multiple skulls appear on screen for comparison. Depending on number of skulls on screen (1-6) they change position and size, Ive done this through the use of an array of gameObjects (the skulls) and a list that can keep track of which skull is in which 'position'. T...
sarah mientka
1

votes
3

answer
149

Views

Unity: Convert Vector2 to Vector2Int

I have a Vector2 and I want to convert it into a Vector2Int. I know I could convert the Vector2 with something like this: Vector2 v2 = new Vector2(10, 10); Vector2Int v2i; v2i = new Vector2Int((int) v2.x, (int) v2.y); But is there a shorter or more effective way? For example something like this: v2i...
Timisorean
1

votes
2

answer
48

Views

Unity: LoadScene does not work when fired from timer

in my game, when the player dies, a dying sound is played and once the sound is over, the scene is supposed to be reloaded when the user still has enough lives. Before I had the sound, the play died instantly upon calling the death() function: public static void Death() { AddCoinScript.coinCounter...
innomotion media
1

votes
3

answer
46

Views

Changing color of text for specific amount of time in C# and Unity

I'm currently working on a game in Unity and I have a small problem. I'm trying to create an effect where the color of the ingame score counter temporarily changes color when the score counter gets incremented and then switches back to it's original color. However when I attempt to do this my game...
Maurice Bekambo
1

votes
2

answer
56

Views

underscore surrounded by backslashes

I am trying to concatenate some file name constituents to make sure if I already have an identically-named file, the new one gets a new name with an underscore and an incremental counter. I have written the following which I believe should work: string tempPath = Path.Combine(Application.dataPath, '...
Joshua
1

votes
2

answer
36

Views

Can someone tell me the difference between AddForce and transform.translate?

I am trying to move a gameobject but I found these two most popular functions to move the object. The difference I know between these two is that there is a rigidbody needed in using AddForce but no Rigidbody needed in Transform.translate. I just wanted to make sure that I am using right function fo...
Davinder Singh
1

votes
1

answer
60

Views

starting Coroutine gives null reference exception in unity

I am trying to access a Coroutine from my GameController.cs script, the Coroutine is located in my DatabaseManager.csscript. I am trying to access the Coroutine like this: DatabaseManager d1 = new DatabaseManager(); d1.uploadData(); This is giving me a null reference exception. I know that everythi...
PaPaB1nG0
1

votes
2

answer
47

Views

How do I connect a random array with an array that is related by subject topic?

I am making a little app to randomly pick a park in Disney world for me to go to, once I am at that park I then want to press the button- 'What should I ride?' for it to tell me what ride to go on in that part of the park it picked for me. Like if it said 'Go to Animal Kingdom' then when I press th...
Thickasastick
1

votes
2

answer
46

Views

Why is the game scene empty when I press “play”?

I'm trying to open up a game demo from my class to see what it looks like, but after opening up the project in Unity, going to the 'Game' tab on the upper part of the screen, and pressing 'play', nothing shows up. I'm new to Unity so I have no idea why the screen is blank (there should be a title sc...
Karen

View additional questions