_id
int64
0
49
text
stringlengths
71
4.19k
0
Error compiling Unity after porting to mac I used BitBucket to move my project from a PC to a Mac, now I can't compile in my Mac, as I get the following error Error building Player Win32Exception ApplicationName ' Users josephtripp Library Android sdk tools aapt', CommandLine 'package auto add overlay v f m J gen M AndroidManifest.xml S "res" I " Users josephtripp Library Android sdk platforms android 22 android.jar" F bin resources.ap extra packages com.everyplay.Everyplay com.unity3d.ads.android S " Users josephtripp sens rebooted Temp StagingArea android libraries everyplay res" S " Users josephtripp sens rebooted Temp StagingArea android libraries unityads res"', CurrentDirectory 'Temp StagingArea' Any help would be of great use.
0
How can I write a dots effect shader when the character is behind an object? I watched an interesting effect while I was playing Super Mario Odyssey when Mario or another character was behind an obstacle (walls, etc), a tiny gray silhouette mesh appears. I tried to build something similar using an amplify shader with Unity but I could not achieve it. How could I write this? Here is an example from the game
0
Generate smaller quads from a large quad? I have a big quad (100x100) and I was wondering how can I generate smaller quads from this big quad? Such that I will have multiple small quads and I can add a different texture to each quad.
0
How can I deal with tilemap position in the editor? Right now it is quite hard in Unity 2017.2 to track where is the (0, 0) coordinate in the tilemap editor, when painting. I tend to use a displayable dummy game object as a marker. I'd like to also edit two different sets of tilemaps. One set of tilemaps is located at (0, 0, 0) absolute position, and another set of tilemaps in, say, (32, 0, 0) position. However it is quite confusing to me (perhaps there is an option, but I can't find it) when trying to guess where is the internal center of the currently focused tilemap, to start painting. If somehow I had to paint several different tilemaps (more than two sets, say), I'd get easily dazed by the tool. ( A set of tilemaps is not any kind of special objects, but just a concept embracing several tilemaps in the same position). Question Does Unity provide a way in the editor UI to know the place of the (0, 0) coordinate inside the tilemap (when editing and focusing a specific tilemap)?
0
How can I make the terrain infinte? I am making a game in Unity 5 in C and I need to make the terrain infinite. I have tried to make it infinite but it just keeps spawning the terrain too much times and then the game crashes. Does someone know how I can make the terrain infinite? Here is my code. using System.Collections using System.Collections.Generic using UnityEngine public class TerrainScript MonoBehaviour public Transform PlayerTransform private float SpawnZ 4139f public GameObject prefabs private float RoadLength 2.2f private int amountRoads 6 private List lt GameObject gt roadList public void Start() roadList new List lt GameObject gt () public void Update() if(PlayerTransform.position.z gt (SpawnZ amountRoads RoadLength)) spawnTile(0) public void spawnTile(int index) GameObject go go Instantiate(prefabs index ) as GameObject go.transform.SetParent(transform) go.transform.position Vector3.forward SpawnZ SpawnZ RoadLength
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
Why are my click events being fired many times for every click? I am working on a game in unity where a user will click a button to gain coins and clicks over a lifetime of clicking the button but the code is making the clicks go up by a lot instead of just 1 each time it is clicked like here are the values returned the first 3 clicks 247 731 2111 anybody have an idea why it produces this behavior and how i can fix it? using UnityEngine using UnityEngine.UI using System.Collections public class GameManager MonoBehaviour public Button clicker public Text coinsSec public Text ltClicks private float baseClick 2 private float coins 0 private float lifeTimeClicks 0 private float coinsPerSec private void Start() UpdateTxt () private void Update() UpdateTxt () Clicker () private void Clicker() clicker.onClick.AddListener (delegate coins baseClick lifeTimeClicks ) private void UpdateTxt() coinsSec.text "Coins s " ltClicks.text "Lifetime Clicks " lifeTimeClicks.ToString ()
0
How to interpolate colors around the spectrum of hues? I wanted to generate a 7 segment display whose color brightness varies with time, this can be done by just using linear relationship. Color activeColour2 new Color(1, DateTime.Now.Millisecond 0.001f, DateTime.Now.Millisecond 0.001f) So in 1 complete second, it produce color in the range of (1,0,0) to (1,1,1) as in the code below using System using UnityEngine public class ClockDigit2 MonoBehaviour static readonly bool , SEGMENT IS ACTIVE new bool , true, true, true, true, true, true, false , 0 false, true, true, false, false, false, false , 1 true, true, false, true, true, false, true , 2 true, true, true, true, false, false, true , 3 false, true, true, false, false, true, true , 4 true, false, true, true, false, true, true , 5 true, false, true, true, true, true, true , 6 true, true, true, false, false, false, false , 7 true, true, true, true, true, true, true , 8 true, true, true, true, false, true, true 9 public Color32 inactiveColour Color.black public SpriteRenderer segments new SpriteRenderer 7 public void Display(int number) Color activeColour2 new Color(1, DateTime.Now.Millisecond 0.001f, DateTime.Now.Millisecond 0.001f) var digit number 10 if (digit lt 0) digit 1 for (int i 0 i lt 7 i ) if (SEGMENT IS ACTIVE digit, i ) segments i .color activeColour2 else segments i .color inactiveColour void Update() Display(DateTime.Now.Second) However, now I want to interpolate through all the colors in the circle above over 1 second. I don't know how to express this as a formula for R, G, and B. The RGB value is not linear relationship as you spin the selected color in the chart, you can notice the RGBA components vary together in a nonlinear form. I considered using Lagrangian interpolation. However, this will not be accurate or might fail greatly because if you take a reference point at the circle and assume in 1sec, it made a complete revolution, you will notice there is a certain period of time where the RGB value is constant along the path either 0 and 1. So is there any method to get a formula that perfectly fits the color chart with respect to time?
0
Troubleshooting Unity Unity Hub Problems Behind Firewall I'm teaching game design at a high school in the US. This means that we're behind a firewall that does packet inspection. Our lab machines are running Windows 10 and have the school's certificate installed as a "Trusted Root Certification Authority" (as seen in certlm). The problem I'm seeing are Unity Hub (2.0.0) silently fails when trying to download Unity installs Unity (2019.1.3f1) complains about a "self signed certificate in the trust chain" (roughly) This post from the Unity Forums suggests that Unity might know how to read the local computer's list of trusted certificates, but there are also responses indicating that it may not always work. My questions Where do Unity and Unity Hub log certificate errors (do they)? Suggestions for troubleshooting?
0
How can I stop this fixed update from executing so I want this FixedUpdate() Method to stop executing when the Method OnMouseDown() is executed. A bool doesn't work a if() statement also doesn't work Please use my whole code Please help ) Thanks, private void FixedUpdate() int random Random.Range(1, 4) if (random 1) m SpriteRenderer GetComponent lt SpriteRenderer gt () m SpriteRenderer.color Color.green if (random 2) m SpriteRenderer GetComponent lt SpriteRenderer gt () m SpriteRenderer.color Color.blue if (random 3) m SpriteRenderer GetComponent lt SpriteRenderer gt () m SpriteRenderer.color Color.yellow private void OnMouseDown() shouldexecute false
0
Changing animator via scriping I am using the following code, my intention is whenever the 2 objects meet the animator boolean changes and when leave change back to its original setting. But it doesnt seem to work. public GameObject ThePlayer public float TargetDistance public float EnemyHealth public float AllowedRange 10 public GameObject TheEnemy public float EnemySpeed public Animator animator public int AttackTrigger public RaycastHit Shot public static bool hasAttacked false private bool gapTest true void Start() animator GetComponent lt Animator gt () hasAttacked false void OnCollisionEnter(Collision col) if (col.gameObject.name "FPSController") Debug.Log("hit") animator.SetBool("Moving", false) animator.SetBool("Attack1Trigger", true) hasAttacked true void OnTriggerExit(Collider col) if (col.gameObject.name "FPSController") Debug.Log("left") animator.SetBool("Moving", true) animator.SetBool("Attack1Trigger", false) hasAttacked true Any tips on why this does not work? This is hitting the debug.log in the console, but it is not hitting the animator changes or the boolean change
0
Zoom camera on player I am developing a simple side scrolling game. I want to target and zoom camera on player when he dies. But it rotates the screen, and I want to prevent it. I'm copying the snippet of code here IEnumerator ZoomIn() while (GameCamera.orthographicSize gt 2) yield return new WaitForSeconds (0.01f) GameCamera.orthographicSize 0.2f public void ZoomCamera() CameraZoomSource.Play () StartCoroutine (ZoomIn ()) public void TargetPlayer() transform.LookAt (PlayerTransform) GameCamera.orthographicSize 3 GameCamera.transform.Rotate (0, 0, 2) Should I change anything in this?
0
NAT punchthrough failed I finished my game while I was unaware of this error since it only shows up when I disable "WIFI" on my phone and testing it with 3G and 4G. Otherwise, when both devices are on my personal network (and I believe the same network in general) the game works perfectly fine. Whenever two players connect via my own MasterServer I have setup on Amazon AWS services I get this error Receiving NAT punchthrough attempt from target "XXXXXXXXXXXXX" failed in the Unity console for both players. I am running both the Unity MasterServer and Facilitator on the server. There are many question around the internet like this but not a single one with a answer. If this is really not easily fixable Unity should at least mention it's flaws where it provides the MasterServer. I would love to have an answer or at least some insight since now I have my own Linux server on Amazon I'd like to use it too. Currently it looks like my best alternative is using the multi player options from Google Play Services. This is the log I get from the server. Looks perfectly fine but it might help answering. 03 02 2015 02 28 31 INFO New connection established to 24.XXX.XXX.X 62501 03 02 2015 02 28 31 INFO Query request from 24.XXX.XXX.X 62501 03 02 2015 02 28 31 DEBUG Version 2.0.0 connected 03 02 2015 02 28 31 INFO Table Buckrider Studio FourInARow3D not found during query or row removal from 24.XXX.XXX.X 62501 03 02 2015 02 28 41 INFO Connection with 24.XXX.XXX.X 62501 closed 03 02 2015 02 28 41 INFO Removing rows for IP 24.XXX.XXX.X 62501 03 02 2015 02 28 41 INFO 24.132.7.159 62501 has diconnected 03 02 2015 02 28 41 INFO New connection established to 24.XXX.XXX.X 61335 (166633197962428130) 03 02 2015 02 28 41 INFO New connection established to 24.XXX.XXX.X 61336 03 02 2015 02 28 41 INFO Update row request from 24.XXX.XXX.X 61336 03 02 2015 02 28 41 DEBUG Version 2.0.0 connected 03 02 2015 02 28 41 DEBUG Table Buckrider Studio FourInARow3D created. 03 02 2015 02 28 41 INFO Sent row ID 0 in Buckrider Studio FourInARow3D to host at 24.XXX.XXX.X 61336 03 02 2015 02 28 41 DEBUG Updating, inserting 4 at column 4 03 02 2015 02 28 41 DEBUG Updating, inserting public at column 5 03 02 2015 02 28 41 DEBUG Updating, inserting 6 at column 6 03 02 2015 02 28 41 DEBUG Updating, inserting 7 at column 7 03 02 2015 02 28 41 DEBUG Updating, inserting 8 at column 8 03 02 2015 02 28 41 DEBUG Updating, injecting 24.XXX.XXX.X at column 9 03 02 2015 02 28 41 DEBUG Updating, injecting 61336 at column 10 03 02 2015 02 28 41 DEBUG Updating, inserting Welcome to Connect four 3D! at column 11 03 02 2015 02 28 41 DEBUG Updating, inserting 166633197962428130 at column 12 03 02 2015 02 28 41 DEBUG Internal port is 23466 IPs set as 192.XXX.XXX.X 03 02 2015 02 28 50 INFO New connection established to 188.XXX.XXX.X 46374 03 02 2015 02 28 50 INFO Query request from 188.XXX.XXX.X 46374 03 02 2015 02 28 50 DEBUG Version 2.0.0 connected 03 02 2015 02 28 50 INFO Fetching existing table Buckrider Studio FourInARow3D 03 02 2015 02 28 51 INFO Connection with 188.XXX.XXX.X closed 03 02 2015 02 28 51 INFO Removing rows for IP 188.XXX.XXX.X 46374 03 02 2015 02 28 51 INFO 188.XXX.XXX.X 46374 has diconnected 03 02 2015 02 28 51 INFO New connection established to 188.XXX.XXX.X 46375 (300946669)
0
Audio slider doesn't change value For some reason, my slider and audio resets back to 0 when I stop and play the game after I changed the value. Here is the code, I can't spot anything wrong with it using UnityEngine using System.Collections using UnityEngine.UI public class MainAudio MonoBehaviour public Slider slider void Awake() PlayerPrefs.Save () GetComponent lt AudioSource gt ().volume PlayerPrefs.GetFloat ("CurVol") if (slider) slider.value GetComponent lt AudioSource gt ().volume public void VolumeControl(float volumeControl) GetComponent lt AudioSource gt ().volume volumeControl PlayerPrefs.SetFloat ("CurVol", GetComponent lt AudioSource gt ().volume) PlayerPrefs.Save ()
0
How can I make the terrain infinte? I am making a game in Unity 5 in C and I need to make the terrain infinite. I have tried to make it infinite but it just keeps spawning the terrain too much times and then the game crashes. Does someone know how I can make the terrain infinite? Here is my code. using System.Collections using System.Collections.Generic using UnityEngine public class TerrainScript MonoBehaviour public Transform PlayerTransform private float SpawnZ 4139f public GameObject prefabs private float RoadLength 2.2f private int amountRoads 6 private List lt GameObject gt roadList public void Start() roadList new List lt GameObject gt () public void Update() if(PlayerTransform.position.z gt (SpawnZ amountRoads RoadLength)) spawnTile(0) public void spawnTile(int index) GameObject go go Instantiate(prefabs index ) as GameObject go.transform.SetParent(transform) go.transform.position Vector3.forward SpawnZ SpawnZ RoadLength
0
Implementing a game in Unity without Unity Networking I have been programming in Unity for a while, and ever since I started I could not wrap my head around the Unity Networking system. I understand on a whole how it works, I even made a small project using it, but it has always seemed to me like I did not have much control over the system (e.g. managing the streams of data, the lack of documentation about more advanced topics). Therefore, I would like to try to implement a peer to peer game without Unity Multiplayer. My current project has a lot to do with movement ( take for example a fighting game, a brawler), where there is real action constantly being streamed. It is important that when something gets hit, killed, crashed into, the players get the update immediately. I know a few basic thing about socket programming and I am ready to learn even more. I imagine the system being based on byte arrays messages, that trigger specific actions on each player. For Remote Procedural Calls (RPCs), this looks like a good solution, but what about streaming the constant position of a player? How can I stream it fast and easy without overloading the network channel? I would like to hear different approaches to this problem.
0
Retrieving an array of images from Firebase Storage As title says I'm trying to get all images on firebase storage and save them to an array which later on i will be using to load them into the scene. i can manage downloading on image so far but I'm unsure of how to make them into an array. This is the code I'm using now to download one image by name and assigning it into a texture variable storage FirebaseStorage.DefaultInstance storageRef storage.GetReferenceFromUrl( url) storageRef.Child( resourceName).GetBytesAsync(1024 1024).ContinueWithOnMainThread(task gt if (task.IsCompleted) Texture2D texture new Texture2D(1, 1) byte fileContent task.Result texture.LoadImage(fileContent) Debug.Log(texture.name.ToString()) selectedText texture if (task.IsFaulted) Debug.Log( quot faulted DOWNLOAD quot ) ) now through that i want to replace my current function which loads all images through the inspector. if (LevelSystemManager.Instance.CurrentLevel lt source.Length) selectedText source LevelSystemManager.Instance.CurrentLevel Source being the array i use from the inspector to load those images into the game scene which then are selected into the selectedTex Texture2D and loaded based on the level, so 0 element in array level0 , 1 level 1 etc. etc. So i was wondering if i have a couple of folders inside firebase with 10 to 20 images each how can i make that source array pull from that folder? And as a result remove the need to have them in the game and of course not setting them through the inspector.
0
Best way to retrieve const data My game uses big const data which i need to retrieve it to use data used on each level when its needed data security is important I got two options in my head which one is better? Note the data is const and it never changes during game and only i can change it on coding for using it on some levels and after build it always same data 1 using return "data" Something like this which means data stored in script and finding script will expose data if(level number lt 10) switch level number case 1 return data 1 . . . if(10 lt level number lt 20) . . . 2 saving in binary file Check if the file exist read it and if it isn't then create it during game and use it next time This one uses binary formatter to save load data and there is two options for this too 2.1 creating file during game which still have same problem like first solution 2.2 creating file on the editor and load it from plugin folder etc And second one also have storage usage when first one just a script which returns some const data I know you cant stop hackers from hacking offline file but i'm also looking better way to save this big const data and retrieve it to use it Which one is better and if you have better solution i'm happy to hear it
0
UDK or Unity Dynamic Runtime Mesh Boolean subtraction (or alternative) I'm new to 3D game dev and was wondering if anyone could help me out. I'm planning to use UDK and would like to have deformable items in the world. So a projectile strikes a target, and a dent or hole is inflicted. At first I thought there might be a way to load a mesh at the impact point and then "subtract" that mesh from the target mesh. Is this possible? This would allow me to have different "impact effect" like thin and deep, or wide and shallow. (Similar to this, but without requiring DX11) I've searched for this but not sure what to call it (deformable meshes, boolean mesh operations, etc), but if it already has an answer then that would be great. If my approach is wrong, could you point me to any alternatives? Don't really want to go down the chunks route. Or, if Unity etc. supported it, then it's not too late for me to change engine. Thanks very much, Martin
0
Why is unity's RaycastHit2D contact point is slightly off This is a small test I made, basically I have a simple BoxCollider2D that has the top surface aligned with the x axis. It's just a 1x1 cube placed at (0, 0.5). Now when I cast a ray down from position (0, 1) I would expect the resulting RaycastHit2D's contact point to be (0, 0) however when I log the contact point, it shows it is slightly over the actual surface at (0, 2.384186E 07). So the question is, why does this happen? Also, can it be fixed somehow (like tweaking settings or something)?
0
How to get what button was clicked on? Other contexts in which this was done I'm sure have been answered for this kind of problem before. But this has thus far been a 2 week long impasse of wittling down all the other suggestions I've seen and not one has worked. I've got a prefab GUI with a singleton instance based script, which automatically disables itself at the start (I've tried commenting that out to see if that was it). The gui has a title text, body text, and 8 buttons. The script is meant to allow other scripts for interactive objects to safely access it and "start a conversation", using a coroutine. I created a script for the buttons that I attach to each, that when called should set a public bool to true, indicating it was clicked, this bool is polled among the buttons to see which button the user clicked. This is then return to the script which called the GUI, and the GUI closes or waits for the next piece of the conversation. I've set everything to be enabled, and removed anything that disabled the components. I've made sure that the buttons are higher in the hierarchy than everything else, to make sure nothing else was intercepting the clicks. I'm unable to get OnClick, OnMouseOver, OnMouseDown to be called. Debug messages never show. I've tried setting OnClick as part of the GUI where you select a function from the list, and inside of the button's code by adding a listener manually to the button. I've tried IPointerExitHandler, IPointerDownHandler, etc, also never seen anything come back from the methods. I've tried several other methods to date to get which button I clicked, such as ray casting when the mouse button is down and checking the name for the button's name, however it always passes through to the terrain. I've tried getting the button's rect and using Rect.contain with the mouse position to see if the mouse was over the button when clicked, but this never returns true. I'm really interested in seeing a working example where something like this has been done, so that perhaps if that doesn't work, I could at least start hunting down what might be causing a functioning example to fail, as I've no idea what's wrong at this point. Not to vent but this is very frustrating, and I feel it could be made so much simpler. Thank you all for any help you can give, you guys have been very wonderful with my short time here.
0
unity android output is about 120mb even with just an empty scene there is a lot of content in my project but as a test I just chose a empty scene with one sprite to build but the apk output size is about 120mb. I think there is an options or setting or platform support that makes it much big but I don't know what it is. thank you for helping
0
Need help accessing booleans from other script Unity3D I'm making an endless runner game where platforms move towards the player so it makes it seem like the player is running across them. I'm trying to make it so that when the player dies, the platforms stop moving. What I have isn't working, when the player dies, the platforms just keep moving as if nothing has happened. Here is the script I have that is attached to the player using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.SceneManagement public class CoinColliderScript MonoBehaviour void OnTriggerEnter(Collider target) if (target.tag quot Enemy quot ) StartCoroutine(Died()) IEnumerator Died() PlatformMover.dead true gameObject.GetComponentInParent lt Animator gt ().Play( quot Male Died quot ) yield return new WaitForSeconds(0.5f) SceneManager.LoadScene( quot MainMenu quot ) Here is the script I have that is attached to the platforms using System.Collections using System.Collections.Generic using UnityEngine public class PlatformMover MonoBehaviour private Vector3 newPlatPos public float platMoveSpeed public static bool dead public void Start() dead false void Update() if (dead) newPlatPos new Vector3(transform.position.x, transform.position.y, transform.position.z) else if (!dead) newPlatPos new Vector3(transform.position.x, transform.position.y, transform.position.z platMoveSpeed) transform.position newPlatPos New Code Attached to platforms public class PlatformMover MonoBehaviour private Vector3 newPlatPos public float platMoveSpeed void Update() if (!CoinColliderScript.Dead) newPlatPos new Vector3(transform.position.x, transform.position.y, transform.position.z platMoveSpeed Time.deltaTime) transform.position newPlatPos Attach to player public class CoinColliderScript MonoBehaviour private static bool dead false public static bool Dead get gt dead set dead value print( quot 'Dead' changed to quot value) void OnTriggerEnter(Collider target) if (target.tag quot Enemy quot ) StartCoroutine(Died()) IEnumerator Died() dead true gameObject.GetComponentInParent lt Animator gt ().Play( quot Male Died quot ) yield return new WaitForSeconds(0.5f) SceneManager.LoadScene( quot MainMenu quot )
0
How to make an existing Editor window floatable I added a second inspector window tab to Unity and locked it. I tried moving it to another desktop on my Mac but it doesn't move to the next desktop. How can I make a duplicate Inspector Window floatable?
0
Why am I not getting stuck in the loop I'm new to Unity. I was learning coroutines and I wrote this. private void Fire() if(Input.GetButtonDown("Fire1")) StartCoroutine(FireContinuously()) if(Input.GetButtonUp("Fire1")) StopAllCoroutines() IEnumerator FireContinuously() while(true) GameObject laser Instantiate(LaserPrefab, transform.position, Quaternion.identity) as GameObject laser.GetComponent lt Rigidbody2D gt ().velocity new Vector2(0, 10f) yield return new WaitForSeconds(firetime) When the button is pressed the coroutine is called and it enters the 'while' loop. When I leave the button it stops the coroutine. Shouldn't it get stuck in the 'while' loop as it is an infinite loop ? Why?
0
How to properly synchronize achievements on Google Play Services? I have a mobile game with achievements on android, so the achievements are using Google Play Services. For a couple of reasons, I must track the progress on the achievements locally (or so I think) because If the user is not connected to the internet Some achievements have complex "step" that the simple increment system provided by the Google Play Service (number of steps, current step) cannot track. When the game starts, the local copy data on the achievements is synced with what is on Google's server. Either both are the same, do nothing the local copy has more progress than what is shown on Google's so update Google data (that happens if you play offline) the copy on Google's server show more progress than locally so update the local data (that happens if you play on a different device) Clearly, there's a way to abuse the system here. Given two players with different achievement progress (Player A (lots of achievements), Player B (few achievements)) they can do the following Using Player B's device, Player B signs out of his account Player A signs in (the current active Google Account is now Player A) Start the game All of Player A's achievements are synced locally (they had more progress than the previous local version of Player B) Player A signs out and Player B signs in Re start the game the local copy will show as more advanced than Player B achievements, therefore they will get updated. How do people deal with this problem? Not care? Key the local achievement progress to the logged in player (which causes some problems)? Not to track anything related to the achievements locally (but how to deal detect being offline?)
0
Get the dropped object using IDropHandler.OnDrop In Canvas, I drag some UI objects to a panel using this code public void OnDrag(PointerEventData eventData) Vector3 screenPoint Input.mousePosition screenPoint.z 10.0f Item2Drag.position Camera.main.ScreenToWorldPoint(screenPoint) But what I can't figure out is when I dropped an object on the panel, how can I get the gameObject which has been dropped?
0
Failed to spawn server object, Unity UNET I'm familiar with Unity and programming but I'm new to this site. So I have an issue with clients on Unity. I start servers with no errors, flawless. But when I join a server as a client I get a bunch of the error mentioned in the title. What causes this issue? I am using the UNET networking components. I think it's lines like these, when executed by a client NetworkServer.Spawn (objectNameHere) How can I fix it if that's the case? Edit After hours of having this issue I have become so frustrated that I think it's best I take a break. I'll check back on this site from time to time.
0
Why am I not getting stuck in the loop I'm new to Unity. I was learning coroutines and I wrote this. private void Fire() if(Input.GetButtonDown("Fire1")) StartCoroutine(FireContinuously()) if(Input.GetButtonUp("Fire1")) StopAllCoroutines() IEnumerator FireContinuously() while(true) GameObject laser Instantiate(LaserPrefab, transform.position, Quaternion.identity) as GameObject laser.GetComponent lt Rigidbody2D gt ().velocity new Vector2(0, 10f) yield return new WaitForSeconds(firetime) When the button is pressed the coroutine is called and it enters the 'while' loop. When I leave the button it stops the coroutine. Shouldn't it get stuck in the 'while' loop as it is an infinite loop ? Why?
0
How can I move the object back to his original position after the object reached the target? InteractableItem target private void Update() if (target ! null amp amp target.name quot kid from space helmet quot ) objToThrow.transform.position (target.transform.position objToThrow.transform.position).normalized 2f Time.deltaTime if(Vector3.Distance(objToThrow.transform.position, target.transform.position) lt 1f) objToThrow.transform.position (objToThrow.transform.position target.transform.position).normalized 2f Time.deltaTime The object is moving to the target but never moving back. This IF is not working good if(Vector3.Distance(objToThrow.transform.position, target.transform.position) lt 1f) My guess is that the problem is that when the object distance is less then 1 he try to move back but then he is not less then 1 anymore. but anyway it's not working. I want to move the object to the target then wait 1 second at the target and then to move the object back.
0
How to see which mouse button was pressed (Unity Input System) I have switched my game to use the new Unity Input System, and I want to know which mouse button was pressed when an action is called. Here's how it's set up Whenever one of these three mouse buttons are pressed, the MouseButtonClicked action will fire. I want to somehow know which one of these buttons was pressed from this single action, rather than making 3 seperate actions for 3 seperate mouse buttons. I have tried reading the values from InputAction.CallbackContext context but I can't seem to get a proper value from the mouse button which was pressed. How can I do this?
0
Unity Instantiate GameObject from client on Network I am building a game where a weapon shoots prefab bullets. I am trying to make this a multiplayer game, so the bullets need to be spawned into the Network. What happens right now is that if I shoot a bullet from a host, the bullet is shot, but doesn't appear on the client screen. If I shoot the bullet from the client, the bullet doesn't appear on either screen. In fact, the function CmdShoot() isn't even called, as the Debug.Log("Hello") is not called. Here is the current code public class Gun MonoBehaviour private GameObject bulletPrefab void Update() if (Input.GetMouseButtonDown(0)) owner.GetComponent lt PlayerSetup gt ().CmdShoot(bulletPrefab, transform.position, owner.name, GetComponentInParent lt Weapon gt ().angle) public class PlayerSetup NetworkBehaviour void Start () Disable components if not local player Command public void CmdShoot(GameObject bulletPrefab, Vector3 position, string playerName, float angle) Debug.Log("Hello") GameObject bullet Instantiate(bulletPrefab, position, Quaternion.identity) bullet.name "bullet " playerName bullet.GetComponent lt Rigidbody gt ().AddForce(Quaternion.AngleAxis(angle, Vector3.forward) Vector3.right bulletPrefab.GetComponent lt Bullet gt ().force) Destroy(bullet, 10f) NetworkServer.Spawn(bullet) Edit This piece of code doesn't work either, gives the same result. No error, but the function is also not called. The Input is detected though void Update() if (Input.GetMouseButtonDown(0)) CmdShoot() Command void CmdShoot() Debug.Log("Shoot") GameObject bullet Instantiate(gunComponent.bulletPrefab, gun.position, Quaternion.identity) bullet.name "bullet " transform.name bullet.GetComponent lt Rigidbody gt ().AddForce(Quaternion.AngleAxis(GetComponentInChildren lt Weapon gt ().angle, Vector3.forward) Vector3.right gunComponent.bulletPrefab.GetComponent lt Bullet gt ().force) Destroy(bullet, 10f) NetworkServer.Spawn(bullet)
0
Finding a moving target in a maze I'm making a game that is a bit of a mix of snake and pacman. Basically, two players go through the maze and each time they pick up a piece of candy, a cube is added to their tail. If one player touches the other's tail, he steals that piece for himself and the game is over when one player has all the pieces. Right now they both move randomly unless there's a piece of candy one space away that is not their tail. I'm trying to find a method algorithm (preferably a different method for each player) for both players to target avoid the other player. Any advice?
0
The tile cursor is not on the same tile I selected Here is the image, when I select the tile I want to paint, it paints in the correct box where I want it to be but the white cursor should also be in the same box but it is 2 units to the left? This really makes it difficult to paint the tiles. I'm a beginner in unity and can't seem to fix this problem ( Thank you for your help!
0
How to enable and disable scripts on a Game Object? This worked briefly yesterday, I believe I did something to mess this up. All my inputs that I put in are correct therefor, it must be the code. I want to switch players. While the red cube's script is enabled and can move under the movement script I want the blue cubes movement script to be disabled and vice versus. Can you give me some insight into what I'm doing wrong? Please and thank you!! using UnityEngine using System.Collections public class PlayerMovementScript MonoBehaviour public float speed 2f public float height 2f public Component playerMovement public GameObject redCube public GameObject blueCube void Start() var bc blueCube.GetComponent lt PlayerMovementScript gt () bc.enabled !bc.enabled Update is called once per frame void Update () if (Input.GetButton ("Right")) transform.Translate(Vector3.right speed Time.deltaTime) if (Input.GetButton ("Left")) transform.Translate(Vector3.left speed Time.deltaTime) if (Input.GetButton ("Jump")) transform.Translate(Vector3.up height Time.deltaTime) var bc blueCube.GetComponent lt PlayerMovementScript gt () var rc redCube.GetComponent lt PlayerMovementScript gt () if (Input.GetButton ("Switch")) bc.enabled !bc.isActiveAndEnabled rc.enabled !rc.enabled
0
Avoiding GC Allocation in Unity UNet API I'm trying to profile the game using Unity Profiler, I can see in the Hierarchy tab that there's an 18.3 KB correlated to NetworkIdentiry.UNetStaticUpdate(). I guess this has happened inside the Unity UNet API, is there a workaround to avoid that to happen? and why an internal Unity calls can cause GC?
0
How to calculate a direction that will turn a parent so that a locally rotated child is faced in a given direction? Imagine an old sailing ship with cannons they're pointed out at 90 angles from the ship's hull, so in order to fire them, you have to turn the whole ship so that the cannons are pointed at the target. I'm hoping to figure how to calculate quot where to point the ship so that the cannons are aimed correctly, quot but for any possible cannon angle (not just 90 ) in 3D space. I'm an experienced dev but a total 3D newb, so this vector stuff is wrinkling my brain. This is what I have right now, calculated from the child's (cannon's) gameObject Vector3 directionToAim (transform.localRotation (transform.position target.position)).normalized It's working for side facing weapons (like the sailing ship), but for forward facing weapons it turns the parent in the opposite direction, directly away from the target. If I invert it to (target.position transform.position) the forward facing weapons work fine, but the side facing weapons face the opposite way. Also, my vague understanding is that it's better to use Quaternions for this, rather than Vector3, is that right? Can someone help me grasp how these parent child rotations can be calculated?
0
How is the density of a collider determined? I read here that, once determining the density of a Buoyancy Effector, "Colliders with a higher density sink, those with a lower density float, and those with the same density appear suspended in the fluid." However, I did not find a density field in my CircleCollider2D. What I found is that If I increase the mass of the attached RigidBody2D, then the body sinks into the fluid since apparently its density increases. If I keep the mass but decrease the size of of the circle collider, then again the body sinks into the fluid indicating that its density increases. So my conjecture is that the density is calculated by the mass of the rigid body, divided by the volume of the collider. But I did not find the formula in the Unity manual. Is this correct?
0
Quaternion.AngleAxis smallest value? If I'm using an angle with a value of somewhat below 0.1 degrees in Quaternion.AngleAxis, the quaternion will not apply a rotation at all. Why is this?
0
Separate data tables for different item types? I have two types of items in my game, consumables, and equipment. For my database, should I store them in two different tables, or all in one big items table?
0
Unity ad does not show I have imported the advertisement package from the package manager, turned the ads service on, and added a script string gameId quot correctGameId quot bool testAds true void Start() Advertisement.Initialize(gameId, testAds) void Click () if(Advertisement.isInitialised) Advertisement.Show() This Click function is called from a button's OnClick event. Every time I play in the editor and click the button, nothing happens. How can I make my advertisement show?
0
Automated Unity iOS command line build on Mac I am doing the iOS builds for a group of Unity (Unity3d) game developers. After pulling the latest git updates, I start up the Unity editor on my Mac and choose "Build Settings", select the iOS target platform, press Build, specify a destination folder and that is it. Can this exact process be done automatically via the terminal prompt?
0
How to handle levels in Unity3d I m making a top down 2d game in Unity3D for Android based smartphones. Currently I have two scenes a preloader and the game itself with all the stuff I need packed into one scene file. Also there is a very simple game state manager in my scene. My question now is Is it better to script all the levels within one scene file or should I seperate them into unique scene files? I m just asking because basically the levels are very similar to each one only the background and the sprites are different. Is there a problem with memory management if I use one scene only?
0
Controlling a balance wheel using a Unity script I am working on a small demonstration project with Unity like this (screenshot from footage below). I don't want to use Unity physics, which is too heavy. I plan to create a rotation function with ratio params for gears. But I am not sure how to control the balance wheel rotation like that video, I tried animation tools which is hard to make the acceleration like real physics.
0
Unity doesn't show always the score I don't know if this issue is in Unity or in my script, the score work well in scoreText, but in the scorePanel its show before last score like it showing 1 rather than 2 the issue doesn't always appear its appear just in specific moment when my score and player die nearly in same time, so here is my script. AddToScore is called with InvokeRepeating, scoreText who show me the correct score, it works well void AddToScore() score scoreText.text score.ToString () mySound.Play() This is when my player Die void OnCollisionEnter2D(Collision2D other) Time.timeScale 0 Die () void Die () Pause.SetActive (false) Panel.SetActive (true) GameOverPanel.SetActive (true) GenerateObstacles.HighScore () And here is the HighScore from GenerateObstacles public void HighScore() if (score gt highScore) PlayerPrefs.SetInt ("highScore", score) highScore PlayerPrefs.GetInt ("highScore") scorePanel.text score.ToString () highScorePanel.text highScore.ToString () else if (score lt highScore) highScore PlayerPrefs.GetInt ("highScore") scorePanel.text score.ToString () highScorePanel.text highScore.ToString () Here is a paint to understand
0
problems with imported texture I have done a texture in GIMP and imported it in Unity but for some reason the texture appears to be squashed in the sides. Image done in gimp And here is what happens in Unity
0
How can I keep the drawn lines instead deleting them? using System.Collections using System.Collections.Generic using UnityEngine public class DrawLines MonoBehaviour private Transform startMarker, endMarker public GameObject waypoints private float speed 2f private float startTime 0f private float journeyLength 1f private int currentStartPoint 0 private LineRenderer lineRenderer public void StartInit() currentStartPoint 0 SetPoints() lineRenderer GetComponent lt LineRenderer gt () lineRenderer.startWidth 0.2f lineRenderer.endWidth 0.2f void SetPoints() startMarker waypoints currentStartPoint .transform endMarker waypoints currentStartPoint 1 .transform startTime Time.time journeyLength Vector3.Distance(startMarker.position, endMarker.position) void Update() if (waypoints.Length gt 0) float distCovered (Time.time startTime) speed float fracJourney distCovered journeyLength Vector3 startPosition startMarker.position Vector3 endPosition Vector3.Lerp(startMarker.position, endMarker.position, fracJourney) lineRenderer.SetPosition(0, startPosition) lineRenderer.SetPosition(1, endPosition) if (fracJourney gt 1f) if (currentStartPoint 2 lt waypoints.Length) currentStartPoint SetPoints() else if finished, disable lineRenderer and this script lineRenderer.enabled false this.enabled false Each time it's drawing a line between two waypoints but then the line is deleted and then it's drawing a new line between the next two waypoints. Instead I want it to draw one line between all the waypoints. And to keep the line in the end not to delete it.
0
How to develop VR PC games without a Head Mounted Display of my own? I am an intermediate student of Unity 3D, and I am not able to purchase heavy and expensive equipment like Oculus Rift, HTC Vive, or other models that are not available in Pakistan. So I'm wondering how I can develop VR games without these peripherals.
0
How to deal with inconsistent network delay caused by packets arriving at different times in the frame? I'm developing a multiplayer game that does not have prediction. It implements client side interpolation. The problem with this is that input delay can be perceived. I've measured the various times involved in calculating the delay(packet arrival time, server respond time, time spent interpolating), and it seems about 50ms is spent on interpolating(correct), and 60ms is spent on ping and what I can only assume to be unfortunate message arrival time. The ping is 18ms, which leaves 42ms. If the message arrives at the server immediately after the server has finished reading it's incoming messages this frame, we suffer at least a 16ms delay(at 60fps) that wouldn't be there if the message arrived right before the reading. If this happens with both the server and the client, the delay really adds up, especially at lower frame rates. How can posts like this http pastebin.com ekk07PKn claim to have exactly 50ms delay with 0 ping if this is an issue? If it's relevant, this is being developed with Unity3d and the Lidgren networking library in C . I've moved the server snapshot writing to a different thread with a lock around the game world update method. This helped a lot, but from what I understand moving the reading to a different thread won't help in the same way, because the client won't be able to use the new information until the next frame anyway.
0
In Unity UNet How do you properly spawn a NetworkPlayer ? In Unity UNet How do you properly spawn a NetworkPlayer? Right now, I'm doing it like this from inside a NetworkManager derived class public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) NetworkPlayer newPlayer Instantiate lt NetworkPlayer gt (m NetworkPlayerPrefab) DontDestroyOnLoad(newPlayer) NetworkServer.AddPlayerForConnection(conn, newPlayer.gameObject, playerControllerId) This code snippet works pretty well and both clients can communicate with each other. However, there are a few little issues that arise only on the host In Unity's hierarchy view on the host, there are only two NetworkPlayer instances. Shouldn't there be four NetworkPlayer instances on the host? Two client instances and two server instances? If so, do you have any ideas what could cause the missing NetworkPlayer instances? The two NetworkPlayer instances have both, their isClient and isServer flags set to true. But only one of the has it's isLocalPlayer flag set. Now I wonder if this behavior is as intended? And if so, how do you distinguish between the client and the server instance of a NetworkPlayer? Two player behavior If the remote client sends a Command that changes a SyncVar on the server, then on the host, the SyncVar hook is called only on the NetworkPlayer instance that represents the remote NetworkPlayer. The SyncVar hook is not called on the host's "isLocalPlayer NetworkPlayer" instance. Shouldn't the SyncVar hook be called on both NetworkPlayer instances? Any advise is welcome. Thank you!
0
Unity3D Problem Temporarily Stop Players Movement When Playing a specific Animation This is my first time in Unity3D and programming so forgive me if i'm a bit vague on this. I'm working on my own project in Unity3D but I couldn't get the player to stop moving when I press the key. I avoided using the GetButton since it triggered the animation to play twice. After bout 2 hours, I still can't find any answer to my problem. Can someone help me please? Here's part of the code of the the player script. if (Input.GetButtonDown("Fire1")) animator.SetTrigger("AttackSword") Debug.Log("Animation called") if(!animator.GetBool("AttackSword")) Move(inputDir, running) If you would like me to add the full code of the script, let me know.
0
Car simulation, motor torque and brake torque combine problem I am creating a custom wheel collider in Unity. Every thing is fine now (suspension, collision, friction) except one problem that i cant get my head over for last 3 weeks. So now i have a car (one wheel only), it stand on top of a hill, then i apply a brake torque enough to make it stand still, after that i apply a motor torque that less than max brake torque, my question is how the car behave?. In my opinion, that if sum of motor torque (roll down hill direction) and gravity torque(friction force radius) greater than the max brake torque will cause the car to roll down hill, and it remain stand still if motor torque (roll up hill direction). I really need help! So i have mT(motor torque), bT(max brake torque), fT(max ground torque), rT(residual torque) if ( mT gt bT ) rT mT bT if ( rT gt fT ) wheel spin up with sign(mT) ( rT fT ) ground force sign(mT) fT radius else wheel roll without slipping ground force mT radius else rT bT mT if ( rT gt fT ) wheel slow down to 0 with sign(omega) ( rT fT ) ground force sign(velocity) fT radius else wheel roll without slipping ground force sign(velocity) ( bT sign(velocity) mT) radius All torque sign are on top.
0
How to activate GearVR Menu in my own Unity Apps? So in normal GearVr Apps, which you can download from the marketplace, you can activate the GearVr Menu to control brightness etc. with a long click on the back button. But this does not work for all of my apps which I made with Unity for the GearVr, is there something special I have to import into my project?
0
Iterating through all animator layers in Unity Mecanim I'm aware of how SetAnimatorLayerWeight works, I'm looking for a way to iterate through all layers of my controller at runtime. I've four layers and expect more, and need to update them at once, in essence, what I'm trying to do is something like this. To clarify The code below is boilerplate of what I'm trying to do. void SetCurrentWeaponLayerWeight(int index) animator.SetLayerWeight(index, 1) foreach(AnimatorLayer l in Animator.Layers) if (l.index ! index) animator.SetLayerWeight(l.index, 0)
0
Having player names over models in 3d space I wanted to have in my multiplayer game, the players name's over their models, however I am faced with the question of how? Should I create a new Canvas object for each game model or just use 1 main canvas and move their names around relative to position in 3D world space? My aim is to have an open world game.
0
Best way to connect multiplayer users with each other (matchmaking) on a low powered server? OK so I am using unity to make a multiplayer game, but I'm not sure how to connect players with each other over the internet. Unlike other questions, this isn't a general problem of working out how to do UPnp or using unity's matchmaking server. My issue is that my server that I would use is a simple low powered pc (running normal windows 10, no idea how to use windows server). I think it is powerful enough to match players with each other, but not to host more than one or two actual games. The other issue is that I have a residential internet connection with a dynamic ip that changes every few months. However the speed should be ok (150Mb s download, 20Mb s download). Also, I'm not planning to spend money on a monthly basis for a server (like unity's matchmaking service) as I plan to spend as little as possible (So far I've paid 12 to Microsoft for a dev account and I've received a 200 voucher from them so my current spending is 189!) So my question is should I use my server (would it work), are there any online services that are very cheap to use, or is there another way to make this work? Only other thing is I could use the free 20 users at once on unity's matchmaking, but would this limit be too small? EDIT just for information, my game is a simple tank shooter. I was thinking about limiting the amount of tanks in a game somewhere around 8 20. The bullets in my game are physical objects with rigidbodys and they move at a slower speed (if you've ever played tank trouble, it looks like that). The world is in 3D. There is a potential for there to be up to a hundred bullets in a scene at once at the worst. After hosting a LAN world with 7 players connected for about 20 30 minutes, windows reports the data usage being around 3 4MB.
0
How to not move my character when they collide using Unity and Box Collider? I'm trying to get my characters near to each other so they can attack the other one, but when the player character or otherwise gets near they are pushed to the other direction when they collide. How to prevent that happen so they won't move when touching each other? This is the player objects The Treant objects I what I want is that they collide and can't move through each other and stop moving. But this keep happen gif of my treant getting pushed away Can someone help me with this issue?
0
How can I my homing missile avoid walls (2D)? Okay, I have the homing missile implemented. It will follow the player, but I want it to avoid the walls. I tried out A but I want to make my own. I need some help plzz.
0
Detecting when a car is out of the track I am completely new to Unity 3D, just started to follow some tutorials y'day. I am trying to build a 2D car racing game as a part of my learning (time beating, no opponents). I have a racing track as texture (repeating). My problem is knowing when the car is outside inside the track (I wouldn't prefer to limit it to the track boundaries). What I have tried after searching around I read somewhere about Mesh Colliders so I added a mesh collider to the track (with 'Convex' and 'Is Trigger' checked , to be honest I don't know what Convex is, but I couldn't check 'Is Trigger' w out checking 'Convex'). Added OnTriggerExit and OnTriggerEnter methods to the Track script (the script that scrolls the track) hoping the two would be called each timer the car goes out of the track or gets back in. Apparently the two methods aren't called at all, Would someone please help. Thanks.
0
Converting to JSON String with JsonUtility.ToJson I am working on converting and displaying the JSON String with unity. I have done coding for it using UnityEngine using System.Collections using LitJson using SimpleJSON using System.IO public class TestDelete MonoBehaviour JsonData json void Start() Data2 data new Data2() Payload2 data2 new Payload2() data.command "state" data.payload new Payload2() text "wwwwwww", image "hello" data2.option new Option () A1 "k", A2 "J" string dataValue data data2.ToString() string json JsonUtility.ToJson(data,true) P(json " t n") Use this for initialization void P(string aText) print (aText " n") System.Serializable public class Payload2 public string text public string image public Option option System.Serializable public class Data2 public string command public Payload2 payload System.Serializable public class Option public string A1 public string A2 This code of working fine.But with the output Iam having problem.The out is displayed as follow "command" "state", "payload" "text" "wwwwwww", "image" "hello", "option" "A1" "", not getting displayed "A2" "" not getting displayed the string value A1 and A2 is not getting displayed.What will be the issue with my code.Can anybody help me sorting out this issues
0
Unity "static" references I have been researching this for 2 days now and I cannot seem to find a proper response. I am trying to figure out a good way to store constant variables within my game. Basically, does it make more sense to create a singleton script that holds all my prefabs inside it so I can easily access them and instantiate through the game? Or does it make more sense to keep all my assets inside the Resources folder and then call Resources.Load throughout the game (or through a Static class that holds references to all the resource paths and loads the resources on start up) I have the same question regarding variables used within runtime. Would it be better to run through the Static class that is holding all these prefabs through the Resources folder? Or would it make sense to also hold these values inside the singleton. Thank you!
0
Determine where is player facing up, down or left right I have a player object who can rotate(face using mouse) up, down left right and can face straight. I am willing to know that how to determine that where is camera facing? Either it is looking up or down?? while the player is continuously moving in a up down surface.
0
How can I tell how much of a "scratch card" has been revealed? I have developed scratch card effect.I am now working on reward system, so my question is how will I go on and implement logic which will let me know that the object behind scratch card is now visible??
0
canvas not found in game view with unity I am working on a GearVR app with Unity3D.I have an environement and I have placed a canvas in the scene.I have set the canvas Render mode to "World Space".But when I runned my project,the canvas is getting displayed on the scene view,but in the game view the canvas is not getting on the scene.But whereas in the camera view its showing the canvas.What will be the issue?. When I set me canvas Rendere mode to Screen Space Overlay the canvas is getting displayed in the scene but as the lookup change,the canvas is also moving along with the camera Can anybody please help me out.
0
SerializedPropertyBindings NullReferenceException Using Unity 4.6.1 Pro Visual Studio 2013 Pro, c Team Foundation Connected to git vc Windows 7 Premium Building 2D iOS app (2D set up) Details Periodically, this error is occurring. There is no pattern to invoke this error so far. I then found this on the official Unity forums Strange error showing up But, I would like to avoid creating an entirely new project and re importing everything, since it is getting to become a slightly large project. I do remember deleting an asset out of the file directory(not in unity), on accident, so this may be the issue. Is there any way to clean wipe fix this issue, w o doing a fresh project and import? I appreciate the guidance.
0
Strange I'm getting exception but the scripts in the exception message are not exist on my pc. What should I do? I'm using unity version 2019.2.5f1 personal I searched on my hard disks the entire pc and none of the scripts in the exception message are exist. And the exception is happens only sometimes. When I stop the game in the editor by pressing the play button the exception is show sometimes and sometimes not. I tried to close and open over agai the unity editor and the project. Still strange. MissingReferenceException The object of type 'ReflectionProbe' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEditor.ReflectionProbeEditor.OnPreSceneGUICallback (UnityEditor.SceneView sceneView) (at C buildslave unity build Editor Mono Inspector ReflectionProbeEditor.cs 651) UnityEditor.SceneView.CallOnPreSceneGUI () (at C buildslave unity build Editor Mono SceneView SceneView.cs 3359) UnityEditor.SceneView.DoOnPreSceneGUICallbacks (UnityEngine.Rect cameraRect) (at C buildslave unity build Editor Mono SceneView SceneView.cs 1935) UnityEditor.SceneView.OnGUI () (at C buildslave unity build Editor Mono SceneView SceneView.cs 2320) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture) (at lt 599589bf4ce248909b8a14cbe4a2034e 0) Rethrow as TargetInvocationException Exception has been thrown by the target of an invocation. UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C buildslave unity build Modules UIElements Renderer UIRChainBuilder.cs 238) UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C buildslave unity build Modules UIElements Renderer UIRRepaintUpdater.cs 66) UnityEngine.UIElements.UIRRepaintUpdater.Update () (at C buildslave unity build Modules UIElements Renderer UIRRepaintUpdater.cs 54) UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at C buildslave unity build Modules UIElements VisualTreeUpdater.cs 72) UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at C buildslave unity build Modules UIElements Panel.cs 637) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C buildslave unity build Modules UIElements UIElementsUtility.cs 240) UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C buildslave unity build Modules UIElements UIElementsUtility.cs 78) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C buildslave unity build Modules IMGUI GUIUtility.cs 179)
0
Make handlers visible on scene load In my dev enviroment I have a couple custom handlers I want to always be visible. I have already figured out that I can do this by deriving a class from Editor, linking it to the desired component type, and then appending the render method to SceneView.duringSceneGui (in OnEnable(), as the target gameobject information will be available there). However, this appending now only happens once a specific gameobject carrying the component has been selected. Is there a way I could have the Editor's OnEnable() method properly trigger on opening a scene, for all relevant gameobjects, without manually selecting them first?
0
Unity Controlling animation by switching between a GameObjects children I bought an asset the other day containing an Atlas of character parts (head, hairs, clothes, body parts). It's great and allows me to tint each piece any color I want. However, The artist decided to devide up the character like this Each child is a fully setup character, facing a certain direction, with an Animator attached to it, inside each Animator Controller you find this Some sample animations, pretty self explanatory. However, I have never worked with sprites like this where its several parts, the entire character is maybe 30 40 parts (allowing for some fun animations). I'm used to making Blend Trees (on a single GameObject) and have one animation for each direction. The best solution for controlling these animations I could think of was something like this private void AnimControl() call in update if(direction ! directionLastFrame) do not run method if we are moving same direction standing still if (direction.x 0 amp amp direction.y 0) directionLastFrame direction left else if (direction.x lt 0.5f amp amp direction.y 0) currentCharacterDirection.SetActive(false) set current gameObject (which is a character facing a certain direction) inactive currentCharacterDirection character.leftDirection change to correct direction currentCharacterDirection.SetActive(true) set gameobject active again anim currentCharacterDirection.GetComponent lt Animator gt () set the animation controller to the new gameObject directionLastFrame direction set the new direction to check for right else if (direction.x gt 0.5f amp amp direction.y 0) currentCharacterDirection.SetActive(false) currentCharacterDirection character.rightDirection currentCharacterDirection.SetActive(true) anim currentCharacterDirection.GetComponent lt Animator gt () directionLastFrame direction down else if (direction.y lt 0.5f amp amp direction.x 0) currentCharacterDirection.SetActive(false) currentCharacterDirection character.downDirection currentCharacterDirection.SetActive(true) anim currentCharacterDirection.GetComponent lt Animator gt () directionLastFrame direction up else if (direction.y gt 0.5f amp amp direction.x 0) currentCharacterDirection.SetActive(false) currentCharacterDirection character.upDirection currentCharacterDirection.SetActive(true) anim currentCharacterDirection.GetComponent lt Animator gt () directionLastFrame direction anim.SetBool("Moving", playerMoving) I mean it works, but feels wrong? Anyone that can think of a better Idea here, worried this might be too slow. setting an object to active inactive too often.
0
How to make an enemy spawner that selects from a list of potential enemies? (Unity) I'm just making a practice version of a basic 2D RPG, but I'm trying to build a spawner kind of object that could be scaleable across the entire game. That is, there would be multiple types of enemies, and each instance of such a spawner would have a specific set of enemies that it would spawn. I'm sure the answer is very simple, but I'm at the beginning stages of all of this. I guess really I just want a simple list that I can attach to my object and add the enemy names to it so that it can draw from that to figure out what they would spawn.
0
Collider for Unity Line Renderer I have several line renderers that are using as gas pipelines. A user can select one end of the pipe and attach it to one connector. Now the problem is some pipes (line renderer) are overlapping and penetrating with each other. Is there any way to avoid penetration using colliders so they look realistic?
0
One Android app, dynamic load several Unity games I'm a newbie in this unity world, exciting about everything in it. Days ago I came up with this idea One day someone finds this android app, naming "Blahblah Game Engine" or anything else. This app has to be very small, containing only some simple activity and Unity runtime, without further resources related to any specific game. He installs it and sees an android activity, maybe a webview, showing a list of unity games the server currently hosting, produced by the very same Blahblah company. Then he clicks on one and this "Blahblah Game Engine" loads the game build via network, starts an Unity activity, without prompting an installing dialog. He can exit the current game whenever he likes, returns to the previous game list, and plays another, all working well in one app's lifetime. In a word, the user experience is very much like how we play games on www.kongregate.com with pc browsers light weight app, mutiple games in one list, all loads via network, playing right away and installing less. Any game that listed in this app should not be installed as a standalone android app, it should be part of the "Blahblah Game Engine", stored as a file inside data folder of "Blahblah Game Engine", run as an activity of "Blahblah Game Engine". Is it possible with Unity 5, both technically and legally? If I were to start this "Blahblah Game Engine" project, should I choose Unity 5 personal or pro licence?
0
Can I Create A Windows Package to Submit to the Window Store using the Mac Version of Unity 5.3? Note New to App Development. I'm using a Mac for building my three 3D puzzle apps with Unity 5.3.2. I want to create Windows versions to sell in the Windows Store. I attempted to transfer the package for one of our apps to the Windows version of Unity but it was a pure hot mess. A lot of the alignment of text and images was skewed really bad. We have not used Windows in approx. 10 years so for all practical purposes we are brand new Windows users. The last OS we used was XP. The laptop we just purchased runs Windows 10 Home. I can create a Windows executable (.exe) file from the Mac version of Unity that executes my 3D puzzle app perfectly just like the Mac version. However I found out that I had to submit a special package to the Windows Store. The instructions that I found so far for this assumes that you are using the Windows version of Unity. I do not plan to be a full time app developer so the idea of trying to learn Visual Studio for me is a waste of my time. I would prefer creating the Windows package for the Windows Store using the Mac version of Unity. Is this possible? I could not find instructions in the manual or from search on what options need to be set to do this. I'm thinking it can be done since I was able to create a Windows exe file using my Mac version of Unity. I would like to create Windows Store packages for both 8.1 and 10.
0
How can I prioritize the call order of decoupled scripts? I have a player with many individual components that each handle a behavior such as jump, block, attack, duck, etc.. None of the scripts know about one another. Each listens for a specific input to fire. Some behaviors share the same input depending on the characters state such as ok the ground, in the air. I'm running into issue where the wrong behavior will fire that has shared input (down attack instead of down attack being held down for x seconds). I'm looking for advice on how to manage these behaviors and have more control over what can happen when. I've tried resolving this issue by creating a method that will disable other behaviors temporarily while completing the action and I've changed the script execution order. I thought about adding a discrete player state and restricting what behaviors are able to be performed at any given time but this increases the complexity quiet a bit.
0
Missing Reference exception when accessing a GameObject in Unity I have been making a C script that attacks the player in Unity. However, with the following code I got the following error message "The object of type 'GameObject' has been destroyed but you are still trying to access it. Here is my code using System.Collections using System.Collections.Generic using UnityEngine public class attackPlayer MonoBehaviour GameObject Enemy GameObject Player void Start () Enemy GameObject.FindWithTag ("Enemy") Player GameObject.FindWithTag ("Player") void Update () var heading Enemy.transform.position.x Player.transform.position.x if (heading gt 0.0f amp amp heading lt 5.0f) Explode () void Explode() var exp GetComponent lt ParticleSystem gt () exp.Play () Destroy (gameObject,exp.main.duration) Destroy(Player) void OnCollisionEnter2D (Collision2D col) if (col.gameObject.tag "Player") Explode ()
0
IgnoreCollision while Dodging Colliding I'm working on a mechanic to allow the player to dodge through enemies. However I'm running into the issue where the player is only able to dodge through enemies while their already dodging when they collide with the enemy. I want this to work both ways, as in, when their colliding with the enemy, they should be able to dodge through then. Here's what I've been trying void OnCollisionEnter (Collision col) STOP ENEMY FROM MOVING PUSHING if (col.gameObject.tag "Enemy") Debug.Log("Collided with " col.gameObject.name) target col.gameObject target.GetComponent lt ZombieController gt ().mRigidbody.isKinematic true IGNORE DODGING COLLISION WHEN ALREADY COLLIDED if (isDodging) Physics.IgnoreCollision(col.collider, GetComponent lt Collider gt (), true) IGNORE DODGING COLLISION if (isDodging amp amp col.gameObject.tag "Enemy") Physics.IgnoreCollision(col.collider, GetComponent lt Collider gt (), true) It just doesn't seem to work when the player has already collided with the enemy. Hopefully all that made sense.
0
smooth look at only on x and y i'm using the script down below to make my camera look at mouse x and y position, and it has a limitation for my camera rotation.the problem is the way my camera rotates is not smooth at all.is there any way to make it smoothly look at position on x and y? rotationX Input.GetAxis("Mouse X") sensitivityX rotationX Mathf.Clamp(rotationX, minimumX, maximumX) rotationY Input.GetAxis("Mouse Y") sensitivityY rotationY Mathf.Clamp(rotationY, minimumY, maximumY) transform.localEulerAngles new Vector3( rotationY , rotationX, 0)
0
Generating a sprite using a list of points I am trying to dynamically generate a sprite in Unity to visualize a list of points. What I've got so far is creating a small Texture2D object and then trying to override the geometry static SpriteRenderer SpriteRendererFromPoints(SpriteRenderer spriteRenderer, List lt Vector2 gt points) var texture Texture2D.whiteTexture spriteRenderer.sprite Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f)) Sprite sprite spriteRenderer.sprite sprite.OverrideGeometry(points.ToArray lt Vector2 gt (), sprite.triangles) return spriteRenderer I am adding this SpriteRenderer and a PolygonCollider2D to my gameobject and the instantiate it like this GameObject meshObject new GameObject() PolygonCollider2D polygonCollider meshObject.AddComponent lt PolygonCollider2D gt () PolygonCollider2DFromPoints(polygonCollider, points) SpriteRenderer spriteRenderer meshObject.AddComponent lt SpriteRenderer gt () SpriteRendererFromPoints(spriteRenderer, (from point in points select new Vector2(point.x, point.y)).ToList lt Vector2 gt ()) Instantiate(meshObject) It all runs fine but when running this, the sprite is nowhere to be seen Any help as to what I'm missing here or alternative ways of accomplishing this would be much appreciated.
0
How to parent object to empty when looked at I am making a fps in unity. I have an empty parented to the camera for the gun, and I want to be able to pick up and drop guns found in the scene. Does anyone have a simple c script that would allow the player to look at the gun on the ground, press a key and have it be parented to the empty? I would also like for the player's old gun to drop on the floor where the one being picked up was and un parent from the empty when the new gun is picked up. If you want an example I guess you could say it is like halo where you can go around and pick up new guns. I am not looking to make an inventory, just a simple script where you can swap your weapon.
0
Why does unlocking cursor with keyup behave the same as unlocking it with keydown? To understand the difference, let me review a bit about the behavior of GetKeyUp and GetKeyDown with the following code snippet. void Update() if (Input.GetKeyDown(KeyCode.Escape)) Debug.Log("Escape Key Down") if (Input.GetKeyUp(KeyCode.Escape)) Debug.Log("Escape Key Up") Right after pressing the Esc key (and holding it), a message "Escape Key Down" is produced. Later right after releasing the key, a message "Escape Key Up" will show. The behavior does make sense. Now I apply this for toggling (locking unlocking) the mouse cursor. Here is my code snippet. void Update() if (Input.GetMouseButtonDown(0)) Cursor.lockState CursorLockMode.Locked Cursor.visible false if (Input.GetKeyUp(KeyCode.Escape)) Cursor.lockState CursorLockMode.None Cursor.visible true Right after clicking the left mouse button, the cursor becomes invisible. However, right after pressing down the Esc key, the cursor becomes visible again. The expected behavior is that the cursor will be visible right after releasing the Esc key rather than right after pressing the key. Question How to fix this abnormal behavior?
0
MissingComponentException There is no 'TextMesh' attached to the "Can" game object, but a script is trying to access it When I run my program I keep getting MissingComponentException There is no 'TextMesh' attached to the "Can" game object, but a script is trying to access it.Even though I have attached it as you can see In the script I am trying to edit the text of the Text Mesh like this private int count public TextMesh countText Use this for initialization void Start () count 0 counterText gameObject.GetComponent lt TextMesh gt () counterText.text "Count " count.ToString() What I want is to count the cans that have been shot, so what I do next is void OnCollisionEnter(Collider other) if (other.gameObject.CompareTag("Can")) other.gameObject.SetActive(false) count count 1 counterText.text "Count " count.ToString()
0
Some meshes are visible in game view while others are not I have a FPS character in unity. The FPS character is divided into a few different pieces (upper arm, lower arm, hand, fingers, etc). I exported it from blender, so I'm using the camera that got converted from the blender camera. For some reason, the mesh is not showing up in the game view camera vision. I did a little bit of testing and found out that If I move the camera away, the mesh shows up, so the mesh isn't invisible or anything I put a version of the character that I imported from blender earlier as a test(different rest pose and less animations attached to it) in the same location as the FPS character, and attached the same animator to it. When I did that, you can see the earlier version but not the newest one The same thing happens even if I change the camera The camera has a field of view of about 67, and a focal length of 18. Near is set to the lowest value possible. Both characters are visible in scene view, just not in game view.
0
Enemy doesn't fire at player My script looks pretty good but it says Target variable has not been assigned value. public GameObject AntagonisticElement public GameObject Target public float bulletSpeed public float enemySpeed public float bulletDestroyTime public GameObject explsn public GameObject bulletPrefab public Transform bulletSpawn Vector3 pos public float min 20 public float max 10 public int MaxCounter public int CounterStatus int numberofEnemy Use this for initialization void Start() Update is called once per frame void Update() if (CounterStatus lt 0) if (numberofEnemy lt 3) Vector3 creationPoint transform.position creationPoint.y 0.5f Instantiate(AntagonisticElement, creationPoint, transform.rotation) CounterStatus MaxCounter numberofEnemy else CounterStatus transform.LookAt(Target.transform.position) if (Vector3.Distance(transform.position, Target.transform.position) gt min) transform.position transform.forward 4 Time.deltaTime if (Vector3.Distance(transform.position, Target.transform.position) lt max) shootAt() void shootAt() Instantiate(explsn, bulletSpawn.position, bulletSpawn.transform.rotation) var bullet Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation) bullet.GetComponent lt Rigidbody gt ().velocity bullet.transform.forward bulletSpeed
0
Anchored Unity text ...not anchoring! I've added some text to a unity UI and set both the achor and pivot to the top right corner as shown here When I start this in debug in unity the text looks fine What's weird is that when I build the app and run it as an executable as a host (this is a multiplayer networked game) the text also looks fine. But when I start a client instance the text doesn't appear. I debugged and paused the game in unity in client mode and noticed that the text object is miles away from where I'm expecting it to be (and as a result doesn't show on the camera). You can just about see the black line on the below image which is my level and the text anchored miles up and right of the level. It seems like I've done something stupid here but I can't work out what s EDIT Leo's answer was correct conceptually, but here's how I implemented the suggestion. Created an empty game object GameStateManager in the hierarchy Add a GameState script to the manager with a network identity Added my 'RemainingTime' property to the game state script and put the SyncVar attribute on it Put logic in the game state Update method to update the remaining time Added a ClientTimer script to the text object (mono behaviour), which retrieved the GameState from within the clients copy of the game state manager. In the update method of the client time, get a reference to the Text object and set the .text property to the value of the remaining time. I'm not sure if this is correct, but it does seem to work, and now the ClientTimer script isn't networked, which resolved the issues with placement of the text.
0
Bad Viewports Using Unity with Google Cardboard VR on iOS I'm using unity 2017.3.1f1, building for an iPhone SE. I'm able to build the google HelloVR scene, available from the Google Cardboard VR unity package. However, in the end result, the cameras are giving the wrong display. They aren't lined up to create stereoscopic vision at all, and the image appears distorted. Here is an example of the output https i.imgur.com Y4pqdiy.jpg Is there a default setting in the Google Cardboard VR package that can be changed to fix this?
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
How to add only 1 value in a list in the Update function when a GameObject is active for many frames In my C script, I get the active gameobjects during play mode. Those gameObjects that are active are 1 First, I get the ones that the application has selected randomly 2 and then after the first ones get disabled (setActive(false)), I get the selected gameObjects which are those that the user has pressed using their button. So basically the application is The user hears a sound being played (here I set active the gameObject that has that sound) and then after some frames, the sound gets disabled and then the user needs to press a button in screen to make a choice depending on the sound (here I set active the gameObject that has the button) and then I disable that game object after some frames. Now every time one of those gameObjects gets selected, I try to add to my list some sort of value (lets say 1 in this case). But what happens is that I only manage to add the value in the Update() function but in this function I do not get only 1 value added in the list every time I get the first gameObject selected but because it updates every frame, this value gets added for like 125 times in the list until this gameObject gets diselected and the next gameObject (the one that holds the button) get active. if (DogSelected.activeSelf amp amp NoCarSelected.activeSelf) enable true if (enable) DogLionSelected.Add(0) NoCarCarSelected.Add(0) enable false if (DogPressed.activeSelf amp amp NoCarPressed.activeSelf ) enable true if (enable) string data new string scene.name.ToString(), "0", "0", "0", "0", "1" orientationStringWriter.Write(string.Join(delimiter, data) " n") DogLionPressed.Add(0) NoCarCarPressed.Add(0) PrimaryCorrectIncorrect.Add(1) enable false Ideally, I would want to 1 Hear the sound (gameObject is active) add only 1 value in list until the gameObject is deselected. 2 Then do the same thing for the gameObjects that hold the button. So when that gets selected add only one value in the other list until this gameObject is deselected. Then do the same process 72 times (because the number of trials in this application is 72). Can anyone give me any advice how to achieve this? Thanks
0
Add singleton to an existing gameobject in Unity via script I did notice that if I assign scripts that generate singleton classes (for my managers), to an empty game object, everything works fine. Now I would like to start the scene with the empty game object, attach the main game manager singleton, and in the game manager singleton I would like to attach to it the other manager singleton classes. Although I am not sure how you actually do so. Do you run addComponent to the main game manager, and they will be attached to the existing gameobject? The gameobject that I use for the main gamemanager is set to not be destroyed on load the doubt is if I should run addComponent on the scripts, or create a reference from the gamemanager script and instantiate it from there. I did look for examples on the subject, but the only thing that I found is the reference to add a script to a game object and I am not sure if that's actually what is supposed to be done.
0
Create a normal map using a script? Unity I don't have a software that can create normal maps from an image so I usually make a grayscale image and then let unity make the normal map from that image. But I can't save the image to use for later, Instead I have to convert it to a normal map every time I use it. So how would I make a normal map from a greyscale using a script? i prefer c but js works fine.
0
Angle between start and current rotation I'm facing problem of the operations on rotations. I have a wheel with a start rotation of (0, 0, 0). The player has to rotate wheel 270 degrees in Y axis either left or right. During the rotation slider should indicate progress of the rotation. For example if player rotated 135 degrees in right direction, slider is 50 filled to the right. The thing is that I'm not sure how to get the value of which the player rotate the object. For example when I start rotating right my angle changes from (0, 0, 0) to (0, 359, 0). How can I resolve this issue so it knows that change from (0, 0, 0) to (0, 359, 0) means player rotated only 1 degree?
0
Why is perlin noise generating flat terrain in Unity? I am trying to generate terrain using perlin noise however the terrain being generated is a plateau. Here is the code that I'm using var xlength 65.0 var ylength 65.0 var scale 4.1f var heights new float xlength, ylength function Start () for (var i 0 i lt xlength i ) for (var j 0 j lt ylength j ) heights i,j Mathf.PerlinNoise(Time.time i xlength scale 1000,Time.time j ylength scale 1000) i j gameObject.GetComponent(Terrain).terrainData.SetHeights(0,0,heights) What am I doing wrong here?
0
How to do pixel per pixel modeling in unity3d? So generally I want to have api like pixels.addPixel3D(new Pixel3D(0xFF0000, 100, 100,100)) (color, position) where pixels is some abstraction on 3d sceen objet.So to say point cloud. It would have grate use in deep space stars modeling... I want to set each pixel by hand (having no image base or any automatic thing)... So point is modeling something like Or look at alive flash analog here How to do such thing in unity?
0
Effect culling on uneven terrain I'm trying to integrate a "ground particle" effect (like a fire circle or similar) in Unity3d, however since i'm using uneven terrain as my terrain mesh, the effect gets culled behind terrain parts that above it. To better ilustrate it I created an image as attachment I want for the effect to always be displayed regardless of it's "depth". How can this undesired effect be avoided resolved properly ?
0
How to reset the score to 0 when reloading the game? My scoring system uses DontDestroyOnLoad to persist between scenes public class ScoringSystem MonoBehaviour private int score 0 public void Correct(int number) If correct add score score score number void Start () score 0 void Awake() DontDestroyOnLoad(transform.gameObject) public int GetScore() return score Here is another script that I should include a description about public void iniTag() jawab true Time.timeScale 0 GameObject objek1 GameObject.FindGameObjectWithTag("Benar1") GameObject objek2 GameObject.FindGameObjectWithTag("Benar2") GameObject objek3 GameObject.FindGameObjectWithTag("Benar3") GameObject objek4 GameObject.FindGameObjectWithTag("Benar4") if (objek1.transform.parent.tag "Jawab4" amp amp objek2.transform.parent.tag "Jawab3" amp amp objek3.transform.parent.tag "Jawab2" amp amp objek4.transform.parent.tag "Jawab1") PanelBenar.SetActive(true) buttonNext.SetActive(true) GameObject.Find("QuizManager").SendMessage("Correct", playerScore) void Start () if (GameObject.Find ("QuizManager") ! null) ScoringSystem scoringSystem GameObject.Find ("QuizManager").GetComponent lt ScoringSystem gt () gameObject.GetComponent lt Text gt ().text scoringSystem.GetScore().ToString () else Debug.Log("No Scoring system found. To test scoring system start from the front page scene")
0
Can't get the current animation state name (hash or .IsName) to work I have some hard times trying to get the current animation state name in Unity, to perform specific actions while I'm in a certain state. I want to know when I'm the "ThoughtsStill" state, I only have the default layer (Base Layer) To do this, here is what I tried AnimatorStateInfo curr state animator.GetCurrentAnimatorStateInfo(0) if (curr state.shortNameHash Animator.StringToHash("ThoughtsStill")) Debug.Log("I'm in ThoughtsStill state"). which is not working. I also tried with IsName() method but it is not working too (both tried to compare "Base Layer.ThoughtsStill" and "ThoughtsStill"). I'm certain that I'm going in this ThoughtsStill state but I don't know why I can't get it. Do you guys have any ideas or leads? Thanks !
0
Move circle inside semi circle based on external object I have a circle that I'd like to move around in semicircle with it's location following an external object. I can get the direction the circle should be facing with something like this Vector3 targetDir X.transform.position circle.transform.position How can I stick the movement of the circle inside a semicircle?
0
How to add or increase speed on every 500m distance of player? I'm a a beginner, creating an endless runner game. I want to increase speed as the player completed the distance and on every 500 meter speed should be increased. Anyone have an idea of how to implement this kind of logic? speed 10 as soon as player reach 500 m distance speed should be incremented it should be continuous process on every 500m My code public class Score MonoBehaviour SerializeField GameObject ground SerializeField AudioClip clip SerializeField Transform player SerializeField public Text LiveScore SerializeField public GameObject gameOver SerializeField public bool runningScore true public Text finalScore public Text Highscore, bestScore float distance ball Ball Start is called before the first frame update private void Start() Ball GetComponent lt ball gt () PlayerPrefs.DeleteKey("HighScore") Highscore.text "Best " ((int)PlayerPrefs.GetFloat("HighScore", 0)).ToString() bestScore.text "Best " ((int)PlayerPrefs.GetFloat("HighScore", 0)).ToString() Update is called once per frame void Update() distance player.position.z 500 if (runningScore) LiveScore.text distance.ToString("0") Highscore.text LiveScore.text if (runningScore false) float score float.Parse(LiveScore.text) finalScore.text "Score " LiveScore.text if (PlayerPrefs.GetFloat("HighScore", 0) lt score) PlayerPrefs.SetFloat("HighScore", score) Highscore.text "Best " score.ToString() bestScore.text Highscore.text AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position) else if (score lt PlayerPrefs.GetFloat("HighScore", 0)) bestScore.text Highscore.text while (distance gt 500) Ball.speed 5
0
How to implement Microwave Signals in Unity? I need to implement microwave signals for object detection in Unity. I know there are raycast sensors in Unity, but can microwave signals be simulated or can a proxy of microwave signals be created in Unity using the raycast sensors?
0
Calling functions that needs to be on update() So I have a function DialogueRun() for a Dialogue System that changes the line on the dialogue box whenever you click. Which means it has to be in Update(). My test works so far but my next problem is how to make the whole dialogue box only appear whenever I click on a character. I tried making the characters as buttons and it does make the dialogue box show up whenever clicked, but it won't change the dialogue lines because that function has to be in an update method. I'm looking at OnMouseDown() right now but the result will be probably the same. Any ideas? public void DialogueRun() dialogueBox.SetActive(true) dialogue.text textLine nextLine if (nextLine lt textLine.Length 1) if (Input.GetKeyDown(KeyCode.Mouse0)) nextLine 1 else counter dialogueBox.SetActive(false) return
0
Using unity Rigidbody 2D gravity, how to add to velocity? I am creating a top down game, and have an object I want to create a small bouncy illusion for. Since I dont have anything to collide with I'll have to do it with Scripts. Without Unity I would probably do something like function fall () this.vertical speed this.vertical speed GRAVITY if (this.vertical speed gt TERMINAL VELOCITY) this.vertical speed TERMINAL VELOCITY this.vertical position this.vertical position this.vertical speed However in Unity we have the Rigidbody 2D, so I want to somehow use that for this. if I set rigidBody.velocity new Vector2(1, 0) speed delta , it gets a constant speed, and ignores gravity. How can I add gravity? i.e I want to create a curve like
0
How to make an illusion where the contents of a 3D shape change based on which face you look through? I remember coming across a Unity 3D tutorial where there was a technique where the contents of a 3D shape change based on which face you are looking at, similar to this screenshot from Antichamber What is this techique called? And how do I implement it into a Unity 3D project? Thanks in advance.