_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
0 |
Limit Color Pallete Using Shader (Unity) Basically, what I want to do is take a primary input image texture (which is a render texture in game) and a secondary pallete texture (contains X number of colors, and is X by 1 pixels in size). What I want to do is replace all of the pixels in the image with the most similar color in the color pallete texture. I made a stab at producing the effect, but at the moment, it only seems to return the first color in the pallete. Below is my (nonfunctional) version. I'm new to shaders, so sorry for the potentially very sloppy basic shader code. Shader "Custom Limiter" Properties MainTex ("Texture", 2D) "white" PalTex ("Pallete", 2D) "white" SubShader No culling or depth Cull Off ZWrite Off ZTest Always Pass CGPROGRAM pragma vertex vert pragma fragment frag include "UnityCG.cginc" struct appdata float4 vertex POSITION float2 uv TEXCOORD0 struct v2f float2 uv TEXCOORD0 float4 vertex SV POSITION v2f vert (appdata v) v2f o o.vertex UnityObjectToClipPos(v.vertex) o.uv v.uv return o sampler2D MainTex sampler2D PalTex fixed4 frag (v2f i) SV Target float4 baseCol tex2D( MainTex, i.uv) float4 palCol tex2D( PalTex, 0) float palDiff 1000 for (int p 0 p lt 37 p ) float baseColDiff abs(tex2D( PalTex, p).r baseCol.r) abs(tex2D( PalTex, p).g baseCol.g) abs(tex2D( PalTex, p).b baseCol.b) palDiff min(palDiff, baseColDiff) palCol (abs(palDiff baseColDiff) lt 0.001) ? tex2D( PalTex, p) palCol return palCol ENDCG Any help would be greatly appreciated! I feel like it's a relatively simple problem to solve, but I couldn't find any examples of existing shaders like it, or any resources describing it. Edit This shader works... sort of. It has been picking the nearest color, but it has only been picking two yellow colors out of the pallete. I tried removing those colors, and it then chose to use only an orange. I don't know if this will help anyone, but I thought it was at least mildly interesting.
|
0 |
How can I disable an NGUI button when I pause my game? There is an NGUI button in my game, which when pressed increases the player's power. When I press the escape key, my game pauses completely. But the button still functions normally. Here's how I check for pausing void Update () if(Input.GetKeyDown("escape")) if(isPaused amp amp Time.timeScale 1.0f) Time.timeScale 0.0f AudioListener.volume 1 else Time.timeScale 1.0f AudioListener.volume 0 I'd like the button to be deactivated when the game is paused. It should be visible, but not be clickable or anything. How can I achieve that?
|
0 |
Unity Car Rollover Protection I have a standart Unity car with Unity Car physics. What would be the best approach to protect my car from a rollover? I dont want to mess up and try and error 10 different approaches, so maybe here is an expert who really knows how to do it right? I couldnt find anything decent on the internet.
|
0 |
UnityEditor.SyncVS.SyncSolution putting wrong language version in generated files I'm working on getting our Unity projects building in bamboo for our build server. We have a cli step that runs through the Unity commands for creating a build. It works fine on several projects, but for some reason this particular project I'm working on I'm getting an error that states I need to use c version 7.2 or newer. If I log in to the build server and open the .csproj files in notepad and check the language version, it's setting them to 7.0. However, if I deactivate the cli step so that the build job only clones the project, then manually log in and open unity and go through the process so it generates the .csproj files, then check them, the language version is set to 8.0. The project works fine locally on my own pc. And it works when setup manually on the build server pc, but when ran through the cli step, it generates them at an earlier c version. This leads me to believe there is a problem with the UnityEditor.SyncVS.SyncSolution step in my commands. I'm just not sure what it could be, or why it's behaving differently for this project as opposed to other projects that are using the same code base (where the problem is said to occur), same Unity version, same build server, etc. Anyone else experience this issue or have any thoughts on a solution?
|
0 |
HDR bloom techniques using post processing in Unity3D I've seen many posts on how to accomplish HDR bloom effects in Unity3D using its (now legacy) Bloom component as part of the standard assets package. I'm trying to replicate it using the new post processing package, but I can't seem to get it to work. I have an an emissive material that's emitting at a value far 1 sitting at 10 Bloom is set in a Post Processing Profile, and the threshold is 1 Finally, HDR is enabled on my camera, along with a deferred rendering path. Yet this doesn't work. I only see the bloom effect if I set my bloom threshold lt 1, after which all my materials bloom. It's as if HDR is not actually enabled. Anyone know why?
|
0 |
Rotating gradually in response to input, instead of snapping I'm trying to replicate Silent Hill's mechanic where if you press a button, the character does a 180, but instead of getting a smooth turn around, my character is snapping from one rotation to another. This is the code I have so far if (Input.GetKeyDown(KeyCode.Tab)) transform.Rotate(0f, 180f, 0f) I also have a Sprint() function and I want to disable this feature if the character is sprinting. Here's the code for that private void Sprint() float newTurnSpeed turnSpeed 1.4f vertical Input.GetAxis( quot Vertical quot ) horizontal Input.GetAxis( quot Horizontal quot ) Vector3 direction new Vector3(0f, 0f, vertical) Vector3 movement transform.TransformDirection(direction) sprintSpeed transform.Rotate(0f, horizontal newTurnSpeed, 0f) add the new turn speed isGrounded characterController.SimpleMove(movement) Any help is appreciated!
|
0 |
Why this if logic isnot short circuiting? I've this script in UNITY to check if the hit RayCastHid2D variable has some gameobject with hole tag or a parent gameobject with hole tag when I Raycast... if (hit.collider ! null amp amp (hit.collider.gameObject.tag "hole" (hit.collider.gameObject.transform.parent.gameObject ! null amp amp hit.collider.gameObject.transform.parent.tag "hole"))) Everything is fine until if (hit.collider ! null amp amp (hit.collider.gameObject.tag "hole" but when I enter (hit.collider.gameObject.transform.parent.gameObject ! null amp amp hit.collider.gameObject.transform.parent.tag "hole") it throws a NullReferenceException.... But why? It supposed to short circuit here hit.collider.gameObject.transform.parent.gameObject ! null amp amp if there's no parent gameobject!
|
0 |
Issues accessing arrays in Unity I'm trying to make a mini quiz game, but I'm stuck. I'm showing questions, randomly, but the first question never comes up. Furthermore, when I set the size of the questionsNumberChoosen array to 10 and run the game, it crashes. public struct Question public string questionText public string answers public int correctAnswerIndex .. we also construct the Question, directly providing all values. public Text questionText public Button answerButtons private Question currentQuestion private Question questions new Question 10 private int questionNumbersChoosen new int 9 private int questionsFinished void Start () questions 0 new Question("1", new string "A", "A", "A", "A", "A" , 2) questions 1 new Question("2", new string "A", "A", "A", "A", "A" , 0) questions 2 new Question("3", new string "A", "A", "A", "A", "A" , 4) questions 3 new Question("4", new string "A", "A", "A", "A", "A" , 0) questions 4 new Question("5", new string "A", "A", "A", "A", "A" , 0) questions 5 new Question("6", new string "A", "A", "A", "A", "A" , 2) questions 6 new Question("7", new string "A", "A", "A", "A", "A" , 0) questions 7 new Question("8", new string "A", "A", "A", "A", "A" , 4) questions 8 new Question("9", new string "A", "A", "A", "A", "A" , 0) questions 9 new Question("10", new string "A", "A", "A", "A", "A" , 0) setQuestionIndex () assignQuestion (questionNumbersChoosen 0 ) void assignQuestion(int questionNum) currentQuestion questions questionNum questionText.text currentQuestion.questionText for (int i 0 i lt answerButtons.Length i ) answerButtons i .GetComponentInChildren lt Text gt ().text currentQuestion.answers i public void checkAnswer(int buttonNum) if (buttonNum currentQuestion.correctAnswerIndex) print ("Correct!") else print ("Incorrect!") if (questionsFinished lt (questionNumbersChoosen.Length 1)) moveToNextQuestion () void setQuestionIndex() for (int i 0 i lt questionNumbersChoosen.Length i ) int questionNum Random.Range (0, questions.Length) if (!isContain (questionNumbersChoosen, questionNum)) questionNumbersChoosen i questionNum else i bool isContain (int num, int numbers) for (int i 0 i lt num.Length i ) if (numbers num i ) return true return false public void moveToNextQuestion() assignQuestion (questionNumbersChoosen questionNumbersChoosen.Length 1 questionsFinished )
|
0 |
What is the best option to implement buttons as player controls? I am familiar with programming, but new to Unity. There seems to be a million ways to implement a right and left button for turning the plane. I'm wondering what the standard easiest best way to do this would be. Do I make a single script that references the two sprites "left" and "right" and then detects mouse clicks and figures out whether they are over the sprite? Should the buttons even be sprites game objects? Or is there a better option for UI objects? Should the left and right buttons both have their own scripts? ps. I absolutely can't stand video tutorials, and it seems like that's all there is for unity '( so if there is a good written tutorial on unity desgin patterns, let me know please )
|
0 |
Room lighting in Unity I am trying to make a plain white room in Unity. I used six planes for the walls, but I can't figure out how to get the lighting to not look so harsh and uneven. The top picture is my best attempt using two directional lights, and the bottom picture is the look that I am trying to replicate. It is from a demo scene in the Google VR SDK 1.50 for Unity. It uses only a single point light, but when I turn it off in the scene view, it doesn't change the appearance of the room at all. How can I make my room look more like the Google VR demo? EDIT I made a big improvement by changing all my walls to be static so that they receive indirect lighting, and adding a single point light above the roof.
|
0 |
How can I stop and resume a coroutine over and over again? I want a coroutine to enter by default and then to stop when any input is given to it but then after some code to return again as active. So basically to start and stop a coroutine as many times as it's needed.
|
0 |
Unity applying forces using animation I'm trying to make a croquet mallet swing to hit the ball using an animation that rotates the mallet mesh. The mesh appears correctly positioned to hit the ball in the center but the ball doesn't go straight. Using a script with rigidBody.AddForce works fine. I do have Animate Physics selected on the animator and have explored many other options. Is there a way to debug the physics in this situation? Am I going about it the wrong way to use an animation to apply a force? This is what it looks like now
|
0 |
With gravity enabled, how do you move a RigidBody forwards at a specific speed? I have a perfectly smooth cube on top of a perfectly smooth plane. I am applying a forward force of 1 unit per second, using rigidBody.AddForce(new Vector3(0, 0, 1), ForceMode.VelocityChange). I apply this force every FixedFrame(), taking into account Time.fixedDeltaTime, of course. When the "Use Gravity" checkbox on the RigidBody is not checked, the object behaves as expected after exactly 3 seconds, it has a speed of exactly 3 units per second. However, when I enable the "Use Gravity" checkbox, the object barely moves. Both the object and the surface are using Physic Materials with zero friction, and the moving object's RigidBody has zero drag and zero angular drag. Why does this happen? And more importantly, how would I apply a force to this object so that it moves forward at, say, exactly 3 units per second, with gravity enabled? Thank you.
|
0 |
Unity won't Instantiate() outside of Start(), even though code is the same I am trying to add a gameobject to my game using a socket connection. I have a SocketHandler class, which simply connects to my NodeJS socket server, which can also call a method on another class, which will add a new gameobject to the game. Here is how it basically works void Start () GameObject car Instantiate(CarGameObject) car.transform.parent this.transform car.GetComponent lt TestCar gt ().text.text "Volkswagen" This works fine and it adds the gameobject to the game upon starting. However, if I do something like this in my SocketHandler, it doesn't work var addCar new AddCar() socketio.On("addCar", (data) gt string str data.ToString() Car data2 JsonConvert.DeserializeObject lt Car gt (str) addCar.AddNewCar(data2) ) and then inside my AddCar class, I have the AddNewCar() method public void AddNewCar(Car input) GameObject car Instantiate(CarGameObject) car.transform.parent this.transform car.GetComponent lt TestCar gt ().text.text input.name it does not work. If I do a Debug.Log(input.name) inside the AddNewCar() method, it does log the name the server sends. It should do the exact same thing, but the AddNewCar() doesn't get added to the game. It simply does nothing. What could be wrong?
|
0 |
Building multiple android apps via script does not trigger Resolving Android Dependencies I have a Unity Project which builds a number of smartphone android apps Anytime I need to build an app I have a script (SetupApp) that move a bunch of assets in the Resources folder and changes the package name. As far as I understood changing the package name triggers the tedious process of Resolving Android Dependencies , because all the various libraries in Plugins Android need to be recompiled. So far so good. Recently I tried to create a multi builder, basically it s a script (MultiBuilder) that takes all the applications that need to be created and, before each, calls SetupApp and then calls BuildPipeline.BuildPlayer My issue is that when MultiBuilder calls SetupApp the Resolving Android Dependencies is not triggered, creating all the app with the same (wrong) dependencies. Some thoughts Is there a way to force by script the Resolving Android Dependencies process? Is there a way to wait for the resolving process to be finished and the continue the building process? Is there a better way to do so? This goes really beyond my understanding of Unity, any help is very welcome. Thanks
|
0 |
How do I use GetComponent on multiple children? I'm a beginner and I'm making a game in Unity where I set random colors for four enemies. I made an empty object called "enemies" for me to use it as a folder for the four enemies. I want to get the colors of the enemies and pick randomly one of them for my player. I wrote this piece of code and I wanted it to store the colors in a list, but whenever I try to print it I find out that it only stores the color of the first child in the "enemies" hierarchy. How do I fix this? enemies GameObject.Find("enemies") GameObject allenemies new GameObject enemies.transform.childCount List lt Color gt colors new List lt Color gt () foreach (Transform child in transform) allenemies i child.gameObject i foreach (GameObject child in allenemies) thecolor enemies.GetComponentInChildren lt Renderer gt ().material.color colors.Add(thecolor) finalcolor Random.Range(0, colors.Count) Debug.Log(finalcolor) mr.material.color colors finalcolor
|
0 |
Does Unity own my game? I made my first game in unity, and I was wondering if I can sell it without owing anything to unity?
|
0 |
Unity Mask shows black content in world space canvas (Vuforia) So I've built my scroll rect, like this reference tells me to do http docs.unity3d.com Manual script ScrollRect.html Scroll View (Rect Transform with scroll rect attached) Viewport (Image Mask attached) Content (Image attached) In scene view it looks like I want it to look like, but in play mode it looks like this, which is the correct shape, but obviously not the correct content Update My Canvas Update The Image is getting displayed normally, when I disable the mask. Update The source of this problem seems to lie in Vuforia (Image Object Tracking library) since Vuforia appends a ClippingMask to the cameras
|
0 |
Unity How to use delegates with EventManager ? and use variable number of arguments in listenners? As answered here, I would like to know how to implement an EventManager with delegate instead of UnityAction for pass arguments. I tried but I did not succeed. Also, can someone tell me if it's a better solution than following ? And is it possible to change this code for invoke listenners with a variable number of arguments? using UnityEngine using UnityEngine.Events using System.Collections using System.Collections.Generic namespace Assets.Scripts System.Serializable public class Event UnityEvent lt System.Object gt public class EventManager MonoBehaviour public static EventManager Instance private Dictionary lt string, Event gt eventDictionary private void Awake() ... public static void StartListening(string eventName, UnityAction lt System.Object gt listener) Event thisEvent null if (Instance. eventDictionary.TryGetValue(eventName, out thisEvent)) thisEvent.AddListener(listener) else thisEvent new Event() thisEvent.AddListener(listener) Instance. eventDictionary.Add(eventName, thisEvent) public static void StopListening(string eventName, UnityAction lt System.Object gt listener) if (Instance null) return Event thisEvent null if (Instance. eventDictionary.TryGetValue(eventName, out thisEvent)) thisEvent.RemoveListener(listener) public static void TriggerEvent(string eventName, System.Object arg null) Event thisEvent null if (Instance. eventDictionary.TryGetValue(eventName, out thisEvent)) thisEvent.Invoke(arg)
|
0 |
What's the size of library in unity for android? In unity3d what is the size of library compiled into apk. Is that affect when i make game without any physics(2d or 3d) or when making 2d or 3d game.
|
0 |
Resuming a previous scene from a current scene using the Unity3D I am building a first person shooter game using unity and I am facing the problem of resuming a scene from its current state. It would be easy to pause the scene by using the Time.timeScale 0.0 within the scene itself. But I am loading a pause scene to ask whether the user wants to restart, resume or quit. But when I click on resume, it loads the scene I want, but it is totally fresh (i.e when the Ammo is supposed to be half full, it is full. Or the enemy has lost a part of his life, but then it starts with life completely full) How do I resume the previous scene from where it left off using SceneManager? This could have been somewhat easy by using the Application.loadLevel() and making sure that application does not destroy the previously loaded state. Here is the script I made for the pause scene. using UnityEngine using UnityEngine.UI using UnityEngine.SceneManagement using System.Collections public class pauseScript MonoBehaviour Use this for initialization void Start () Update is called once per frame void Update () public void exitPressed() Application.Quit() public void restartPress() SceneManager.LoadScene("prototype1") public void resumePress() SceneManager.LoadScene("prototype1") Here is the code snippet for calling the pause menu scene. and this is in another script. SceneManager.LoadScene ("PauseMenu") Is there anyway to save the current scene before calling the PauseMenu scene as shown in the above statement? This may be a simple enough query to you but I am completely new to game development as a whole and I am using unity for the first time, so please go easy on me. Thanks
|
0 |
object reference not set to an instance of an object hello i have a error "object reference not set to an instance of an object" when my ball collide with the spikes.its supose to remove one heart but it doesnt. health code using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class Health MonoBehaviour public int health public int numOfHearts public Image hearts public Sprite fullHeart Use this for initialization void Start () Update is called once per frame void Update () if (health gt numOfHearts) health numOfHearts for (int i 0 i lt hearts.Length i ) if (i lt health) hearts i .sprite fullHeart if (i lt numOfHearts) hearts i .enabled true else hearts i .enabled false public void Damage(int dmg) numOfHearts dmg spikes code using System.Collections using System.Collections.Generic using UnityEngine public class Spikes MonoBehaviour private Health Player Use this for initialization void Start () Player GameObject.FindGameObjectWithTag("Player").GetComponent lt Health gt () Update is called once per frame void Update () void OnTriggerEnter2D(Collider2D col) if (col.CompareTag("Player")) Player.Damage(1) here i have the error.
|
0 |
Camera bounds grow along with the game scene editor in Unity I am extremely confused by the Unity editor. Look I have an image, And I want my camera to fit it perfectly. I have achieved so by using a size property of 540 Notice how the viewport rect has 1 width and 1 height. If you run this game in a Samsung Galaxy S5, the sprite will fit perfectly in your device. Now, resize the game scene view a bit (drag the Unity window border outwards to make it grow). Let's make it bigger. Then this happens The camera "white bounds" grew bigger! And the sprite no longer fits perfectly in the Galaxy S5! My question is, then why did the camera's bounds grow along with the editor window, if the viewport rect property never changed (it is still at 1 width an 1 height)?
|
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 randomly generate objects inside of a Complex Area? In my game, I want to generate randomize enemies inside of this green area that I made with a custom editor tool.
|
0 |
Changing color for each element in linerenderer not working I want to change color for each line (element) just like in color switch. But my code is not working. What I wanted is that the right line should turn blue then the down line should turn color red. What is wrong with my code? void Start() lineGeneratorPrefab new GameObject() DrawLine() private void DrawLine() GameObject myLine new GameObject() myLine.transform.position start myLine.AddComponent lt LineRenderer gt () LineRenderer lr myLine.GetComponent lt LineRenderer gt () lr.positionCount 4 lr.SetPosition(0, new Vector3( 2, 0, 0)) lr.SetPosition(1, new Vector3(2, 0, 0)) lr.SetPosition(2, new Vector3(2, 2, 0)) lr.SetPosition(3, new Vector3( 2, 2, 0)) lr.materials 2 .color Color.blue lr.materials 3 .color Color.red
|
0 |
Limiting interaction between certain RigidBodies I'm developing a 2D game in Unity and have been tasked with building a particular feature I'm not sure how to accomplish with Unity's physics engine. To simplify, a bunch of objects of type X and O are filled into a pit XXXXXXXXXXXX XXXXXXXXXXXX XXXXXXXXXXXX XXoXXXoXXXoX Both objects have Rigidbody2Ds and colliders. Objects of type X have normal gravity and should settle into place. Objects of type O have inverse gravity and should float. However, O should not be able to push X, and X should not be able to push O. Another way of looking at it is that O should only be able to move upward, and X should only be able to move downward. If we remove some of the Xs directly above an O, the O should float upwards as the Xs fall downwards until the Xs settle on top of the O and everything stops moving XXXXXXXXXXXX XX XXXXXXXXX XX XXXXXXXXX gt XXXXXXXXXXXX XX XXXXXXXXX gt XXoXXXXXXXXX XXoXXXoXXXoX XX XXXoXXXoX (In the actual game Xs and Os can be different sizes their movement is continuous and they are not constrained into rows or columns). The Os should be able to support the weight of any arbitrary number of Xs without sinking. XXXXXXXXXXXX XXXXXXXXXXXX XooooooooooX X X Lastly, the Os should be able to float diagonally if there is a space available XXXX XXXXXXX XXX XX XXXXX XX gt XXXXX XXXX XXXX XXXX gt XXXXoXXXXXXX XXXo XXXXXXX XXXX XXXXXXX I can't solve this problem simply by adjusting the mass of the Xs or Os since the number of Xs on top of an O may vary. I can't use the built in RigidBody constraints since they don't allow you to disable only one direction along an axis (e.g. saying an object can move upward but not downward). What's the proper way to handle this? I could do something like this void FixedUpdate() if (movementDirection Direction.UP) if (transform.position.y lt lastYCoordinate) Vector3 position transform.position position.y lastYCoordinate transform.position position lastYCoordinate transform.position.y but that feels hacky to me and I suspect it will keep the objects from sleeping. Are there better solutions here?
|
0 |
The .apk file for my built game is much larger than expected Assets of my game are 15 MB, Player Settings are default, but my .apk file is 45 MB. I tried to change Player Settings and convert PNG images to JPEG, but this didn't work.
|
0 |
How can I deactivate and activate a button? I have a code that keeps a gameObject between scenes, the theme is that this gameObjecte has as a child a button, which I can change the linerenderer color, besides changing the image of the button according to the selected color and thus keep the data between scenes. then when I change to the next scene I deactivate the button with the meteodo "dehabilitar()" and in the others it is not necessary, then when I change to the next scene I deactivate the button and it is not shown, but when I go back to the next scene and call the function " habilitar() "the button is not displayed. If someone can help me in what I have bad in the code or what I lack? PS I did different methods to activate and deactivate the button but the same thing always happens and I leave it like that for a while. using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI namesp ace DigitalRubyShared public class CambioColor MonoBehaviour public Button mybutton public LineRenderer p1 public LineRenderer p2 public Sprite colorRojo Color Rojo new Color(1, 0, 0, 1) public Sprite colorAzul Color Azul new Color(0, 0, 1, 1) public static int counter 0 public static bool estado false public static CambioColor estadoCambioColor void Awake() if (estadoCambioColor null) estadoCambioColor this DontDestroyOnLoad(gameObject) else if (estadoCambioColor ! this) Destroy(gameObject) void Start() mybutton GetComponent lt Button gt () p1 GetComponent lt LineRenderer gt () p2 GetComponent lt LineRenderer gt () counter 2 public void changeColor() counter if (counter 1) mybutton.image.overrideSprite colorAzul mybutton.image.sprite colorAzul p1.startColor Azul p1.endColor Azul p2.startColor Azul p2.endColor Azul if (counter 2) mybutton.image.overrideSprite colorRojo mybutton.image.sprite colorRojo p1.startColor Rojo p1.endColor Rojo p2.startColor Rojo p2.endColor Rojo counter 0 public void dehabilitar() if (estado false) mybutton.enabled estado mybutton.gameObject.SetActive(estado) estado true public void habilitar() if(estado true) mybutton.enabled estado mybutton.gameObject.SetActive(estado) estado false Update is called once per frame void Update()
|
0 |
Instantiation of a custom class I have a custom class named Stars class Star public int primaryID public string properName public string HIPID public string HDID public string HRID public string GLID public string BFID public decimal rightAscension public decimal declination public string magnitude public string colourIndex public int scale public int red public int green public int blue public bool isSimulated public double x public double y public double z public void setDetails(int primaryID, string properName, string HIPID, string HDID, string HRID, string GLID, string BFID, decimal rightAscension, decimal declination, string magnitude, string colourIndex) this.primaryID primaryID this.properName properName this.HIPID HIPID this.HDID HDID this.HRID HRID this.GLID GLID this.BFID BFID this.rightAscension rightAscension this.declination declination this.magnitude magnitude this.colourIndex colourIndex decimal deg2rad 0.01745329251994329576923690768489m this.isSimulated true Decimal datatype is used to make sure that values are very accurate and precise decimal degrees ra decimal degrees dec decimal radians ra decimal radians dec degrees ra Decimal.Multiply(rightAscension, 15) degrees dec declination radians ra Decimal.Multiply(degrees ra, deg2rad) radians dec Decimal.Multiply(degrees dec, deg2rad) Converted from decimal to double because the Math library cannot work with decimals float distanceStars 19113 this.x (distanceStars Math.Cos(decimal.ToDouble(radians dec)) Math.Cos(decimal.ToDouble(radians ra))) this.y (distanceStars Math.Cos(decimal.ToDouble(radians dec)) Math.Sin(decimal.ToDouble(radians ra))) this.z (distanceStars Math.Sin(decimal.ToDouble(radians dec))) public Vector3 getVector() return new Vector3((float)z, (float)y, (float)x) There are many of these stars and I want to instantiate them at run time void plotStars() int i 0 while (i lt (StarDataBank.Instance.NumOfStars)) string name StarDataBank.Instance.StarName i string HIP StarDataBank.Instance.StarIDHIP i string HD StarDataBank.Instance.StarIDHD i string HR StarDataBank.Instance.StarIDHR i string GL StarDataBank.Instance.StarIDGL i string BF StarDataBank.Instance.StarIDBF i decimal RA Convert.ToDecimal(StarDataBank.Instance.StarRA i ) decimal Dec Convert.ToDecimal(StarDataBank.Instance.StarDec i ) string Mag StarDataBank.Instance.StarMag i string ColI StarDataBank.Instance.StarCI i var star new Star() star Instantiate(ObjectStar, transform.position star.getVector(), Quaternion.identity) star.transform.parent StarObject.transform star.transform.localScale new Vector3(star.scale, star.scale, star.scale) i But I am experiencing a lot of errors. Unity isn't instantiating the Stars because it can't convert UnityEngine.Transform to Star Star doesn't contain definition of Transform Is there a way to assign a class as a gameobject?
|
0 |
How can I use spectrum data to calculate energy values of certain frequency bands? I'm working on a rhythm game, and need to detect beats in a piece of music. After all the research and reading through old posts in unity forum reddit etc., as far as I understood, I need to calculate the average energy, and if there is a sudden energy change spike, I want to register them as beats. So here's the thing as far as I understood public class something MonoBehaviour public AudioSource audioSource public float freqData new float 1024 void Start () audioSource GetComponent lt AudioSource gt () void Update () audioSource.GetSpectrumData (freqData, 0, FFTWindow.BlackmanHarris) Let's say I have this code in place. My sampling rate is at 48000 Hz. The array size determines the frequency range of each element. So with a size of 1024, my frequency resolution is 23.4 Hz. So freqData 0 represents the freq between 0 23.4 Hz. freqData 1 represents 23.4 46.8 Hz. so on and so forth. And I want to detect, let's say bass beats between 60Hz and 250 Hz. How can I translate this data into the average energy value for this frequency band?
|
0 |
Quixel asset to unity I downloaded asset from Quixel, I'm using Unity HDRP, the problem I am facing is how to properly create a mask map cause the asset from Quixel doesn't have metalness map where in HDRP mask map it requires channel R should be metalness map, and the base map requires RGB color and I've got diffuse map from the asset, to put diffuse map to the basemap slot the right way to do? I'm fairly new to the channel, so put it simple 1.How to pack channels for mask map if no metalness map in the asset, what to do with the empty channel 2.Is it right to put diffuse map to basemap slot? 3.What to do with the detail map in the maskmap , the same as to no metalness map provided in the asset. 4.Another question is heightmap, Unity provide pixsel mode and vertex mode, what is the consideration before choose the displacement mode, When I choose pixsel mode, the whole texture seems to be lowered down not the pixsel on the texture surface bumped or lowered down, it is the whole texture moved. Thanks for answering these!
|
0 |
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 get the normalized heading vector between two children, TargetStart and TargetEnd (see images below) You can see that both of these objects are children of the prefab's first child. Because all of these instances will be structured the same, I want to compute the heading for the conveyor belt by accessing the locations of these children by their indices relative to the parent (which sounds like it should be simple and should be more efficient than searching by name or tag). I am anticipating a structure like this (pseudo code) heading targetEnd's position targetStart's position vector3 heading gameObject.GetChild 0 1 .position gameObject.GetChild 0 0 .position vector3 direction heading heading.magnitude How can this be done? I would like to know this so I can access any child I need to for any object by the child's index.
|
0 |
Unity Mirror Network Transform not working I am having an issue with Mirror's network transform component in unity. Players cannot see each other move, and in the inspector window only the host's player moves (this is not updated to the connected player though). In the inspector window you see a sphere moving and facing in the direction of the connected player (I did not program this so it must be Unity trying to tell me something) as per the picture below. Any help is much appreciated as there doesn't seem to be anybody that I can find online with a similar problem. Thank you!
|
0 |
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 of strings, like enums, the list is different for every dialogue). But the thing is it's VERY long inspector with a lot of variables and rewriting everything just for this one input doesn't click for me. Other problem is that this string is nested deep in the serializable object arrays, it look like so I'm very happy with how default inspector shows all the fields, expect this one string I want to change. I tried playing around with SerializedProperty but no luck. If it comes to available options I populate public string array with the names in the inspector (every dialogue has different list of participants) so the options should vary between different dialogues. What's the best way to set options? Is there a way to do it without rewriting whole inpector on your own?
|
0 |
Is a mesh OK to use for grass if there will be 1000's of them across the terrain? Am creating a low poly game in Unity 3D for PC. The terrain is made in Blender, so it's a fixed size, but quite large for the player to explore. I want to add things such as grass and flowers, but am not sure the best practices are for creating those types of assets. Is using a mesh for small clumps of grass the wrong way to do this if there will be 1000's of them? I will likely be using the occlusion culling system Unity provides, but I'm not sure if I still need to look at doing things such as grass in a different way for performance sake.
|
0 |
Unity Create large Terrain with accurate raycast detection? I'm not using the Unity Terrain because it lacks certain features. Amongst them, you cannot tile them You cannot create concave walls or make holes in it No custom textures, no detail textures, awful sculpting tools... the list goes on and on. So I imported my own Terrain as a Mesh. The collision works perfectly, however raycasting onto the Terrain is horribly inaccurate. Unity seems to compress the Mesh Collider depending on distance to player. See the video linked below. Since Unity is (by my knowledge) the only Game Engine that supports convex colliders, how do other game engines create Terrain colliders? For a racing game or a RTS or RPG the colliders are no problem, but for a shooter it's unacceptable. Here's a video showing the problem https youtu.be coiFS6IT4wI I've researched long and hard and there seems to be no known solution for this. So my question remains, if it's possible at all, how can i create large scale Terrains for Unity? This problem makes it completely impossible for me to create outdoor scenes. There HAS to be some kind of solution. 1) Raycasting script Spread float spreadAmount Mathf.Lerp(spreadMin, spreadMax, burstTimer spreadThreshold) Current Spread lerps between spreadMin and spreadMax by burstTimer (increases per shot) int i 0 totalShotDamage 0 Buckshot sends 8 rays down the range. totalShotDamage gets total damage done by all rays. Needed for displaying damage text while (i lt bulletCount) Repeats Shooting Vector for bulletCount amount (needed for buckshot) Vector3 shootDirection shootOrigin.transform.forward Shoot Vector 100 accuracy shootDirection shootOrigin.transform.right (Random.Range( spreadAmount, spreadAmount)) Randomizes Vector horizontally, reduces accuracy shootDirection shootOrigin.transform.up (Random.Range( spreadAmount, spreadAmount)) Randomizes Vector Vectically, reduces accuracy Ray ray new Ray(shootOrigin.transform.position, shootDirection) Ray from Shoot vector RaycastHit hitInfo if (Physics.Raycast(ray, out hitInfo, 2000, shootLayerMask)) Sets range of gun amp sends ray Vector3 hitPoint hitInfo.point Point of impact with any object GameObject go hitInfo.collider.gameObject GameObject of impacted Object string targetTag hitInfo.collider.gameObject.tag Tag of GameObject of impacted Object addHitParticleEffects(targetTag, hitInfo, enableBulletholes) Add hitparticle effects based on Tag (IMPACTmaterial) damageEnemy(targetTag, hitInfo, damage, damageRollOff) Damage enemy i total bullet count (needed for buckshot) 2) Terrain Inspector Settings 3) LOD Settings There are no LOD Settings (yet). Individual Planes of the whole Terrain and objects on top of it simply pop in and out of existence depending on the Players position.
|
0 |
Insert 3d text to the front face of a cube GameObject I want to add a text to a cube in Unity. I have a cube which has a 3d text as a child. I am using the below UnityScript to write on the 3d text var countdown int 200 function Update() GetComponent(TextMesh).text countdown.ToString() I am trying to write show the text to the front face(or very close) of the cube but I am failing. EDIT My difficulty is to make the text appear in the front side face of the cube, like it is written on it. Attaching the text or the script to any object is not an issue My last failed try was to use the below lines var tm gameObject.AddComponent(TextMesh) tm.text countdown.ToString() Any ideas?
|
0 |
Enemies and item drops issue Disclaimer I'm relatively new to developing games so bear with me. In my scene I have enemies and when they die, they drop items. No matter which item is dropped, the same prefab (the physical representation of the dropped item) is instantiated. That physical orb on the ground may represent different items. It could be a pile of coins, a sword, etc. Depending on which item is dropped, I want its name to appear in a UI label attached to the top of the item. Basic ARPG stuff really. The problem I'm running into is that I can't seem to get the references right. DisplayItemNameLabel is a script which is attached to each item when it is dropped. I did it this way so each item can be in charge of its own UI label. ItemDrops is attached to each enemy. SpawnItem(Item item) is a function which is called when the enemy dies. The last relevant Monobehaviour script is the ItemData script which is attached to an Item Manager game object which is there from the beginning and persists forever. This class just defines the different items that are possible in the game. So basically the structure is that when an enemy dies, if the random number generated is within some range, then some item will drop. If (randomNumber lt 0.5) SpawnItem(itemData.coin) where SpawnItem(Item item) is something like... private void SpawnItem(Item item) itemDropped true nameOfDroppedItem item.itemName Instantiate(itemPrefab, transform.position offset, Quaternion.identity) Again, this is attached to each enemy. In the DisplayItemLabel script then, I would like to set itemNameText.text to that nameOfDroppedItem. But the DisplayItemLabel script is attached to each item. I don't think I can make each item a child of each enemy because enemies are destroyed when they are killed so the scripts would be destroyed. I also can't use GameObject.FindGameObjectWithTag("Enemy").GetComponent lt ItemDrops gt () because it wouldn't always grab the enemy I want. I thought maybe I could set the text in SpawnItem but it would have to reference the correct item, so I couldn't use GameObject.FindGameObjectWithTag... What should I do?
|
0 |
How do I restart an animation that is already playing using SetTrigger? I have set up a relatively simple example scene with one enemy. This enemy is controlled with an animation controller. In this animation controller, I have set up a trigger named "Hit". The enemy plays an idle animation, and when my hero character shoots him, I set the trigger "Hit" via script like this animator.SetTrigger("Hit") This causes the animation controller to react to it, and it transitions from "Idle Animation" to "Hit Animation" The hit animation is 3 seconds long. After it has completed, the animation controller will automatically transition back to the "Idle Animation". I would like make it so that the hero character can shoot the enemy even though he is already playing the hit animation. Let's imagine you use a machine gun to shoot him repeatedly quickly. However, when I call animator.SetTrigger("Hit") while the hit animation is already being played, nothing happens. As I currently understand it, this makes perfect sense as the Trigger triggers the transition from animation A to animation B, and if we're already at animation B, then there can be no transition. The transition will only kick in if the animation controller is currently playing the "Idle Animation" as it can then transition to the "Hit animation" What could I do to "restart" the hit animation? Thank you.
|
0 |
How can OnMouseDown in the parent object be triggered from the child placed on top of it? I am learning Unity from a book. The example is to create a 2D memory game as follows (viewed in perspective view). The green (background) at z 5, the purple diamond (front card) at z 0 and the red (back card) at z 5 for example. The front card is set as the parent of the back card in the hierarchy window. A box collider (2D) component and a script below are attached only to the parent. public class FrontCard MonoBehaviour public void OnMouseDown() Debug.Log( quot testing 1, 2, 3! quot ) When I play the game and click the back card, the OnMouseDown gets invoked. Question How can the OnMouseDown get invoked when I click the back card by considering the script is attached to the front card game object that is placed below the back card?
|
0 |
How do I make an object's y axis align with a Vector3? I have a golf ball on the ground, and from a raycast, I have the normal which gives me the slope of the ground by the ball. I have an object which is rendered on the HUD to show that slope to the player. I have a parent object rotated 90 degrees around X, so that the indicator's Z axis points up. This way I can do this Quaternion yRot Quaternion.Euler(0, CameraController.Instance.CachedTransform.eulerAngles.y, 0) Vector3 displayGroundNormal yRot groundNormal lieIndicator3DParentCachedTransform.rotation Quaternion.LookRotation(displayGroundNormal) This, as far as I can tell, takes the ground normal, rotates it around the y axis so that it shows the proper perspective given the camera's facing. Then it tells that parent object to look in that direction, which aligns its z axis with the rotated ground normal. This works, except the object I have also rotates around the y axis depending on the orientation of the camera. I thought that I was throwing that information away in the second step by keeping only a Vector3 aligned with the ground normal rotated for the camera position. So I want this Not this
|
0 |
Pass parameters from html page to start() function in unity3D webplayer application I want to pass a parameter from web browser to Unity3D web player as soon as it is loaded. I know that, as soon as the web player is loaded, the start() function is execute inside web player. So I want to pass parameter from web browser to this start() function.
|
0 |
Creating an efficient 2D mobile game background I am working on a 2D unity mobile game and would like some advice on how to save as much MB's as possible with my background images. I can either create 15 600 x 1000 png images through an image manipulation program and import them into unity, each image is roughly 300 kB's before building the project. Or I can import a base background image that i would use multiple times, and also import a sprite sheet with scenery, and just place the sprites on the background layer of my game scene. Note, if i choose the second option there will be 30 100 tree sprites, along with enemy and player game objects in view of the main camera at a time. I'm not sure if this second option will bog down the game, because of all the individual sprites on the screen at once.
|
0 |
Choosing random array indexes in Unity C I want to change a string by randomly choosing an index in an array, using the random.range command in unity. Bare in mind that I'm using strings here, not floats or integers. Here is a code example(not the real thing. I'm just coming up with this by example, but it still has the same meaning. I may make a few typo errors as a result) public string ChangingString ("") public string ExampleArray new string 2 void Start () ExampleArray 0 ("String1") ExampleArray 1 ("String2") void OnGUI () if(GUI.Button(new Rect(10,10,100,24), "Randomize text")) ChangingString (code to choose random string using the ExampleArray) GUI.Label(new Rect(10,30,100,20), ChangingString) EXTRA NOTE I'M NEW TO USING ARRAYS.
|
0 |
Other methods to save data than PlayerPrefs? I've been saving data using the playerPrefs option in Unity till now. Is there any better secure way of saving data for developing mobile games. Somes sites have mentioned encryption of data how do I approach that?
|
0 |
Interpolate object collision stuck in Unity I am working on a very basic test in 2D. The problem I am having is that, when my sprite collides with the ground, it is checking the event too frequently. The sprite stays in limbo, as it doesn't have a chance to leave the ground. By the time it does, the check tells it to turn around, resulting it quickly going up and down. I uploaded an example clip to YouTube. When contact is made, the sprite needs to change it's Y axis direction. How do I fix this? Please see my code, below void Update () hitWall Physics2D.OverlapCircle(wallCheckUp.position, wallCheckRadius, whatIsWall) if (hitWall) moveUp !moveUp if (moveUp) transform.localScale new Vector3( 1f, 1f, 1f) GetComponent lt Rigidbody2D gt ().velocity new Vector2(speed, GetComponent lt Rigidbody2D gt ().velocity.x) else transform.localScale new Vector3(1f, 1f, 1f) GetComponent lt Rigidbody2D gt ().velocity new Vector2( speed, GetComponent lt Rigidbody2D gt ().velocity.x) Here is my object
|
0 |
Unlock cursor through script I am using unity's default FPS controller script. My game switches scenes, and when it does I can't move the mouse. I know that this is because of unity's m mouselook's lock cursor is on. What I don't know how to do is turn that boolean to false through a different script.
|
0 |
In Unity how can I know which direction is the screen auto rotated? From the Screen.orientation description I get If the value is set to ScreenOrientation.AutoRotation then the screen will select ... automatically as the device orientation changes. This seems to imply that if the screen does auto rotate, then Screen.orientation has been set to ScreenOrientation.AutoRotation. If that's so, how can I know in which direction it has been auto rotated? Disabling the auto rotation doesn't count (obviously), and I need to distinguish between LandscapeLeft and LandscapeRight, so checking height and width doesn't work either. This should be cross platform, without including any kind of non C plugin. (the answer, given this documentation, seems to be "you can't", but maybe I'm missing something)
|
0 |
Calculating the bounding box of a game object based on its children 2D game with Unity. Have a parent game object, with several children objects scattered all over the scene. I want to calculate the bounding rectangle of the parent game object. Let the black dots be the children objects. The red rectangle is the bounding box. I am not really interested in the position I only want the dimensions of such box. Of course, the bounding box should also consider the bounding boxes of the children... and so on. How can I achieve this? I heard that Renderer has a bounds property... but my parent object doesn't have a renderer. And when I put one, the value is 0 anyway.
|
0 |
What's the better approach, running multiple server builds on one instance or running one server build and managing matches in different rooms? We are building a racing multiplayer game using Mirror and Unity and we've been able to successfully run the authoritative server on AWS Gamelift and Playfab so far. Both providers are with the flexibility of running multiple server builds and mapping with different ports. So I think running multiple server build for different matches on one instance is a bit expensive in terms of server usage as compared to running one server and managing multiple matches in different rooms. But overall it seems to be a safer option to go with since build crash and similar issues will only happen on one match and other matches (servers) will be running fine on the same machine and also it's a bit easier to handle and scale. What's your opinion on this? It might be useful if you share any blog or resource to look at for scaling and managing servers on gamelift playfab. thanks!
|
0 |
How can I get my physically based sky to be blue all the way down? I'm rendering with a physically based sky. I want to get a very simple light blue background but below the horizon the sky becomes grey brown. How can I get it so that the sky is blue all the way down? As if the edge of the city was the edge of the world. I also want to make the blue sky brighter, especially at the bottom.
|
0 |
Size of .skp gets doubled after importing to Unity I have created a 3D model in SketchUp, and it is about 1.6Mb in size. After importing it to Unity, the size more than doubled to 4Mb. Why is that?
|
0 |
C in Unity with dependencies I am currently creating a c program to eventually use in Unity. This c program contains references to libraries like OpenCV and dlib, referenced with a include statement which calls in other files, which are installed on my machine. My question is How do you compile your c project so that it runs in Unity completely self contained? i.e no reference to external files are needed, and all that are references are included within the program. Is there a specific tool to use, or a useful tutorial on the net? Thanks for the help.
|
0 |
Destroy the enemy only if the animation is played and touch the enemy I am using Unity. I want to attack an enemy with a knife. So I created an object (the knife) and put an attacking animation to it. Now I want to destroy the enemy only if the attacking animation is played and the knife touches the enemy. And if the animation is not played and the knife touches the enemy it should show a game over screen.
|
0 |
Unity bounds includes the center of the scene I'm trying to get the bounds of an object and put a box around it. Sounds simple right? I just encapsulate all the bounds together and use its center and size to do so. But the problem is one corner of the box is always at the center of the scene, like a part of the object is there, unless the center of the scene is in the bounds. This is when object is at the center This is when it isn't This is the code i'm using public static Bounds Calculate(Transform TheObject) Renderer renderer TheObject.GetComponent lt Renderer gt () Bounds combinedBounds new Bounds() if (renderer ! null) combinedBounds renderer.bounds var renderers TheObject.GetComponentsInChildren lt Renderer gt () foreach (Renderer render in renderers) if (render ! renderer) combinedBounds.Encapsulate(render.bounds) return combinedBounds
|
0 |
How can I import a Google Sketchup model with textures? I'm using Unity 4 and trying to import a SketchUp Model into Unity and other Engines but I can't get it to import correctly. Can anyone help me out?
|
0 |
Would creating a player scriptable game using Unreal Engine or Unity violate their license agreement? I want to create a game in Unity or UE4 which allows the user to write scripts in Python and run them mainly to control the AI. I will have to find a way to enable runtime script execution first. After searching the internet i was able to find some ways that may work. What i cant find an answer for is how to limit the parts of engine and game code the user has access to so that the player doesnt feel like he's playing it in God mode. And the main question is that even if i am able to restrict access to the API will it violate the terms of agreement for these commercial engines because the player will get access to the underlying engine and will be manipulating objects within it. I don't intend to make a moddable game just a game that requires you to write some code but that would be an extreme case to think about.
|
0 |
Spawn Array of GameObjects to Array of Transforms I have a question regarding spawning an array of GameObjects in Unity. What I want to happen is that when a big enemy dies, it will spawn enemies into their respective Transform positions (i.e., Enemy 1 will spawn in Position 1, Enemy 2 in position 2, and so on). I suppose I could go on with something like C public GameObject Enemies public Transform SpawnPoints void KillEnemy() GameObject enemy1 Instantiate(Enemies 0 , SpawnPoints 0 .position, SpawnPoints 0 .rotation GameObject enemy2 Instantiate(Enemies 1 , SpawnPoints 1 .position, SpawnPoints 1 .rotation GameObject enemy3 Instantiate(Enemies 2 , SpawnPoints 2 .position, SpawnPoints 2 .rotation Destroy(gameObject) But the problems are 1. I'm aware that the code is expensive to run, especially since I'm doing a 2D game and 2. It provides no flexibility, meaning if I want a different enemy to use the same code, then I won't be able to do stuff like adding more enemies to spawn (after the first one dies, of course). So yeah, I hope I get some help with this. Thanks!
|
0 |
Unity 5.5 Android scaling The questions I've seen are outdated, explained, not to my liking, or just don't work. Problem I want to be able to create a game that can scale on all mobile devices with ease and with no pixelation. Extra Info I'm very new to unity and tackling the the software with all my might I'm sorry for being a noob. I already paired unity with my phone and set the build to android (Nexus 5). Aspect ratio is 10 16, The game is going to be portrait. I have no scripts or anything, Its legit a blank game with a camera that has a blue background. I have some pictures, if you need anything else for my assistance don't hesitate I'm here to learn and take, GULP, Constructive Criticism. PC Android
|
0 |
unity3d nullreferenceexception i want to display a mesh sequence so i imported my obj files and found a script and partially edit it a bit.My project looks like this the script is this using UnityEngine using System.Collections Animate a mesh by cycling through different meshes. author bummzack public class MeshAnimation MonoBehaviour public Mesh Meshes public bool Loop public float FrameDuration private int index private bool playing true private float accumulator private MeshFilter meshFilter public void Start() meshFilter GetComponent lt MeshFilter gt () index 0 public void Update() accumulator Time.deltaTime if( accumulator gt FrameDuration) accumulator FrameDuration index ( index 1) Meshes.Length if( index 0 amp amp !Loop) Stop() return meshFilter.mesh Meshes index print ("Hello World") the line that causes the problem is this meshFilter.mesh Meshes index and the problem shown in the console is this NullReferenceException MeshAnimation.Update () (at Assets MeshAnimation.cs 43) i know it has something to do with Meshes index being null but i cant find the solution because i think the Meshes array is properly filled.Can anyone suggest a solution? Thank you all in advance.
|
0 |
Remove Sprite Shape Controller Icons from 2D sprite shapes How do I get rid of those "purple icons in my scene"? They are so annoying ... they literally covers the entire 2d shape! GIF showcasing it
|
0 |
How to make animation in unity Dots hybrid? I'm working on isometric game in 2D but didn't find any good tutorial in how to handle animation...any help?
|
0 |
how to create a curve movement of slider in unity I am trying to create a curved (not circular) movement of slider. Here is my demo images for reference I have watched some tutorial but those are for circle images. I want to make this movement along the arrow images below car. Also if this can be done with just images without using slider that will be ok too. I just this done the simpler and easy way.
|
0 |
How should I account for the GC when building games with Unity? As far as I know, Unity3D for iOS is based on the Mono runtime and Mono has only generational mark amp sweep GC. This GC system can't avoid GC time which stops game system. Instance pooling can reduce this but not completely, because we can't control instantiation happens in the CLR's base class library. Those hidden small and frequent instances will raise un deterministic GC time eventually. Forcing complete GC periodically will degrade performance greatly (can Mono force complete GC, actually?) So, how can I avoid this GC time when using Unity3D without huge performance degrade?
|
0 |
Objects aren't rotating in sync This is a follow up question to How to reapply force applied to one object to another object I want to make two objects move, react to collisions and other stuff as if they were one. For example, Objects A and B are entangled. When Object C rams into Object A and starts moving with it, Object B should start moving with it. When Object B hits a wall, Object A should act like it also hit a wall. I tried changing position speed every frame, but this only works when done in one direction. Now, I want all forces applied to any of the objects to also apply to the other objects entangled to it. Edit This is the new code which only fails when multiple collisions happen at once using System.Collections using System.Collections.Generic using UnityEngine RequireComponent(typeof(Rigidbody)) public class EEScript MonoBehaviour public List lt EEScript gt activeObjects public new Rigidbody rigidbody public Vector3 lastPosition Start is called before the first frame update void Start() rigidbody gameObject.GetComponent lt Rigidbody gt () Update is called once per frame void Update() lastPosition transform.position private void OnCollisionEnter(Collision collision) foreach (EEScript entangled in activeObjects) if (entangled this) continue Rigidbody rb entangled.rigidbody if (rb is null) continue rb.velocity rigidbody.velocity rb.angularVelocity rigidbody.angularVelocity entangled.transform.position entangled.lastPosition transform.position lastPosition
|
0 |
How can i rotate both NPCS facing the door moving to the door and then...? I need to make some steps. To rotate both npcs but each time running the game they will rotate randomly from another direction. For example the first one will rotate from the right side or left side same the other one. They will facing the door and start moving to the door. Near the door she will open automatic they will wait then they will move through the door. one of the npcs will keep moving and will start random patrolling. The second npc will rotate facing the door from the outside and will do something like locking the door ( I will animate it later he will rotate facing the door wait 2 3 seconds will rotate and will join the first npc and start patrolling too. This is a screenshot of both npcs each one have a box collider. The door they should rotate smooth randomly and facing and moving to the door the one behind them. This is the behind the door outside the hall. This is where one of the npcs should start patrolling and the other one wait some seconds facing the door like he is locking the door and then after some seconds to join and start patrolling too. And this is the hall out side the door and then the hall right and left. They should be patrolling the hall right and left and also the hall with the door. But not getting too close to the door s so they will not open all the time. The last screenshot show where they should be patrolling. The left image is the hall outside the door the right image is a door on the front hall on the right and the bottom image the door on the left. It's like a T I need some guide how to start it by logic how to do it. I have the scenario in my mind what they should do the 4 steps. But not surw hot start doing it. The scenario in general is Two guards(npcs) lock the door from the outside and start patrolling outside.
|
0 |
Instantiation of a GameObject not working for a threading reason I receive the following error "INTERNAL CALL Internal InstantiateSingle can only be called from the main thread." "Constructors and field initializers will be executed from the loading thread when loading a scene." "Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function." whenever I try to instantiate some GameObject's using this function public void DisplayCalls () for (int i 0 i lt calls 0 .Count i ) for (int j 0 j lt impFields.Length j ) GameObject textClone Instantiate (textBox, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject textClone.transform.SetParent (canvas.transform) Text text textClone.GetComponent lt Text gt () text.text calls impFields j i text.alignment TextAnchor.MiddleCenter textClone.transform.localPosition new Vector3 ( 262.5f (175f j), (182f (30f i)), 0f) The function is called using this other function public void GetPanelInfo () string file "getpanelinfo.php" string hash Md5Sum (mostRecentID.ToString () SecretKey1 SecretKey2) string parameters "?mostrecentid " mostRecentID.ToString () " amp hash " hash string fullURL baseURL file parameters Uri fullURI new Uri (fullURL) WebClient client new WebClient () string jsonString string.Empty client.DownloadStringCompleted (sender, e) gt if (!e.Cancelled amp amp e.Error null) jsonString e.Result JSONNode json JSON.Parse (jsonString) for (int i 0 i lt json "calls" .Count i ) for (int j 0 j lt calls.Length j ) calls j .Add (json "calls" i names j ) mostRecentID json "calls" i "callID" .AsInt else if (e.Cancelled amp amp e.Error null) Debug.Log ("Cancelled") else Debug.Log ("Error " e.Error) loading false LogCalls () DisplayCalls () client.DownloadStringAsync (fullURI) Which is called once using a button. I cannot seem to find the problem, but as stated above, the error says that it is a threading problem and that I cannot call instantiate from another thread other than the main one. I do not know how to change the instantiation to another thread, but any help to solve this problem would be much appreciated.
|
0 |
Create borders and clickable areas from image Crusader Kings, Europa Universalis and several other strategy games use provice based maps where "tiles" are not squares nor hexagons. Border style indicates different ranks owner. I've done some research and this is what I found from modding guides they seem to use a source image to dynamically generate the borders which are used to separate the provices but also to indicate currently selected areas (border changes color or flashes etc) and Im pretty sure that same file is used for "clickable areas" (click on provice to get province details screen). Source image contains all the provinces painted with solid colors. This image is same size as height map (water bodies and land masses) to align geographical shapes with provinces. Then there's some sort of dictionary file (text, JSON etc) that has all the province colors that maps these colors to meta data about the province. It also makes provinces "loopable" for game engine in order to add them to in game database and to use colors to find the correct shapes from image. Example in JSON "key" is RGB color that points to correct province in previous image "253 28 37" "name" "Kent", "otherStuff" 13 , "142 133 150" "name" "Oxford", "otherStuff" 54 How to create referenceable borders and clickable areas from source image?
|
0 |
Missing references in built bundles The following is a copy of our post in Unity Forum (https forum.unity.com threads missing references in built bundles.1103689 ) Hello, We have a bundle for our scenes and another one to store our prefabs (actually we have around 10 bundles but let's keep it simple). In every scene we have unpacked prefab instances. We have no problem in playmode using the AssetDatabase but once we use built addressables some unpacked prefab instances in our scenes are broken. Sprites and or scripts are missing in a inconsistent way in some scenes those objects are fine and sometime they are not. This comes along multiple warning messages quot The referenced script (Unknown) on this Behaviour is missing! quot . Note that the issue also happens when we fully deploy our player. Unity version 20193.3.13 Addressables version 1.16.1 Solution 1 We tried to remove addressable prefabs (A,B,C in the diagram) from their bundle since we don't really have to instantiate them at runtime for now and it worked. Solution 2 We also tried to put scenes and prefabs into the same bundle and it worked too. Solution 3 Switch to 1.18.2 and 1.15.1 version of addressable package and it didn't work. Solution 4 Finally we tried to use the Duplicate Bundles Dependencies analyzer multiple times in order to have no more issues of this type and it didn't work. Questions 1 As far as we understand, when addressable groups are built, Unity computes all dependencies and build them inside the bundle along the orignal assets (in my diagram quot Scenes quot bundles is packed with D'). What we don't understand is why having our prefabs in a separated bundle break references link in the scenes. Our guess is that Unity doesn't know which version of those dependencies to use (the one in the scene bundle or the one in the prefab bundle) and somehow fails to load them properly. Question 2 Is splitting our content is a good approach, we did it mostly for visibility but it appears to be more a problem in the long term, what are your guidelines regarding this matter ? Question 3 Why Duplicate Bundle Dependency rule has to be processed multiple times to properly fix every issue ? We think that running this rule creates duplication issues itself but we can't really tell.. Thanks.
|
0 |
How do I use an external FBX object in Unity? Is it possible to use an external .fbx object in Unity 3D the same way we can insert a picture? Something like myPath "http www.myserver.com object myobject.fbx" ?
|
0 |
Drawing rectangle around a target on screen I am just started with Unity and C . I need in my work to do rectangle on a scene. I have a 3D scene, say some warehouse and there is an object. Camera is animated and moving towards the object. Is it possible to draw a rectangle around the object on the camera screen while the camera is moving unless the object on the screen? The task is like keeping target in war flight games. This is my code, where I tried to draw rectangle anywhere using System.Collections using System.Collections.Generic using UnityEngine public class MY getting images MonoBehaviour Start is called before the first frame update public GameObject pallet public Camera color cam public Vector3 pos LineRenderer l void Start() pallet GameObject.Find("PalletWood01") l pallet.AddComponent lt LineRenderer gt () List lt Vector3 gt ps new List lt Vector3 gt () ps.Add(new Vector3(0, 0)) pos pallet.transform.position ps.Add(new Vector3(10,10)) l.startWidth 1f l.endWidth 1f l.SetPositions(ps.ToArray()) l.useWorldSpace true Finding camera in a scene tag needed camera, for example "Player", and then GameObject.FindWithTag("Player").GetComponent lt Camera gt () Tag the camera another way for deployment color cam GameObject.FindWithTag("Player").GetComponent lt Camera gt () pos color cam.transform.position pos pallet.transform.position Debug.DrawLine(Vector3.zero, new Vector3(0, 0, 5), Color.red) Debug.Log(pos) Update is called once per frame void Update() Debug.Log(pos) pos color cam.transform.position Debug.Log(pos) The scene now looks like on the image above I want 2d rectangle around the pallet drawn on the screen.
|
0 |
How to move my cube left or right using touch Inputs (C ) in unity I am trying to create a 3d game in unity. I have a cube in unity and I want it to move left or right on swipe . It should move to a distance till where user swipe or take their finger off of a screen. I want it to move fast or the cube should move fast on swipe and cube should flow smooth. Like in the gif there is a circle and the user use their finger to move the circle till wherever the user swipe it and it should be instant and I want my cube to move like that at a distance till where user swipe their finger and it should be instant and fast. I don't know how to do it. Any help is appreciated!
|
0 |
Add a tag in Unity editor in code How to add a tag in editor? I am working on automatic asset generation and I would like to use tags for certain objects.
|
0 |
Precise punch animation for unity I'm using blender to model, rig and animate my character for a Unity game, but there is something that I can't figure out by myself neither find on the internet, for example Lets say the main character is able to punch npcs and I want that punch aimed to the face but not all npcs have the same height. How can the animation be adjusted to handle this? Inverse kinematics seems to be the solution but to this date I couldn't find any good example or information about this subject better than "Check this box to fix the animation for stairs" and so on.
|
0 |
Unity IOS game restart when you press the home button Why does my unity IOS game restart when i press the home button on the device? The same game worked fine on Android device and did not restart on pressing the home button. Thanks
|
0 |
Unity How to apply bloom to only some objects in the scene? In my game I want to apply bloom, from the standard assets, to only a few objects in the scene. To do that, I set up 2 cameras at the same position and orientation, one with the bloom component and the other without. Then I put the blooming objects on a "Bloom" layer, set the blooming camera to only render objects on this layer, and the main camera to render everything else. Then I noticed that, if the main camera has a depth lower than the bloom camera, then the bloom camera will apply bloom to everything in the scene. I guess that's because the bloom effect works on everything rendered up to the point the script is executed. So I made sure that the bloom camera has the lowest depth and clears with a solid color. Main camera does not clear. However, now I lose the illuminated pixels around the blooming objects. I guess they are overwritten by the main camera, since the blooming camera probably did not give them any depth. Here's a simple scene to illustrate the problem Currently the game looks like this If I swap the configuration of the 2 cameras (Main camera lower depth, clear with solid color Bloom camera higher depth, don't clear), the game looks like this (exaggerated for demonstration) What I want is the yellow object to look like that in the last image, and the purple object to look like that in the second last image. How? Because of company policies, I am limited to Unity 5.4.1f1, and cannot use anything not made by Unity in the Asset Store.
|
0 |
Resize rigidbody in runtime, Box collider OnTriggerEnter not work Scene setting Object A Rigidbody, kinmeatic Box collider, is trigger true. Object B Box collider, is trigger true. Script is on Object A void FixedUpdate() if(increaseScale) transform.localScale transform.forward speed when to stop if ((AEForward transform.localScale.z).sqrMagnitude gt range range) increaseScale false void OnTriggerEnter(Collider other) Debug.Log(other.transform) No log message when part of object A is inside B. And the funny part is if I use it on a sphere collider, it works. (use transform.localScale new vector3(1,1,1) speed instead )
|
0 |
Unity Global illumination seems no longer applied to static objects on runtime First of all I'm newbie with Unity, so please forgive me if the answer of this question is obvious for any experimented developer. So, in one of my project I have this result while I run the project in the editor However, on runtime I get this result As you can see, several objects in the scene are no longer lighted. In fact, I noticed that ALL my static objects lost their illumination on runtime. I tried with Windows and WebGL as targets, same result. As I'm hobbyist, I may provide any info about the project configuration. Better, I can provide the Git link of my project https github.com Jeanmilost Unity tree master Survival 20Demo 20Scene This is a demo project, but in the future I'm interested to create more serious projects, and thus I need to understand why this issue happen. So if someone can point me what I'm doing wrong, I would be very grateful, because I already spent some hours to search the solution, without success.
|
0 |
Make an object rotates by an arbitrary angle and rotates toward a target in Unity I have an object facing up in Unity. I need it to move from point A to point B, without prior knowledge of where A and B are. So when I place it at point A, I need to rotate it toward point B. I used this this.gameObject.transform.rotation Quaternion.FromToRotation(A.position, B.position) However, before doing the movement, I also need to rotate the object by 90 around the X axis. I used this this.gameObject.transform.rotation Quaternion.Euler(90.0f, 0.0f, 0.0f) These two functions worked, but separately. When I try to use these two functions together, the last function called overrides the other.
|
0 |
How to test if procedurally generated level for infinite runner can be passed? I have a 2D infinite runner platformer game built in Unity 5, where the level procedurally generates itself. I need to check if it is possible to pass the holes on the level. How could I do that?
|
0 |
How do I get Input Positive Button value in Runtime? In Unity in InputManager I assigned R Button to "Restart" name. Now that property (Restart) has another property with a key "Positive Button" and string value "R". In the game I can show notice to user "click R for Restart!" But what if user will change that key in the start config window? For example from R to T button. Now the game should display notice "click T for Restart!" Question How do I get changed Positive Button value by name "Restart" via script in Runtime? Is it possible? p.s. in Editor I can do this SerializedObject inputManager new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings InputManager.asset") 0 ) SerializedProperty axisArray inputManager.FindProperty("m Axes") for (int i 0 i lt axisArray.arraySize i) var axis axisArray.GetArrayElementAtIndex(i) var axisName axis.FindPropertyRelative("m Name").stringValue if (axisName "Restart") restartButtonValue axis.FindPropertyRelative("positiveButton").stringValue break But it allows to use it only in the Editor. Because it uses UnityEditor.dll
|
0 |
Chess engine stock fish process for mobile I am making the chess interface I designed for a game. I am using the process to get answers from a stock fish binary stockfish new Process StartInfo new ProcessStartInfo FileName System.IO.Directory.GetCurrentDirectory () " Assets Scripts Stockfish stockfish.exe", Arguments "", UseShellExecute false, RedirectStandardOutput true, RedirectStandardInput true, RedirectStandardError true, CreateNoWindow true The problem I face is it worked for my Windows build but for mobile package build it won't work with the executable. Is there a way around it?
|
0 |
Limit rotation angle I am currently trying to rotate the weapons of a spaceship towards the mouse position, but in order to avoid the collision of projectiles with the ship I want to limit the angle the weapon can turn. I've tried doing this Vector3 mousePos Input.mousePosition float range 100.0f float rotStep 0.1f Vector3 positionOnScreen Camera.main.ScreenToWorldPoint(mousePos Vector3.forward range) Vector3 targetDir positionOnScreen transform.position Vector3 newDir Vector3.RotateTowards(transform.forward, targetDir, rotStep Time.deltaTime, 0.0f) Quaternion lookRot Quaternion.LookRotation(newDir) float xAngle lookRot.eulerAngles.x if (xAngle gt 10 amp amp xAngle lt 180) xAngle 10 else if (xAngle lt 350 amp amp xAngle gt 180) xAngle 350 float yAngle lookRot.eulerAngles.y if (yAngle gt 10 amp amp yAngle lt 180) yAngle 10 else if (yAngle lt 350 amp amp yAngle gt 180) yAngle 350 float zAngle lookRot.eulerAngles.z if (zAngle gt 10 amp amp zAngle lt 180) zAngle 10 else if (zAngle lt 350 amp amp zAngle gt 180) zAngle 350 lookRot.eulerAngles new Vector3(xAngle, yAngle, zAngle) transform.rotation lookRot The problem here is that I don't know how to limit the rotation angle since it's not the same depending on the ship rotation (for example if it's (0, 0 , 0) or ( 90, 90, 90)). I've tried using transform.localRotation too, but still happens the same. Do you how could I limit the rotation regardless of the ship rotation?
|
0 |
Prefabs property is not overriding when changing from editor script? In unity we can have different instances of a prefab with different properties. Unity represents the overridden property with bold characters. This works fine when manually change the value of prefab instance. But when I do it using a editor script, it do not turn bold and the property value changes to the source prefab when I play the game. Here is an example of the code using UnityEngine using UnityEditor CustomEditor(typeof(testScript)) public class editor Editor public override void OnInspectorGUI() DrawDefaultInspector () testScript scrt (testScript)target if (GUILayout.Button ("button")) scrt.test() . using UnityEngine public class testScript MonoBehaviour test() gameManager GameObject.Find("GameManager") gameManager.GetComponent lt gameManager gt ().arr new GameObject 3 . using UnityEngine public class gameManger MonoBehaviour public GameObject arr The arr array in gamemanager class is not overridden and it changes to the source prefab value on play. EDIT actual function called from editor script public void assignPortalPass() GameObject gameManagerObj GameObject.Find ("Game Manager") gameManager gameManagerScript gameManagerObj.GetComponent lt gameManager gt () Transform passed GameObject.Find ("passed").transform int noOfChild passed.childCount if (noOfChild ! gameManagerScript.noOfPortals) Debug.LogError ("Check passed objects and noOfPortals (class gameManager) because both values are different") return Undo.RecordObject(gameManagerObj, "Made some changes to gameManager") as suggested by the answer gameManagerScript.portalPass new GameObject noOfChild for (int i 0 i lt noOfChild i ) gameManagerScript.portalPass i passed.GetChild (i).gameObject
|
0 |
Material is flickering in Unity I'm trying to make a grid like, light up floor using Unity's Shader Graph. However, I am having an issue where the lines are flicking after a really short distance when the camera is moving. The shader graph is below. How can this issue be prevented and what is causing it?
|
0 |
Unity3d vector and matrix operations I have the following three vectors posA (1,2,3) normal (0,1,0) offset (2,3,1) I want to get the vector representing the position which is offset in the direction of the normal from posA. I know how to do this by cheating (not using matrix operations) Vector3 result new Vector3(posA.x normal.x offset.x posA.y normal.y offset.y, posA.z normal.z offset.z) I know how to do this mathematically Note indicates a column vector, indicates a row vector result 1,2,3 2,3,1 0,0,0 , 0,1,0 , 0,0,0 What I don't know is which is better to use and if it's the latter how do I do this in unity? I only know of 4x4 matrices in unity. I don't like the first option because you are instantiating a new vector instead of just modifying the original. Suggestions? Note by asking which is better, I am asking for a quantifiable reason, not just a preference.
|
0 |
Convert Canvas Space point to local space of a rotated rect? I got a quite tricky problem I have my mouse position and my rectangle position in canvas space(screen space but with adjusted scaling). Now I want my mouse position converted to local space of the rectangle. Problem is, the rectangle can be rotated. Without rotation its quite simple and works nicely. Heres a graphic for better demonstration Edit3 Got it finally working. I messed up with a minus in the calculation instead of using a . Also the hierarchy of the image in unity was incorrect. Lastly I had to change the rotation from CCW to CW(Thanks unity for using CCW in your UI...). This is my final solution Code Unity C var mapRect MapContentTransform.rect Canvas Space Map Center var mapPositionCenter CanvasRectTransform.InverseTransformPoint(MapContentTransform.position) mapPositionCenter.x CanvasRectTransform.rect.width 2.0f mapPositionCenter.y CanvasRectTransform.rect.height 2.0f Mouse Position in Canvas Space Vector2 mousePositionCanvasSpace CalculateScreenspacePositionCanvasSpace(new Vector2(Input.mousePosition.x, Input.mousePosition.y)) Rotation angle of the Map in Radians float theta (MapContentTransform.eulerAngles.z 360.0f) Mathf.Deg2Rad var rotatedX ((mousePositionCanvasSpace.x mapPositionCenter.x) Mathf.Cos(theta) (mousePositionCanvasSpace.y mapPositionCenter.y) Mathf.Sin(theta)) mapRect.width 2.0f var rotatedY ((mousePositionCanvasSpace.y mapPositionCenter.y) Mathf.Cos(theta) (mousePositionCanvasSpace.x mapPositionCenter.x) Mathf.Sin(theta)) mapRect.height 2.0f Thank you Kyy13!
|
0 |
What is the difference between the two circles in the rotation tool in Unity? What is the difference between the two circles in the rotation tool in Unity? In 2D rotation tool there are two circles which allow to rotate an object. And I can not conceive a difference between them. Could someone explain me what is the purpose of having both of them? It seems they both do the same.
|
0 |
Unity3D) Is there a way not to draw line renderer if vertex pos is zero? I make a curved line with line renderer. and a sphere move along it. i want to draw a line only behind the sphere. so i do something like this. lr.positionCount 256 while (delta lt time) lr.SetPosition(i , curPos) yield return new WaitForFixedUpdate() and the problem is, because of i set the size of Positions 256, if time is short, there are zero vectors in position. so line renderer draw meaningless line. is there a way to set PositionCount dynamically like List? or any good way to not draw if positions are zero?
|
0 |
Button not clickable if it's under a Content Size Fitter Horizontal Layout Group in Unity? I'd like to make a Tooltip System Tutorial System. I'm using the Content Size Fitter and Horizontal Layout Group components to have a dynamic text bubble.. Also I'd like to attach a button to it, so when the tooltip appears, the game pauses, and then when the player clicks the button, it closes the tutorial text, resuming the flow of the game. But for some reason the click doesn't reach the component. Not even the animation happen, like something is blocking my button from being clicked. Hierarchy uiTutorialText Has a CanvasGroup to fade the whole structure. Interactable true, BlocksRaycast false TutorialText Has an Image (background) RaycastTarget false Has a Content Size Fitter and a Horizontal Layout Group And Text and Button are just simple plain Text and Button objects, and the Button's Interactable is true. I also tried making the Button a child of Text, and then translating it sideways, so the button doesn't share screen space with the tooltip. But it's not clickable this way as well. As soon as I move the Button out of the hierarchy, like directly under the canvas, it works.
|
0 |
How can I animate draw a line renderer over a given period of time I have created a line renderer using the code below public class MyLineRenderer MonoBehaviour LineRenderer lineRenderer public Vector3 p0, p1 Use this for initialization void Start () lineRenderer gameObject.GetComponent lt LineRenderer gt () lineRenderer.positionCount 2 lineRenderer.SetPosition(0, p0) lineRenderer.SetPosition(1, p1) How can I write a coroutine that will animate draw the line over specific duration, say 2 seconds?
|
0 |
Advice on Story Text Based Game I am currently in preparation on making a game. This game will be looks like Lifeline by 3 Minute Games, which is a story text based game. My game will have the same concept with it. Where there will be a scrollable history of conversation between player and characters in game. However, my game will has more than one conversation history. He will be able to interact with more than one character. Therefore, when the game start, it will show list of interactable characters in game, and player can choose who he will interact with when any available. I am planning to make it with Unity. But I don't know is it possible to create some scrollable history of text, each with different content, like chat history, in Unity. So I wanna ask your opinion, is it good to just continue with using Unity, or should I change the game engine I use? If I should change, what is the best game engine to cope with this kind of game? Thank in advance )
|
0 |
How can I draw orbit paths for a solar system? I m trying to make the orbital paths visible for my solar system simulation game. I have most around with trail renderers and solid line sprite but not achieving the desired look I want. I m hoping to get something where the path is alway present but darker directly behind where the planet currently is, and lighter and more transparent ahead of where it s going. This effect is achieved in the game Worbital. If anyone could point me in the right direction how I can achieve this I would be much appreciated.
|
0 |
how to implement ARVR controller in unity vuforia hello i've been strugling figuring out this thing. i'm trying to make ar controller for my vr cardboard game, so the idea is using AR and VR simultaniously. you will completely in vr game but your phone camera wil be turned on and set to AR mode. while you're in vr mode and your AR camera will detect your marker and repositioned it based on your view and the distance between camera and object. that marker will appear in your vr game and you'll make it as a controller. then maybe you want to make that marker appear as a gun, a sword, a shield or whatever it is that can be work with this concept or maybe you just can watch it to get the idea if my explanation is not clear enough https www.youtube.com watch?v a v a23u6n0 so i'm trying to implement it with vuforia as it's augmented reality API and of course Unity. now i'm on the stage where i already now how to use AR amp VR simultaniously and how to transtition between AR to VR or otherwise. i'm still strugling on how to re potitioning my marker to correct position in my VR world. i already tried asking this in vuforia forum but there's still no answer until now. if you guys can help me with this it would be a big help !! thx before
|
0 |
why command is not executing on local player I am getting very strange behavior, if my player instantiate as host (Server Player) then my command function runs perfectly and certain object become instantiate but if I join the host then my Command doesn't execute on my local player but runs on all other clients. void Start() if (isLocalPlayer) Debug.Log("It is VR Player spawn Start") SetVRLocalPlayerSetting() InstantiateMimicVRHeadAndController() CmdInstantiateMimicVRHeadAndController() else Debug.Log("It is not vr Player its not isLocalPlayer") DisableSelectedMonobevaiourScripts() Command This function have a problem public void CmdInstantiateMimicVRHeadAndController() Debug.Log("instantiateing the controller and head object") vrHeadCopyObj (GameObject) Instantiate(vrHeadObjPrefab) vrRightCtrlCopyObj (GameObject) Instantiate(vrRightCtrlPrefab) vrLeftCtrlCopyObj (GameObject) Instantiate(vrLeftCtrlPrefab) spawn the bullet on the clients NetworkServer.Spawn(vrHeadCopyObj) NetworkServer.Spawn(vrRightCtrlCopyObj) NetworkServer.Spawn(vrLeftCtrlCopyObj)
|
0 |
Unity 2d Constant Player movement along the x axis The movement of my player depends on swipes, swipe left character moves to the left swipe right character moves to the right right now i am only getting a small movement, meaning that the player moves along the X axis but it stops inmediatelly. This is the code i have to check the swipes direction PLayer.cs public Vector2 desiredPosition void Update() if (MobileInput.Instance.SwipeIzquierda) desiredPosition Vector2.left if (MobileInput.Instance.SwipeDerecha) desiredPosition Vector2.right transform.position. Vector2.MoveTowards(transform.position, desiredPosition, moveSpeed Time.deltaTime) In the MobileInput script i control the swipes private const float DEADZONE 100.0f public static MobileInput Instance set get private bool swipeIzquierda, swipeDerecha, swipeAbajo, swipeArriba private Vector2 swipePuntoAhora, touchComienzo public bool SwipeIzquierda get return swipeIzquierda public bool SwipeDerecha get return swipeDerecha public bool SwipeArriba get return swipeArriba public bool SwipeAbajo get return swipeAbajo private void Awake() Instance this Use this for initialization void Start () Update is called once per frame private void Update () Debug.Log(SwipeIzquierda) swipeDerecha swipeIzquierda false region Input Pc if (Input.GetMouseButtonDown(0)) touchComienzo Input.mousePosition else if(Input.GetMouseButtonDown(0)) touchComienzo swipePuntoAhora Vector2.zero endregion region Mobile Input if (Input.touches.Length ! 0) Debug.Log("hola") if (Input.touches 0 .phase TouchPhase.Began) touchComienzo Input.mousePosition else if (Input.touches 0 .phase TouchPhase.Ended Input.touches 0 .phase TouchPhase.Canceled) touchComienzo swipePuntoAhora Vector2.zero endregion region Calcular distancia swipePuntoAhora Vector2.zero if (touchComienzo ! Vector2.zero) Mobile if (Input.touches.Length ! 0) swipePuntoAhora Input.touches 0 .position touchComienzo PC else if (Input.GetMouseButton(0)) swipePuntoAhora (Vector2)Input.mousePosition touchComienzo endregion region Calcular DEadzone del swipe if (swipePuntoAhora.magnitude gt DEADZONE) float x swipePuntoAhora.x float y swipePuntoAhora.y if (Mathf.Abs(x) gt Mathf.Abs(y)) Izquierda o Derecha if (x lt 0) swipeIzquierda true else swipeDerecha true else Arriba o Abajo if (y lt 0) swipeAbajo true else swipeArriba true touchComienzo swipePuntoAhora Vector2.zero endregion The goal of all of this is to If i swipe to te right, the player starts to walk to the right AND continues doing so unless i swipe to the left, only then the player starts to move to the left. I want the movement to be constant in one direction until the other swipe changes it Any help with this will be really appreciated
|
0 |
Unity3D Resources load to materials, how to? I think is a simple question, but I don't know nothing about it I have an created material in my materials folder, I just want to apply it to the GameObject by script. I am trying this.GetComponent lt Renderer gt ().materials 0 Resources.Load("Test", typeof(Material)) as Material The material name is Test and it is in materials folder, but the return is always the default material applied to the GameObject, so I think Unity didn't found it.
|
0 |
How do I access objects that are in the next scene I'm loading? using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.SceneManagement public class HouseExit MonoBehaviour public Transform player public void Houseexit() SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex 1) void OnCollisionEnter2D(Collision2D col) if (col.gameObject.CompareTag( quot Player quot )) Houseexit() GameObject.Find( quot Wizard quot ).transform.position GameObject.Find( quot SpawnPos quot ).transform.position This code belongs to the scene quot Goblin House 1 quot and I'm trying to find the wizard and the spawn position both from level 1.
|
0 |
How to import a NET .dll newer than 2.0 into Unity? I'm trying to build one of the simple EventBus libraries from Github and import them into Unity. Here are the libs TinyMessenger and RedBus It's that simple I take the source code, build it through the VS2015 and place the .dll into the Assets Plugins folder. Then, I have no way to use the lib's namespace (Unity doesn't read the file). Both of these libraries are written in NET 3 or 4 and this is the failure's reason. I've recompiled the second one (removed the System.Linq code, changed the project's version) to NET 2.0 and it worked, but that's not the point. I need the first library and it ain't easy to rewrite the entire 4.0 code to 2.0 without Linq. As I remember, you can use System.Linq in Unity (at least, I did it once). This means that Unity uses some kind of trickery magic, as always. What's the problem here? Is there any way to get this working?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.