Converging at position and angle using motor based rigidbody movement I am given a rigidbody positioned in mathbb R 2 . It is a box of length l and height epsilon . The position of the box's left center is described by vec p , and its angle from the x axis is theta . The body is in a vacuum (no friction), and its mass is m (uniformly distributed). Here's a quick diagram. Next, I am given a target position and angle to reach. It is not guaranteed that the body will reach the target position and angle the next time frame. I need to calculate the necessary force F and torque T that will push the body closest to the target. I am given constraints for max force and max torque. To make things complicated, the body might be affected by external forces. One of them is gravity F g , which will always remain constant. Sometimes, normal forces exist as well. The applied forces or the total force is unknown, but the velocity or the angular velocity is available. I tried to solve this problem using steering behaviors. However, the angle seems to fluctuate constantly. Here's part of my code in C (Unity). vec p 0 transform.position theta 0 transform.eulerAngles.z vec p t position theta t angle private RigidBody body public float SlowDownRadius 2f public float MaxVelocity 50f public float MaxForce 10000f public float SlowDownDelta 15f public float MaxAngVelocity 180f public float MaxTorque 10000f public void Next(Vector3 position, float angle) angle in degrees force Vector2 to position var from (Vector2) transform.position var desired to from var dist desired.sqrMagnitude desired desired.SetMagnitude(dist lt SlowDownRadius SlowDownRadius ? MaxVelocity Mathf.Sqrt(dist) SlowDownRadius MaxVelocity) Vector2 vel body.velocity var steering desired vel var mass body.mass Vector2 force mass UnityEngine.Physics.gravity var time Time.deltaTime var newForce (time lt 0 ? new Vector2() (mass time steering)) force body.AddForce(newForce.Clamp(MaxForce)) limits magnitude of newForce to MaxForce torque var toAngle angle var fromAngle transform.eulerAngles.z var desiredAngle AngleDistance(fromAngle, toAngle) var distAngle Mathf.Abs(desiredAngle) if (distAngle lt 1f) transform.eulerAngles new Vector3(0, 0, angle) return desiredAngle Mathf.Sign(desiredAngle) (distAngle lt SlowDownDelta ? MaxAngVelocity distAngle SlowDownDelta MaxAngVelocity) Mathf.Deg2Rad var angVel body.angularVelocity.z in radians var steeringAngle desiredAngle angVel var newTorque (time lt 0 ? 0f (mass time steeringAngle)) body.AddTorque(0, 0, Mathf.Sign(newTorque) Mathf.Min(Mathf.Abs(newTorque), MaxTorque)) public static float AngleDistance(float from, float to) var dist (to from 180f) 360f 180f return dist lt 180f ? dist 360 dist If I made any errors, please let me know. Thank you in advance!


How can I update data saved using PlayerPrefs when there is a new version of my Unity3D game? I'm using PlayerPrefs to store the players' highscore on each level, but in the next version I'll change how scoring works. For example, In the old version players could easily reach 250 points on a specific level, while in the new version it's difficult to reach even 50. I would like to delete PlayerPrefs data which were saved during earlier versions, because scores that high would cause some issues in the newer version. What is the best way to safely maintain compatibility of saved data between versions, but also be able to reset them if a new update requires it? My current solution is that from now on I use new keys to store the data, for example by adding the current version to it. For example, in version 2.0 the data that was originally saved with the key quot score Level8 quot would now be saved with quot score Level8 2.0 quot . This way the player's progression gets quot reset quot after an update, but the old saves remain until another game changer update comes, and I have to increase the version part of the key from 2.0 to 3.0. This feels a bit error prone and unprofessional.


Render 2D textures on a 3D object's face I am not familiar with 3D graphics, and I'd like to know the right way to render some 2D figures on different points of a wider face of a 3D object. My 3D object is just a cube representing a poker table. I have a 2D png for players' placeholders, and I'd like to render these figures on the 3D object where needed. An alternative solution would be to render the whole face with a big picture containing all the placeholders figures. However, it would be a waste of memory and thus less efficient. What do you suggest?


Maintaining facing direction at the end of a movement I want to make my 2D top down walking animation stop and revert to the idle animation while continuing to face in the same direction as the previous movement. For example, when I go up then stop, my character should continue to look up. If I go down, it should continue to look down. I use lastmoveX and lastmoveY floats for idle and for walking I use moveX and moveY floats. moveX and moveY change when I move with the joystick, but lastmoveX and lastmoveY do not change, and I don't know how to fix this. Here is my code using System.Collections using System.Collections.Generic using UnityEngine public class PlayerController MonoBehaviour private Rigidbody2D myRB private Animator myAnim public Joystick joystick public MoveByTouch controller SerializeField private float speed Use this for initialization void Start () myRB GetComponent lt Rigidbody2D gt () myAnim GetComponent lt Animator gt () Update is called once per frame void Update () myRB.velocity new Vector2(joystick.Horizontal, joystick.Vertical) speed Time.deltaTime myAnim.SetFloat( quot moveX quot , myRB.velocity.x) myAnim.SetFloat( quot moveY quot , myRB.velocity.y) if(joystick.Horizontal 1 joystick.Horizontal 1 joystick.Vertical 1 joystick.Vertical 1) myAnim.SetFloat( quot lastMoveX quot , joystick.Horizontal) myAnim.SetFloat( quot lastMoveY quot , joystick.Vertical)


How do I customise automatically generated script? When you create a script via the Unity editor, it generates a script with some pre formatted code. using System.Collections using System.Collections.Generic using UnityEngine public class GenericClass MonoBehaviour Use this for initialization void Start () Update is called once per frame void Update () When I create a script, I am generally guaranteed to use additional code, such as a namespace or a custom editor. Furthermore, I almost always delete content from the automatically generated script. Is there a way to change the automatic code generated by Unity?


Making an object hang This image is pretty self explanatory I hope How can I achieve this effect without animating it? I want to avoid animations as there are many objects hanging and I dont want them to move the exact same way.


Stop animation from playing while waiting to destroy object I'm working on functionality in Unity where if a game object's health is zero, it does and the object is destroyed. This works fine as is, I reduce the health to zero, the die animation plays and the game object is destroyed. I want to have the script wait a certain amount of time and then run the destroy method. I thought using WaitForSeconds() would do the trick, and technically, it does, but the death animation continues to play until the object is destroyed. My question is, how do I get the animation to stop playing as the script waits to destroy the object? C void Die() GetComponent lt Animation gt ().CrossFade(die.name) If the current animation time is greater than 90 of the entire animation length, destroy the object. if(GetComponent lt Animation gt () die.name .time gt GetComponent lt Animation gt () die.name .length 0.9) StartCoroutine(RemoveBody()) IEnumerator RemoveBody() yield return new WaitForSeconds(5) Destroy(gameObject)


Creating charging particles using Shuriken I've been trying to create a charging effect using the Shuriken Particle system for the longest time, and I've had little to no luck with it. I've tried setting different curves for the Force over Time and Color over Time, but I always come up empty. However, I've seen examples all over the place for charging particles. The most recent example of charging particles I've seen is from the Space Cowboy game jam entry LOS CUERVOS. The game has a ship with a laser that requires the player to hold a button down before it fires. It looks like this when charging and firing. I'm specifically talking about the particles surrounding the ball of light that's slowly growing in size over time. I was wondering if anyone here knew what I may be doing wrong when going about setting up the particle system. Any suggestions relative to the question would be much appreciative.


What is wrong with this character slope math? I'm making a sidescrolling platformer and have implemented some code that should convert the characters speed to an X speed and Y speed based on the angle of the surface they are on. This actual math for this was taken from a web page and I don't know if it's right or not. xSpeed and ySpeed are derived from speed, based on the angle xSpeed speed Mathf.Cos(angle) ySpeed (speed Mathf.Sin (angle)) gravity The angle is found with this code RaycastHit ground Physics.Raycast (transform.position, Vector3.down, out ground, 1.5f) Debug.DrawRay (transform.position, Vector3.down.normalized, Color.green, 2, false) if (ground.collider ! null) angle Vector3.Angle (ground.normal, Vector3.up) else angle 0 This works fine when walking on a flat surface, but freaks out when walking on a slope. I believe the problem lies with the angle itself.


FBX model for 2d sprite charachter I was following along the unity platformer tutorial. https www.youtube.com watch?v 9WhZ1svdC3Q It is great. After looking the animation I found that there was a fbx model for 2d sprite character. I just want to ask can you use 3d animation like motion capture animation once you rig a character using bone for 2d(fbx model). I search but unable to find any good tutorial of how to create fbx model for 2d character and creating maps for these 2d character. I am really confused. Thank you so much for helping.


Unity Static Camera Perspective, Walls Obscure Player Pretty simple and common problem here. The world I'm designing is fully explorable, no invisible walls or tricks. It's presented as a single seamless area, a School complex with 9 buildings, some of which have 2 or 3 floors and contain many rooms. The perspective I've chosen is simple, inspired by topdown RPGs A problem arises with walls. They obscure the player. I've tried some shaders which draw a silhouette of the player ontop but I don't like this approach, other objects and decoration remains obscured behind the wall. Some kind of dissolve effect allowing you to see through the walls would be preferable, but writing my own shaders is not my fort ... Another problem is with large buildings outside. The camera is at a fixed distance, about 14 metre's away. If the player walks behind a large building (over 10 metres tall) then the camera cuts off the top of it as it is now within the building. The only way I can think of fixing this is to adjust the distance between player and camera, but some of the buildings are so tall the zoom out looks very unusual and impractical. I suppose this is why you don't see this simplistic camera setup in large explorable games... While I've been developing games for some years now, I've only come to 3D and Unity fairly recently, so there might be a jaw droppingly simple solution which I'm not seeing. Anyway, I'd like to hear some interesting or novel approaches towards fixing these problems, besides the simple ones I've suggested. I hope that's not asking too much.


Creating orientation Quaternion from forward vector Suppose that I have an orientation Quaternion Q, I can compute its forward vector from V Q Vector3.forward easily. Inversely, suppose that I have its forward vector V, how do I compute Q? I know that is not possible, please tell me what's needed beside V, in order to compute Q. Motivation behind the problem I have a forward direction of a game object, I want to find out its up direction and its right direction. I can find out all these 3 directions if I have the orientation Quaternion.


How to animate fluid filling down a pipe of any shape? I am working on a project where I want to model a simple flow of fluids around a circuit of pipe. I thought a simple way to do this would be to create an irregular shaped loading bar, then animating the shape as it filled up. I have found answers for how to create regular loading bars that are rectangle shaped, as well as some for circular loading bars. But what if want some arbitrary "circuit" of pipes, kind of like one long windey loading bar.


Generate random number in Unity without class ambiguity I have a problem in Unity (C ) where I would like to create a random number. I wanted to use System.Random (reference using System) but Unity complains that it's ambiguous to their own UnityEngine.Random. I can not specify the reference (using System.Random) as random is not a namespace. How do I specify that I want to use the system random and not the Unity one?


How to create a two way teleport system? I'm trying to create a two way teleport system in which players can move into a teleport gameobject, and is then teleported to another linked teleport gameobject. How I was planning to have it work was very simple. On the teleport gameobject's script, it would have a public property to the other teleport's transform in which to teleport the player to. In OnTriggerEnter, I simply set the entering's collider position to that of the linked teleport. void OnTriggerEnter(Collider other) other.transform.position DestinationPoint.position However, when the player's position is changed, it triggers the OnTriggerEnter of the destination teleport, and thus the player gets stuck bouncing back and forth between the two points. What's a good way to prevent this? Some less than ideal solutions I came up with is to offset the position that player teleports too slightly so that he doesn't cause OnTriggerEnter to be called at the destination portal, but I'd like to avoid that.


Show 3d object on device live camera in Unity3d for iOS Possible Duplicate How to add render able Texture in Unity 3d for iOS How render a 3d or 2d(.jpg or .png )object at device live camera in Unity3d, and this 3d object shouldn't stuck with camera. It has to show at specific point, like we can set any object in game scene at particular location.


Unity get component throwing NullReferenceException only in standalone build I'm having a very frustrating issue with GetComponent(). private void Show() var transition GetComponent lt TransitionAnimation gt () Debug.Log( "Transition transition ") transition?.FadeIn() In the editor, this works just fine. transition is not null and FadeIn() is called. In the standalone build, GetComponent() returns null, throws a NullReferenceException, and execution stops before it can even print transition to the console. This is the output from the log file. Uploading Crash Report NullReferenceException at (wrapper managed to native) UnityEngine.Component.get gameObject(UnityEngine.Component) at UnityEngine.Component.GetComponentInChildren (System.Type t, System.Boolean includeInactive) 0x00001 in lt e314adc5a7494b5f8760be75461a94d4 gt 0 at UnityEngine.Component.GetComponentInChildren T (System.Boolean includeInactive) 0x00001 in lt e314adc5a7494b5f8760be75461a94d4 gt 0 at Winglett.RR.UI.Gradient.Show () 0x00001 in Users redacted Documents repos radical relocation Assets Core Scripts UI Gradient.cs 63 at (wrapper delegate invoke) lt Module gt .invoke void() at Winglett.RR.Gameplay.GameState.SetPause () 0x00001 in Users redacted Documents repos radical relocation Assets Core Scripts Gameplay GameState.cs 46 at Winglett.RR.Gameplay.GameState.SetPause STATIC () 0x00000 in Users redacted Documents repos radical relocation Assets Core Scripts Gameplay GameState.cs 70 at Winglett.RR.UI.Wrapper.SetGameStatePause () 0x00000 in Users redacted Documents repos radical relocation Assets Core Playground ui Wrapper.cs 27 at UnityEngine.Events.InvokableCall.Invoke () 0x00011 in lt e314adc5a7494b5f8760be75461a94d4 gt 0 at UnityEngine.Events.UnityEvent.Invoke () 0x00023 in lt e314adc5a7494b5f8760be75461a94d4 gt 0 at Winglett.RR.Utils.ESCButton.Update () 0x00026 in Users redacted Documents repos radical relocation Assets Core Scripts Utilities Other ESCButton.cs 21 I wondered if the issue might be because the gameobject is disabled. So I tried GetComponentInChildren lt TransitionAnimation gt (true) where true is an overload for inactive gameobjects. This didn't change anything.


How can I move an object over linerenderer lines positions? I have 4 cubes the first 3 cubes connected with two lines one of the lines is curved. The fourth cube I want to move over the lines. The lines is built using linerenderer and in the linerenderer there are 397 positions. I created a small script that move an object over the positions. I checked and I have in the array 397 positions and the loop get to 397 but the object (Cube (3)) never moving all the positions only some. Or maybe the positions I get are not the same in the linerenderer ? This screenshot show some of the positions in the linerenderer this is the positions I want the object to move on Why the object is not moving over all the positions , only on some ? And this is the script I created that should move it using System.Collections using System.Collections.Generic using UnityEngine public class MoveOnCurvedLine MonoBehaviour public LineRenderer lineRenderer public GameObject objectToMove public float speed private Vector3 positions new Vector3 397 private Vector3 pos private int index 0 Start is called before the first frame update void Start() pos GetLinePointsInWorldSpace() Vector3 GetLinePointsInWorldSpace() Get the positions which are shown in the inspector var numberOfPositions lineRenderer.GetPositions(positions) Iterate through all points, and transform them to world space for (var i 0 i lt numberOfPositions i 1) positions i transform.TransformPoint(positions i ) the points returned are in world space return positions Update is called once per frame void Update() if(index lt pos.Length 1) objectToMove.transform.position pos index Time.deltaTime speed index Now I checked using a breakpoint the first position in the linerender at index 0 is X 30.57, Y 6.467235, Z 4.98 But in my script in the pos array I see that in index 0 the position is X 30.6, Y 6.5, Z 5.0 And the result is that the object that move Cube(3) is moving only some of the way and also it's not exactly on the line Why the object is not moving over all the positions , only on some ? Something is wrong in my script with getting the right positions from the linerenderer and maybe also the loop and the move is wrong. I can't figure out ho to do it.


How to figure out if I'm on the right path I'm a software developer from Israel, I've been programming professionally since 2011, my first job was in HP software and lasted 2 years after which I decided that I want to pursue my dream in working in game development and focusing on C . for a year an a half I worked for a mobile kids games company, doing small mobile games for kids using C and Cocos2d x. Unfortunately I was laid off last December and since then I've been focusing my free time on studying Unreal engine 4, studying openGL and computer graphics and working on my C skills while searching for a new job. I'm very passionate about computer amp console games and especially the rendering part and my dream job would be to work on AAA games and to be a graphics programming specialist. The problem is that there aren't any AAA game companies in Israel so I started looking at positions in Europe and also in other jobs that involves computer graphics but aren't necessarily in games. Last week I got a job offer for a small start up making a game in the "Clash of Clans" genre, the company seems nice, its not my type of games but I'm sure it presents all kinds of challenge but my biggest concern is the fact that the game is implemented in Unity and Python, which are two technologies I'm not so crazy about. I wonder if I should take the job or keep looking for something that involves more C ,OpenGL,DirectX etc. Do you think that taking a Unity Python job will take me too far from the OpenGL DirectX goal I'm trying to reach? I know that good software developers aren't supposed to limit themselves to a certain programming language but I think its good to become really professional at something specific instead of changing language every 2 years. I guess its being a specialist vs. a generalist question. What do you guys think? should I take this job even though I have some concerns? should I keep searching? maybe doing some freelance work in the meantime? any advice will be appreciated.


Sprite won't change with direction I am making a top down Pacman game. I have two sprites one for facing up and one for facing left. When I press W, the sprite showing is still the one for when Pacman is moving left, but I want to see the up sprite instead. using System.Collections using System.Collections.Generic using UnityEngine public class pacman MonoBehaviour public int speed Vector2 dest public Transform points Start is called before the first frame update void Start() dest transform.position speed 25 Update is called once per frame void FixedUpdate() Vector2 p Vector2.MoveTowards(transform.position, dest, speed) GetComponent lt Rigidbody2D gt ().MovePosition(p) Check for Input if not moving if (Input.GetKey("w")) transform.position Vector3.MoveTowards(transform.position, points 0 .position, speed Time.deltaTime) gameObject.GetComponent lt SpriteRenderer gt ().sprite GameObject.Find("up").GetComponent lt SpriteRenderer gt ().sprite if (Input.GetKey("d")) transform.position Vector3.MoveTowards(transform.position, points 2 .position, speed Time.deltaTime) if (Input.GetKey("s")) transform.position Vector3.MoveTowards(transform.position, points 1 .position, speed Time.deltaTime) if (Input.GetKey("a")) transform.position Vector3.MoveTowards(transform.position, points 3 .position, speed Time.deltaTime) gameObject.GetComponent lt SpriteRenderer gt ().sprite GameObject.Find("left").GetComponent lt SpriteRenderer gt ().sprite


Why does my 2D top down joystick code occasionally stop working? I'm working on a 2D top down game, and am working on the player controls. I have the following code currently controlling a player sprite void Update () float moveHorizontal Input.GetAxis("Horizontal") float moveVertical Input.GetAxis("Vertical") float headingAngle Mathf.Atan2(moveHorizontal, moveVertical) Debug.Log("Heading angle " (headingAngle Mathf.Rad2Deg).ToString() " degrees.") Quaternion newHeading Quaternion.Euler(0f, 0f, headingAngle Mathf.Rad2Deg) if (transform.rotation ! newHeading amp amp (moveHorizontal ! 0f moveVertical ! 0f)) Debug.Log("Turning. Rotation " transform.rotation " New Heading " newHeading) transform.rotation Quaternion.Slerp(transform.rotation, newHeading, turnSpeed Time.deltaTime) else Debug.Log("Heading in the right direction, moving...") transform.position new Vector3(moveHorizontal moveSpeed Time.deltaTime, moveVertical moveSpeed Time.deltaTime, 0) This code sort of works, but occasionally the player will stop moving, even though it's rotated in the direction that the joystick is pointing. When that happens, the transform.rotation quaternion will be something like '(0, 0, 7, 7)', but the newHeading quaternion will be '(0, 0, 7, 7)', like they've flipped around. When that happens, the transform.rotation ! newHeading in the if condition is always true, so the else condition is never reached. If I keep moving the joystick to different locations, eventually the player will start moving again. By the way, I have a sprite attached as a child to a game object, and the sprite is rotated 90 degrees in the z axis, if that makes any difference. Any help would be appreciated!


Parameter 'Blend' doesnt exist I want to animate my character, but i got this error Parameter 'Blend' doesnt exist. if i use 1d Blend Type it works fine no bug nothing. But if i change the Blend type in the animation panel working fine the animation but if i run the game i get this error Parameter 'Blend' doesnt exist and my character is freeze in one position what can cause this problem ? parameters


How to get "this" object collider name when OnTriggerEnter is fired? I have a "car" object with 2 colliders attached, a base and a top collider. Then I have a script attached to my car. I'm using OnTriggerEnter event to detect collisions with an invisible "Checkpoint". The problem is that OnTriggerEnter is called twice, I suppose because it is called either from the base collider and top collider. I want to check my object collider's name. OnTriggerEnter expose me with "other" collider however, how can I test my collider's name?


What's a good way to draw multiple circles? Why does the following code not work? public float ThetaScale 0.0001f private int Size private LineRenderer LineDrawer private float Theta 0f void Start () LineDrawer GetComponent lt LineRenderer gt () LineDrawer.SetWidth(0.1f, 0.1f) LineDrawer.material new Material(Shader.Find("Mobile Particles Additive")) LineDrawer.SetColors(Color.blue, Color.blue) void DrawingCircle(float radius) Theta 0f Size (int)((1f ThetaScale) 1f) LineDrawer.SetVertexCount(Size) for(int i 0 i lt Size i ) Theta (2.0f Mathf.PI ThetaScale) float x radius Mathf.Cos(Theta) float y radius Mathf.Sin(Theta) LineDrawer.SetPosition(i, new Vector3(x, y, 0)) void Update () for(int l 0 l lt 3 l ) DrawingCircle(l) I want to plot a multiple circles like that What's a good way to draw multiple circles?


AudioSource not working. Empty Exception I'm trying to load and play an wav file that exists in my Application.dataPath but when the game gets to the line GoAudioSource.PlayOneShot(audioLoader.audioClip) It justs throws a empty exception and no sound is played. I've already checked if the path is correct and it is. I've also tried uploading this wav file to an FTP and loading it via HTTP instead of File but nothing changes. This is my full code private IEnumerator WriteResponseAudio(ResponseModel res) File.WriteAllBytes(Path.Combine(Application.dataPath, FILENAME RESPONSE), Convert.FromBase64String(res.intent.audio.content)) string path "file " Application.dataPath " " FILENAME RESPONSE WWW audioLoader new WWW(path) yield return audioLoader try GoAudioSource.PlayOneShot(audioLoader.audioClip) catch (Exception ex) Debug.LogError("Erro " ex.Message) This is the version with HTTP request private IEnumerator WriteResponseAudio(ResponseModel res) File.WriteAllBytes(Path.Combine(Application.dataPath, FILENAME RESPONSE), Convert.FromBase64String(res.intent.audio.content)) string path "http www.raphaelrosa.com response.wav" WWW audioLoader new WWW(path) yield return audioLoader try GoAudioSource.PlayOneShot(audioLoader.audioClip) catch (Exception ex) Debug.LogError("Erro " ex.Message) This is the console


FPS using mouse to move rather than keys Hi I am developing a First person game but would like to use the mouse to move on a click to move as opposed to the keys. I also need to disable Y movement and restrict the x movement to 180. What ever values I enter into the input manager, it seems to be ignoring them as I still have both x and y when I run the game. I dabbled with the standard unity FPS but is seems very jagged on movement and from what I can see being a new user, their doesn't seem to be a way to restrict y movement. Can someone help with this or suggest a good tutorial on this type of movement. Thanks


Unable to list target platforms. Please make sure the android sdk path is correct. (Error) When i am trying to build an apk from unity. Than its show me some error something like this CommandInvokationFailure Unable to list target platforms. Please make sure the android sdk path is correct. E DEWA msgs Kunal android sdk windows 1.6 r1 tools bin avdmanager.bat list target c stderr stdout ERROR JAVA HOME is set to an invalid directory C Program Files Java jdk1.8.0 121 lib tools.jar C Program Files Java jre1.8.0 141 lib rt.jar Please set the JAVA HOME variable in your environment to match the location of your Java installation. exit code 1 UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, Boolean updateCommand, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidSDKTools.ListTargetPlatforms (UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit) UnityEditor.Android.AndroidSDKTools.GetTopAndroidPlatformAvailable (UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit) UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK SDKPlatformDetector.GetVersion (UnityEditor.Android.AndroidSDKTools sdkTools) UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK SDKComponentDetector.Detect (UnityEditor.Android.AndroidSDKTools sdkTools, System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress) UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.SDKComponentDetector detector) UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (Int32 minVersion, UnityEditor.Android.PostProcessor.Tasks.SDKComponentDetector detector) UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEngine.GUIUtility ProcessEvent(Int32, IntPtr) Build completed with a result of 'Failed' UnityEngine.GUIUtility ProcessEvent(Int32, IntPtr) UnityEditor.BuildPlayerWindow BuildMethodException 2 errors at UnityEditor.BuildPlayerWindow DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) 0x0020e in C buildslave unity build Editor Mono BuildPlayerWindowBuildMethods.cs 181 at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) 0x00065 in C buildslave unity build Editor Mono BuildPlayerWindowBuildMethods.cs 88 UnityEngine.GUIUtility ProcessEvent(Int32, IntPtr) Error building Player CommandInvokationFailure Unable to list target platforms. Please make sure the android sdk path is correct. E DEWA msgs Kunal android sdk windows 1.6 r1 tools bin avdmanager.bat list target c stderr stdout ERROR JAVA HOME is set to an invalid directory C Program Files Java jdk1.8.0 121 lib tools.jar C Program Files Java jre1.8.0 141 lib rt.jar Please set the JAVA HOME variable in your environment to match the location of your Java installation. exit code 1


A Pathfinding issues, player node is always off so I am using Sebastian Lague's second video on A pathfinding (https www.youtube.com watch?v nhiFx28e7JY amp list PLFt AvWsXl0cq5Umv3pMC9SPnKjfp9eGW amp index 2), and since he is using a 3d model, and I am using a 2d model, I need to convert some of the values to 2d. It is working fine, but the problem I ran into is that the node that detects the player is always off. Like in here, the cyan node is the node where my player is supposed to be, and the my cursor is where my player actually is. You can see that it is completely off. I am pretty sure this is because some error is produced while I tried to turn 3d into 2d, but I don't know how. Here is my grid script using System.Collections using System.Collections.Generic using UnityEngine public class Grid MonoBehaviour public Transform player public LayerMask unwalkableMask public Vector2 gridWorldSize public float nodeRadius Node , grid float nodeDiameter int gridSizeX, gridSizeY void Start() nodeDiameter nodeRadius 2 gridSizeX Mathf.RoundToInt(gridWorldSize.x nodeDiameter) gridSizeY Mathf.RoundToInt(gridWorldSize.y nodeDiameter) CreateGrid() void CreateGrid() grid new Node gridSizeX,gridSizeY Vector3 worldBottomLeft transform.position Vector3.right gridWorldSize.x 2 Vector3.up gridWorldSize.y 2 for (int x 0 x lt gridSizeX x ) for (int y 0 y lt gridSizeY y ) Vector3 worldPoint worldBottomLeft Vector3.right (x nodeDiameter nodeRadius) Vector3.up (y nodeDiameter nodeRadius) bool walkable !(Physics2D.OverlapCircle(worldPoint,nodeRadius,unwalkableMask)) grid x,y new Node(walkable,worldPoint) public Node NodeFromWorldPoint(Vector3 worldPosition) float percentX (worldPosition.x gridWorldSize.x 2) gridWorldSize.x float percentY (worldPosition.y gridWorldSize.y 2) gridWorldSize.y percentX Mathf.Clamp01(percentX) percentY Mathf.Clamp01(percentY) int x Mathf.RoundToInt((gridSizeX 1) percentX) int y Mathf.RoundToInt((gridSizeY 1) percentY) return grid x,y void OnDrawGizmos() Gizmos.DrawWireCube(transform.position, new Vector3(gridWorldSize.x, gridWorldSize.y, 1)) if (grid ! null) Node playerNode NodeFromWorldPoint(player.position) foreach (Node n in grid) Gizmos.color (n.walkable)?Color.white Color.red if (playerNode n) Gizmos.color Color.cyan Gizmos.DrawCube(n.worldPosition, Vector3.one (nodeDiameter .1f)) And here is my node script using System.Collections using System.Collections.Generic using UnityEngine public class Node public bool walkable public Vector3 worldPosition public Node(bool walkable, Vector3 worldPos) walkable walkable worldPosition worldPos


Unity Shader Graph, set blackboard properties from code I have a Shader Graph shader with a blackboard property that I want to change from within my code. The property is called Highlight here are the things I have tried Color myColor new Color(1f,0,0,1f) material.Color myColor throws error (as I expected) material.SetVector("Highlight", myColor) Name in blackboard window material.SetVector("HighlightColour", myColor) Name in material property material.SetVector("Color 8C3A526", myColor) Name in the shader inspector None of these work. Here's the shader set up


How to figure out what's moving my GameObject? I have a GameObject as part of a complex scene with a handful of interconnected parts, that's moving when it shouldn't be. I've tried running under the debugger and setting breakpoints on all of the script points that are supposed to move its Transform, and ensured that none of them are firing. There seems to be some "spooky action at a distance" going on, some rogue script doing something I don't want it to be doing, but I can't for the life of me figure out where it is. What I'd really like is some way to set a "breakpoint" on the object's Transform that will break me into the debugger when it gets moved by any script, but that doesn't appear to be supported. Is there any way to figure out exactly what it is that's moving my object around when it shouldn't be? (And before anyone says "trial and error, disable components and see when it stops moving," I already know exactly which component to disable to make it stop moving. Unfortunately, that isn't helping track down the problem because the movement isn't coming directly from that component's MonoBehaviour script.)


Configure VR support that enables to "look" around and receive user input (Google Cardboard button) When the user moves the head this means that the phone in the HMD also moves and there are sensors that can detect the direction of the phone so that the image can update correctly. Also to note that the HMD has a button that can be clicked and trigger an action. In early 2019, in order to implement both of the above mentioned functionalities (look around and click), stared by configuring Settings gt Player gt XR Settings and add Cardboard as Virtual Reality SDK. Then, I've used the prefab GVR Editor Emulator. It was basically going to this link, download Google VR SDK for Unity, drag it into Unity and import. Once the import finished, it's possible to see in Assets a folder named Google VR. The prefab can be found then under Assets gt Google VR gt Prefabs gt GvrEditorEmulator, copy and paste in our scene. Now, more than 1 year after, when I go to the GvrEditorEmulator page, can see November 6, 2019 update There's a new open source Cardboard SDK that offers a streamlined API, improved device compatibility, and built in viewer profile QR code scanning. We recommend that all developers actively building for Google Cardboard migrate to the new Cardboard SDK iOS, Android NDK, Unity XR Plugin (SDK) What changes in the process considering this update?


Unity ball hitting paddle not reflecting right away After the ball hits the paddle it continues for a frame or two in the physics, reflected direction, then my onCollisionEnter2D function runs and changes the velocity. At least, that's what it seems like. I'm a noob with Unity so I must be misunderstanding something. https streamable.com ac2gg if (other.gameObject.CompareTag("Paddle")) float dist ballRb.transform.position.x paddleRb.transform.position.x if (dist gt 0) print("right") ballRb.velocity new Vector2(4, speedY) else print("left") ballRb.velocity new Vector2( 4, speedY) Thoughts on why there's a stutter after a redirection? I slowed it down so you can see better what's happening.


Send mesh to a video card with the help of ngui instead of DragonBones in Unity I am working at the project. It is pretty huge. And there is ngui at its core, so I can not go away from it (from ngui). Now I am assigned to incorporate the DragonBones into the project. There are visual elements made with DragonBones which are (those elements) displayed behind the ngui elements. I know that ngui works as follows it gathers all the meshes and sends them all to the video card at once. Is it possible to make DragonBones put the meshes in that gathering, so that DragonBones visual elements were sent to the video card along with ngui elements and hence were displayed in accordance with ngui elements? Will extending the UIBasicSprite help me to tackle the issue?


Smoothen line on linerender I've created a square using linerenderer but my problem now is that the line is not smooth. see below picture. I've tried enabling anti aliasing and setting lr.numCapVertices to no avail. private void DrawLine() GameObject myLine new GameObject() myLine.transform.position start myLine.AddComponent lt LineRenderer gt () lr myLine.GetComponent lt LineRenderer gt () lr.material new Material(Shader.Find("Sprites Default")) lr.positionCount 4 lr.startWidth .1f lr.endWidth .1f lr.SetPosition(0, new Vector3(1, 0, 0)) lr.SetPosition(1, new Vector3(2, 0, 0)) lr.SetPosition(2, new Vector3(2, 1, 0)) lr.SetPosition(3, new Vector3(1, 1, 0)) lr.loop true Gradient gradient new Gradient() gradient.SetKeys( new GradientColorKey new GradientColorKey(Color.red, 0.25f), new GradientColorKey(Color.green, 0.50f), new GradientColorKey(Color.blue, 0.75f), new GradientColorKey(Color.yellow, 1f), , new GradientAlphaKey new GradientAlphaKey(1f, 0.0f) ) lr.colorGradient gradient


2D Driving Game with Unity I'm trying to make a 2D car driving game in Unity and I'm having problems with my code. I am able to move forward,backward,turn left right using arrow key from my present code using UnityEngine using System.Collections public class CarControll MonoBehaviour Use this for initialization float speedForce 15f float torqueForce 200f float driftFactorSticky 0.9f float driftFactorSlippy 1 float maxStickyVelocity 2.5f float minSlippyVelocity 1.5f bool move false public bool forwardArrow false public bool backwardArrow false public bool rightTurn false Use this for initialization void Start () void Update() move true Update is called once per frame void FixedUpdate () Rigidbody2D rb GetComponent lt Rigidbody2D gt () float driftFactor driftFactorSticky if(RightVelocity().magnitude gt maxStickyVelocity) driftFactor driftFactorSlippy rb.velocity ForwardVelocity() RightVelocity() driftFactor if( Input.GetButton("Accelerate") Input.GetButtonDown("Forward") Input.GetKeyDown(KeyCode.UpArrow)) Debug.Log ("Uparrow....................................................") rb.AddForce( transform.up 20) if( forwardArrow true) rb.AddForce(transform.up 0.5f) if(backwardArrow true) rb.AddForce( transform.up speedForce 25f ) if(Input.GetButton("Brakes") Input.GetButton("Backword") Input.GetKeyDown(KeyCode.DownArrow)) rb.AddForce( transform.up speedForce 2f ) float tf Mathf.Lerp (0, torqueForce, rb.velocity.magnitude 2) rb.angularVelocity Input.GetAxis ("Horizontal") tf Vector2 ForwardVelocity() return transform.up Vector2.Dot( GetComponent lt Rigidbody2D gt ().velocity, transform.up ) Vector2 RightVelocity() return transform.right Vector2.Dot( GetComponent lt Rigidbody2D gt ().velocity, transform.right ) public void MoveForward() forward button forwardArrow true backwardArrow false public void MoveBackward() backward button backwardArrow true forwardArrow false public void RightTurn() right button rightTurn true I have added four button(Forward,backward,right,left).Now I need to move the car using this button. The car is moving Forward,backward using the button but when Press the right left button the car is not Turing left right while move.But its working perfectly on key press.Can anyboady help solving this issue


NullReferenceException in save game function I was making save system to save position of player. I get an exception NullReferenceException Object reference not set to an instance of an object It comes from this line FloatPos 0 DataG.transform.position.x Here is my Save Manager System.Serializable public class SaveManger public float Player, Top, Ground, ET, ED public int PN, PCN public SaveManger(SaveGame SaveGame) PosMath(Player, SaveGame.PlayerPos) PosMath(Top, SaveGame.TopPos) PosMath(Ground, SaveGame.GroundPos) PosMath(ET, SaveGame.EfTop) PosMath(ED, SaveGame.EFDown) PN SaveGame.TransformMover.GetComponent lt TransformMover gt ().PuzzleNumper PCN SaveGame.TopPos.GetComponent lt PuzzleSetUp gt ().PuzzleCloneNumper public void PosMath(float FloatPos, GameObject DataG) FloatPos 0 DataG.transform.position.x FloatPos 1 DataG.transform.position.y FloatPos 2 DataG.transform.position.z Here is my saved game component public class SaveGame MonoBehaviour public GameObject PlayerPos,TopPos,GroundPos,EfTop,EFDown,TransformMover public void Start() string path Application.persistentDataPath " GSave.GSF" if(File.Exists(path)) LoadButton() else public void SaveButton() SAVESYSTEM.VoidSaver(this) public void LoadButton() SaveManger Data SAVESYSTEM.LoadSave() TransformMover.GetComponent lt TransformMover gt ().PuzzleNumper Data.PN TopPos.GetComponent lt PuzzleSetUp gt ().PuzzleCloneNumper Data.PCN


Jagged array check if array index is out of range Hey I am a bit confused about how to properly check a Jagged array for "index out of range exceptions" Im quite sure im somehow supposed to use the .Length of the array but it confuses me to read this, because my tiles are of a TileType type (enum) https msdn.microsoft.com en us library system.array.length.aspx https stackoverflow.com questions 37233225 c sharp how can i check if a multidimensional array has a value and its index https stackoverflow.com questions 25562496 how to check if multidimensional array row contains non zero value What im doing is creating a grid of tiles and running through them after the fact and setting their values to have a collider (red in this case) if they are in the correct position. In order to do this I have to check the tiles surrounding the one I am currently on. This sometimes, albeit rarely, leads to an index of out range exception because the tile I am on is on the edge of the tile grid and thus it cannot find the tile I am looking for. Here is a small peice of the code void SetTilesValuesForRooms() Go through all the rooms... for (int i 0 i lt rooms.Length i ) Room currentRoom rooms i ... and for each room go through it's width. for (int j 0 j lt currentRoom.roomWidth j ) int xCoord currentRoom.xPos j For each horizontal tile, go up vertically through the room's height. for (int k 0 k lt currentRoom.roomHeight k ) int yCoord currentRoom.yPos k Make the left wall have colliders this line is the culprit if (xCoord currentRoom.xPos amp amp tiles xCoord 1 yCoord 1 TileType.Wall tiles xCoord 1 yCoord TileType.Wall) tiles xCoord 1 yCoord 1 TileType.Red if (yCoord currentRoom.yPos currentRoom.roomHeight 1 amp amp tiles xCoord 1 yCoord TileType.Wall) tiles xCoord 1 yCoord TileType.Red if (tiles xCoord 1 yCoord 1 TileType.Wall) tiles xCoord 1 yCoord 1 TileType.Red Im quite interested to know how I would properly go about checking if the tile I am about to correct is out of range or not. thank you.


Coroutine stops when Time.timeScale 0 I have a coroutine that smoothly changes a variable in my UI, but when I pause the game, the coroutine pauses too. How can I fix that? Code using UnityEngine using System.Collections public class HUDController MonoBehaviour public void PauseGame() FreezeTime() StartCoroutine(ShowPauseMenu()) private void FreezeTime() Time.timeScale 0 private IEnumerator ShowPauseMenu() var pauseMenuCanvasGroup GameObject.FindWithTag("PauseMenu").GetComponent lt CanvasGroup gt () var alphaValue 1f var velocity 0f var time 0.15f while (!Mathf.Approximately(pauseMenuCanvasGroup.alpha, alphaValue)) pauseMenuCanvasGroup.alpha Mathf.SmoothDamp(pauseMenuCanvasGroup.alpha, alphaValue, ref velocity, time) yield return null pauseMenuCanvasGroup.alpha 1 Since float is not accurate, manually set the alpha to 1 pauseMenuCanvasGroup.interactable true


AudioClip is empty saving recording from Microphone EDIT I updated the code to what I have currently. I'm not sure why but, the editor and my platform complained when I put the WWW in a co routine, it seems to load the audio clips to the object but I cannot play them. In a script attached to the object I wait until the Audio Clip is loaded before I try to play it. So I am trying to record some Audio through the microphone and then save an AudioClip to the disk as a .wav file and also save the filepath as a playerpref and then later I can come back and load the string into a url but, for some reason the Audio Clip doesn't get loaded properly as I can see that there is an audio clip on my audio source in runtime but, it has no name and it has no sound on it. However, when I press play in the inspector I can hear my sound I am using SavWav.cs to save my audio clips to .wav files. Here is the url(filepath) I am sending to my load method string filename string.Format( "CapturedAudio 0 n.wav", Time.time) string filepath Path.Combine(Application.dataPath, filename) Here is the method I am using to get the AudioClip private void SpawnObject(string savedNames, Vector3 savedPositions, Quaternion savedRotations) GameObject cubeToSpawn Instantiate(cube, savedPositions, savedRotations) WWW www new WWW("file " savedNames) cubeToSpawn.GetComponent lt AudioSource gt ().clip www.GetAudioClip(false, false, AudioType.WAV) The obj is just a cube with an AudioSource attached to it that I instantiate prior to calling this method above. The filepath works fine for saving but, for some reason it doesn't want to load the audio clip. Any help would be greatly appreciated.


Unity fade all UI elements which belong to one Canvas Like the question describes I want to fade out in all UI Elements belonging to a parent canvas. So things I got are A World Canvas which contains multiple UI Items A script which can fade one color depending how close my cursor comes to that item Things I want A script which can fade my whole canvas without attaching each single Element with a color property to it Thoughts This would most likely work with a script which searches all Text children and Image children of the canvas, but I think that would be rather poorly performing code I'm totally fine if there is no better solution as the mentioned one, but I would be annoyed if I implement it that way and there is a simple trick I don't know about )


How to run the built .exe file? I'm fresh new to unity and I only followed several tutorials. Up to now, I always used tested the games inside of unity and now I would like to use them even on different systems. Hence, I built the game and I will get a folder with several files, e.g. "Tutorial.exe" "UnityCrashHandler64.exe" "UnityPlayer.dll" "WinPixEventRuntime.dll" and the folders "MonoBleedingEdge" and "Tutorial Data". I wonder why is the .exe called Tutorial.exe? Because I'm using files from a tutorial? Probably, however, this is not really my question, instead I would like to know how I start the game.. when I run "Tutorial.exe", the terminal opens and I get the following lines there Mono path 0 'C Users info Desktop game tutorial Tutorial Data Managed' Mono config path 'C Users info Desktop game tutorial MonoBleedingEdge etc' PlayerConnection initialized from C Users info Desktop game tutorial Tutorial Data (debug 0) PlayerConnection initialized network socket 0.0.0.0 55319 Multi casting " IP 192.xxx.y.zz Port 55319 Flags 2 Guid 2366299205 EditorId 3420877675 Version 1048832 Id WindowsPlayer(DESKTOP 58KOK07) Debug 0 PackageName WindowsPlayer" to 225.0.0.222 54997 ... Started listening to 0.0.0.0 55319 PlayerConnection already initialized listening to 0.0.0.0 55319 Initialize engine version 2018.4.13f1 (497f083a43af) Forcing GfxDevice Null GfxDevice creating device client threaded 0 NullGfxDevice Version NULL 1.0 1.0 Renderer Null Device Vendor Unity Technologies FMOD initialized on nosound output Begin MonoManager ReloadAssembly Completed reload, in 0.132 seconds UnloadTime 0.683600 ms Setting up 2 worker threads for Enlighten. Thread gt id 2bc8 gt priority 1 Thread gt id 2280 gt priority 1 I would expect being set into the game? The game has no menu or anything else, one should just be spawning in a landscape and walk around. Instead I end up in the console all the time. What am I doing wrong? More information I'm following this tutorial here https www.udemy.com course virtual reality game development learn lecture 7118680 overview So it is about a virtual reality scenario but afaik the building and so on shouldn't really be different. These are the options I use to build I would like to use the htc vive. I use two different systems The one where I build the game has steam and steamvr installed but no connected hmd. The other one is in another chamber where I play vr and so on.


Player appears in front of objects even if it's in the background I have a player in Z 0 and a fence object that I want it to be in from of the player so I set it to Z 1, it's a 2D game but in the 3D view I can see that the fence is actually in front of the player but in the 2D view the player is displayed in front. Here are a couple of screenshots. 3D view, fence in front of player 2D view, player in front of fence Any idea how to fix this?


What is the correct way to use GameObject.Find in Unity? I have been following along with a Lynda.com video course to familiarize with Unity. I am currently attempting to grab a reference to a scene's First Person Controller's transform as follows Transform targetObject Use this for initialization void Start () targetObject gameObject.Find("First Person Controller").transform And this is within a script class that inherits from MonoBehaviour. However, this gives the error Static member UnityEngine.GameObject.Find(string)' cannot be accessed with an instance reference, qualify it with a type name instead I am sure there is a way to just change the logic and get the desired affect with a different approach. But I do not understand why this results in an error. It is the same code used by the instructor of the course, and from the Unity Script Reference, I can see that MonoBehaviour inherits a gameObject member which has the Find() method. So this error is saying there is only one GameObject instance for all MonoBehaviour classes right? But shouldn't I still be able to call it's methods? I am using Unity 4.1 with C while the instructor is using 3.5 (with JS) if that helps any.


Jagged Edges Even With Anti Aliasing 8x Multi Sampling I have an interior scene where I have imported a model for the apartment and many of the interior objects such as lamps, windows, etc. Unfortunately I have a lot of jagged edges on almost all the objects in my scene even on Fantastic Quality settings with Anti Aliasing pushed to its maximum. What else can I do to reduce the jaggies seen here Here are my quality settings And here are my model import settings


Unity Hiding Game Objects vs Creating them My game project involves collecting items that will be displayed in trophy cases of sorts. There could be several hundred objects as the scale of the project increases, each with their own position, rotation and scripts. I would find it easier to place the assembled items in their correct location using the editor and set their canvas group alpha to 0 (and set booleans in the script to inactive etc) and 'activate' them when they are 'collected' rather than instantiate them from prefabs as GameObjects. My main question is about performance, is it costly to have my Gameobjects set in scene amp created but set to 0 alpha? I don't need these objects to move or be destroyed etc. My second question is about best practices for architecture design, is this a horrible way to do things? is a workaround for instantiating prefabs just lazy and counterproductive?


How to keep the object rotation while using RotateAround in Unity? I've got an object that has a comet like sprite rotating around it. I'm using this code in LateUpdate() to make it rotate and keep the comet's tail at the right position transform.position player.transform.GetChild(0).transform.position (transform.position player.transform.GetChild(0).transform.position).normalized 2f transform.RotateAround(player.transform.GetChild(0).transform.position, Vector3.forward, 100f Time.deltaTime) It works fine until the object moves. After moving, the comet follows the object and goes back to the orbit, but its rotation gets messed. I've got an image describing this problem The image on the left shows how the comet behaves at the beginning. On the right there's a sample of how the comet's position can possibly look after moving around. I want it to always look like on the left image. Is there any way to stick the comet to the object's orbit? It can move as fast as the object, I don't need tealistic calculations of the position changing for the comet.


Unable to Set Up unity remote? I have installed Android Studio and set the path in unity. And I am able to build apks with no problem. But when I try to test in unity remote unity gives an warning as Set up Android SDK path to make Android remote work I don't know what is happening. If Android SDK path is not set then how am I able build the apks. I tried to solutions like enabling usb debugging mode , running unity editor first then opening Unity Remote , installing Google USB driver component of Android SDK but none of them worked for me.


Unity 4 mecanim 'Quaternion to Matrix conversion failed, input quaternion is invalid' I'm trying to animate a stick figure in Unity, with placeholder animations. Character is built animated in Blender, exported to FBX. When imported to Unity, everything appears correct in the editor. All animations are imported, and i can preview them normally. I set up the "rig" section of the model import to use generic rigging. This creates the avatar which is used in mecanim. I set up a simple "walkForward" animation, and setup mecanim parameters to get it called when the player moved forward all that works. The animation is called at the right times. However, during play, as soon as any animation is started on the avatar, the model disappears, and a flood of error messages appear in the console, stating Quaternion to Matrix conversion failed because input Quaternion is invalid 1. IND00, 1. IND00, 1. IND00, 1. IND00 1 IND00 I'm not altering the animation with any scripts of my own, it's all mecanim. Is there a setting i'm missing? I'm using Unity 4.3.0.0f4, building exporting my mesh with Blender (latest).


How to make sure that at least one element in a collection has a certain value? In my game, I assign each agent a random direction. However, at least one of these agents has to have a direction of Vector2.up. How can I ensure that? private void AssignRandomDirection() var directions new List lt Vector2 gt Vector2.up, Vector2.down, Vector2.left, Vector2.right foreach (var agent in FindObjectsOfType lt Agent gt ()) var random Random.Range(0, directions.Count) agent.direction directions random


Unity SpritePacker Atlas with Dynamic Access Here are current conditions for a game I'm building in Unity 5.6.3 SpritePacker is used to create atlases (it would be ideal if that didn't change, but it could, if no other options become evident). Config file describing game state which specifies IDs referring to specific sprites, is loaded. Resources.Load() worked fine with individual sprites, but doesn't work properly with SpritePacker can't access elements by ID, programmatically. Programatic access to SpritePacker sprites is done via an object in the scene that has inspector set arrays of all correctly named assets. From these, the script on that object creates a public static dictionary keyed by those IDs. This dictionary supplies sprites, by key, to rest of game. Memory use and draw calls are reduced, but Android crashes about 50 of the time on startup (game killed by the OS), which seems to result from a delay caused by loading the large Atlas element in the scene... could be wrong though. So... How do I use SpritePacker AND get dynamic access to atlas entries? (AFAIK, it is not possible in 5.6) OR What other solutions can solve this without a major overhaul?


MotionBuilder Actor attached to Mocap moves fluently, but Character using Actor as source jitters and has joints occasionally pop out I'm trying to get a MotionBuilder animation to work in Unity on my custom character. I've downloaded Motionbuilder FBX mocap files with Actors already attached from http dancedb.eu main performances The thing is that when I put the Actor as the Input source for my own (Characterized) character model and hit play on MotionBuilder, my model follows the animation 80 correctly but for the other 20 my character jitters and shakes and occasionally even quot breaks a limb quot when a joint randomly pops out of its place for a second. Does anyone have suggestions on how to get the animation smoother for my Character?


Testing Unity 2D Physics I am looking to push the 2D physics in Unity to the extent where when so much is going on that there becomes noticeable lag in a game. This is for testing purposes, so that when so much is going on that a button can be pressed to reduce the amount of physics objects on screen then see what affect that has. So in my small 2D demo I have placed alot of barrels on the map, all of which have physics on them, player bumps into them and they move. I have went to the extent of placing alot of them on the map (864 to be exact), bumping into them I still don't see any effect on the gameplay. Other things I have tried, besides adding alot in, is increasing the mass of the barrels, changing their linear and angluar drag and making them bouncy. Is there anything I can do besides adding alot more in? Thanks!


Why am I unable to edit the Input Field object's script? When attempting to edit an Input Field object's script like so I get the following error Unable to open C Program Files Unity Editor Data UnityExtensions Unity GUISystem UnityEngine.UI.dll Check external application preferences. Why is Unity attempting to open a .dll, here?


Programmatically create a trigger within abnormally shaped room So I'm trying to create a trigger in each of my rooms. These rooms can be created by players. Basically, I need to know all the objects in a room. These rooms can be shaped in weird and wonderful ways. I'm struggling to figure out how to "fill" an area? The other problem is that some walls are curved. My current thinking is Loop over all the walls in a scene. Do 4 raycasts from each side of the wall and see if we hit other walls. If we do, we are likely in a room. From the offset, literally check each node adjacent to that until we fill the room. Once I have this though, Im not sure what to do with it. How do I create bounds that I can check for collisions with this data? Edit Adding an image for clarity. Red and blue should be 2 different rooms and I want to get all items in each of these rooms


Unity How to get a GameObject programmatically? I have created a prefab. In Unity Scene editor, I dragged the prefab into the scene and named it PrefabA (this is a GameObject instance of the Prefab). Now, I need to update the PrefabA position. How can I access the GameObject "PrefabA" during runtime via script? GameObject prefab GameObject.Find("Canvas PrefabA").GetComponent lt GameObject gt () The code above throws Object reference not set to an instance of an object.


Oculus DK2 won't display Unity 5 I am having a problem with my game showing on my Oculus. I checked mark "Virtual Reality Supported" in Player settings. When I run the exe, I right click to use the option to play on Rift, but it just plays on my Desktop(and it plays fine on its own). The Oculus Configurations Utility shows that my Oculus is "ready," but it doesn't detect to run on the Oculus. I haven't used my Oculus in awhile and use to having the direct to rift option and extended mode, so it's pretty foreign to me so help is appreciated.


How to render gameplay over UI? I'm working in 2D. I have set up 2 cameras. One for UI and another one for gameplay. I need the UI to be rendered after before game objects (over gameplay). I wanted to achieve this without using world space canvas, because It requires being scaled for every other device along with a camera. UI can be drawn over gameplay using greater depth than gameplay camera. And because it's depth only there is no solid color, so it all works well. But you cannot set gameplay camera to depth only because it doesn't render things right, it doesn't clear the render texture I guess. So this is what happens if gameplay camera is set to depth only. This is what happens when gameplay camera is set to Solid Color and UI Camera has bigger depth. You can see that the ring is covered by UI arrow. If the UI Camera depth would be lower than gameplay camera (Solid Color). It would all be covered by gameplay camera without even displaying UI. These are mine settings. Is there a way to achieve this in Unity without using World Space Canvas Mode?


Clamping after forcing aspect ratio I'm using the following script to force aspect ratio of 16 9 https forum.unity.com threads force camera aspect ratio 16 9 in viewport.385541 It works perfectly. However now my game objects are allowed to move off the edges. The camera of the game is fixed, and never needs to move or scale. I have changed my code to WorldToViewportPoint for this but half my of character still goes off the edge. void Update() Vector3 pos cam.WorldToViewportPoint(transform.position) pos.x Mathf.Clamp01(pos.x) transform.position Camera.main.ViewportToWorldPoint(pos) private void FixedUpdate() Vector3 pos cam.ScreenToWorldPoint(Input.mousePosition) if (pos.x transform.position.x gt 0.5f) transform.eulerAngles new Vector2(0, 180) animateOgre(true) Vector2 move new Vector2(1, 0) rb.MovePosition((Vector2)transform.position (move speed Time.deltaTime)) else if (pos.x transform.position.x lt 0.5f) transform.eulerAngles new Vector2(0, 0) animateOgre(true) Vector2 move new Vector2( 1, 0) rb.MovePosition((Vector2)transform.position (move speed Time.deltaTime)) else animateOgre(false) My questions are How do I allow the whole character to stay within the Viewport? How can I clamp within the fixed update method rather than making a seperate update method. Is there anyway to prevent character from moving when the mouse is aligned up with the position of the character. Right now I'm using a hacky solution to find if the x difference is 0.5. (If i don't do this the character just moves back and forth when mouse stops)


How to use rigitbody2d.AddTorque() in JavaScript? (unity2D) I just want to know how to use rigitbody2d.AddTorque() and an example script would be great D. I am trying to rotate a cube forever using it as a test.


Instantiating problems I'm beginner here, I'm trying to instantiate a single object every specific duration, either form the left of the screen or from the the right, at the same time I want this object to move to the other side of the screen So the troubles I'm facing here are sometimes 2 objects are being instantiated at the same time. the objects move in the direction that are defined in the first if statement (both objects on the left and the right move in one direction) the part where I instantiate objects is in the script(smallFishes) that's attached to an empty gameobject is void Start () timer gameObject.AddComponent lt Timer gt () width 2f timer.Duration 3 timer.Run() left Resources.Load("Left") as GameObject right Resources.Load("Right") as GameObject void Update () if (timer.Finished) lr Random.Range(1, 3) if (lr 1) var generetx 8.8f width 2 Instantiate(left, new Vector2(generetx, Random.Range( 4.8f,4.8f)), Quaternion.identity) else var generetx 8.8f width 2 Instantiate(right, new Vector2(generetx, Random.Range( 4.8f, 4.8f)), Quaternion.identity) timer.Duration 3 timer.Run() public int state get return lr the part where I make the object move from the script that's attached to the object prefab void Start () small gameObject.AddComponent lt smallFishes gt () rb2d gameObject.GetComponent lt Rigidbody2D gt () void Update() var fishes GameObject.FindGameObjectsWithTag("small") if (fishes! null) if (small.state 1) moveright new Vector2(4 Time.deltaTime, 0) rb2d.AddForce(moveright, ForceMode2D.Impulse) else moveleft new Vector2( 4 Time.deltaTime, 0) rb2d.AddForce(moveleft, ForceMode2D.Impulse) Thanks in advance.


Unity strange performance impact with moving objects I'm trying to find the solution for 46 hours now and I'd be really happy if someone knows it! I'm using a DOTween library for moving the objects. I also use LeanTween, cause I heard it's faster but none of these work for me in this case. I've used tweening libraries alot, but never faced an issue like this. The bug appeared in my project, so to check it I created a blank one. An empty scene, with a camera and one cube with scale 10,2,10 . Now, I've added a simple script Sequence sequence DOTween.Sequence() sequence.Insert(0f, transform.DOMove(transform.position new Vector3(10f,0f,0f),1f)).SetEase(Ease.Linear) sequence.Insert(1f, transform.DOMove(homePosition,1f)).SetEase(Ease.Linear) sequence.SetDelay(1f) sequence.SetLoops( 1) The script moves the cube continously by 10 units to the right, and back (both in 1 second). There's a noticable jitter. This jitter is strange, cause it does not happen contantly. It choses a time and just freezes the cube in place for a really tiny amount of time which is noticable when you see a smoothly moving object and it freezes for a moment. As you can see, there's a linear interpolation, but I've tried with many (it's even better visible with other interplation types). Now. The profiler is not the case, cause I've tested it on the empty project with one object on the scene. Things I've already tried Turning off occlusion culling Turning off everything I could All the combinations of quality settings LeanTween instead of DoTween The one thing I came up with is the profiler's WaitForTargetFramerate. By definition, when WFTF is huge it means that the app is doing well, cause it finished it's work and waits for the next frame. In my opinion in this case it's the reason of the bug. I have a screenshot of the profiler window (with one cube, one directional light and this script attached to a cube) Now, I'm not 100 sure, but I think that this jitter may happen on these V Sync drops on the screen. Everything is tested on the PC. On Android there's the same thing (a noticable jitter), but I didn't run the profiler. If someone has any idea what may be the cause of this I'd be grateful. I'll put a bounty here as soon as I can, cause I'm really tired! ) DMGregory This is before the 'jump' on the GPU chart and that's on the 'jump' There's no RigidBody or Collider, but on my main project there are box colliders on these floors. I've also tried adding RB with the Interpolation checked. No difference. Josh Hamilton Even if this is a normal behavior, that the frame completed faster there are games on Google Play and AppleStore without any glitches like this. In my main project (where I discovered the issue) the biggest problem is that this lag is happening when I move the camera to follow the player smoothly and the freeze it noticable like anywhere else. Like the entire enviroment was freezing for 1 3 frames.


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


Movement Issues jumping to another GameObject My code can make a GameObject jump while simulating gravity. Now I want my GameObject to jump. The purpose of this is to always have a nice "touchdown". Instead of the parabola, I want to use my jump script but I want it to jump using this relation with the other GameObject. I also need it to work while the target point is moving. Could anyone solve this problem? An answer would be greatly appreciated. If you've got any questions, do not hesitate to reply (I understand that it's hard to understand...).


How my bullet can take HP from enemy? using UnityEngine using System.Collections public class GunScript MonoBehaviour public Transform barrel public float range 0f public Rigidbody myBullet void Update() if (Input.GetMouseButtonDown(0)) Rigidbody bulletInstance reference make the bullet apear out of the barrel bulletInstance Instantiate(myBullet, barrel.position, barrel.rotation) as Rigidbody bulletInstance.AddForce(barrel.forward range) give the bullet some force to move forward IEnumerator Fire() RaycastHit hit Ray ray new Ray(barrel.position, transform.forward) in don't know how write this iff if (Physics.Raycast(ray, out hit, range)) Enemy enemy hit.collider.GetComponent lt Enemy gt () enemy.health 1 Debug.DrawRay(barrel.position, transform.forward range) yield return null I made an enemy class, my bullet is a prefab, but i don't understand what i need to do to lower HP points when the bullet hits.


How to select parent of currently selected object? When i select an object, i can't find a function to select its parent. Does this basic feature exist ? I want to select the parent of selected object and then step up to find parent of parent so on without using the hierarchy window.


Why are my Player Input Unity Events started twice? I'm using the (new) quot Input System quot package and the quot Player Input quot component on my player prefab like this public class Player MonoBehaviour UsedImplicitly public void Fire(InputAction.CallbackContext context) if (!context.started) return Debug.Log( quot Fire! quot ) The odd thing is, this method is invoked twice with context.started true. What am I missing here? Why is the method invoked twice? A minimal working example to reproduce the behaviour can be found on GitHub. EDIT The player joins automatically through the quot Player Input Manager quot


Why is my Canvas RawImage not included in my Camera's RenderTexture output? In my Unity2D game, I'm using a second camera to "screenshot" the current view. I then display this screenshot within the game. This works the first time I take a screenshot. When taking the second screenshot, I expect the first screenshot to show up in the second, creating a screenshot within a screenshot effect. However, this doesn't happen the previous screenshot doesn't show up in the next. Here's a more visual description Before taking any screenshots After taking the first screenshot and displaying it in the bottom left corner After taking the second screenshot Notice that this screenshot looks identical to the previous one. Here's what I expected It seems like my Canvas RawImage that is displaying the screenshot isn't being captured by my second camera. Why is this? Some additional details my canvas is set to Screen Space Camera. I'm using Unity 5.6.1f1.


How can I manually draw a Sprite in Unity? I'm creating a simple workaround on the unsupported prefab on prefab. I've thus created this simple class ExecuteInEditMode public class PrefabLinker MonoBehaviour public GameObject prefab private GameObject spawn void Awake () if UNITY EDITOR if (!EditorApplication.isPlaying) return endif spawn (GameObject)Instantiate(prefab) spawn.transform.parent transform.parent spawn.transform.localPosition transform.localPosition if UNITY EDITOR void Update () if (EditorApplication.isPlaying) return Manually draw the Sprite endif However I've no clue on how to manually draw the Sprite, without adding it to the scene. Obviously I can't add it to the scene like I do when I play it, because otherwise the spawn would be saved in the prefab, polluting it and creating a mess. I'm hesitant to add the spawn to the scene "somewhere else" and updating its position, because I'd like to prevent the level designers from mistakenly move this spawn instead of the PrefabLinker object. This only needs to work with 2D stuff. I've found this link which I guess does something similar to my needs, but I've no idea how to fix it to work with sprites (and doesn't work out of the box).


Return value from coroutine to non monobehaviour I have a class which is not a monobehaviour (lets call it "Generation"), and as such running CoRoutines from within are not an option. I have a monobehaviour (lets call this "TestScript") which needs to call a function within Generation. One parameter required is a Func . It then calls that Func multiple times, expecting a result in the form of a double. The problem, is that it takes time to return, it needs to run across many frames, and so it kicks off some Coroutines (as this is in the monobehaviour). I set it to return a Task so that I could use Threading.SpinWait.SpinUntil and only return after the coroutines have exited, but this just hangs the main Unity thread. Here is the function I am calling public void AssessGeneration(Func lt NeuralNet, Task lt double gt gt assessment) foreach (NeuralNet neuralNet in neuralNets) neuralNet.Fitness assessment(neuralNet).Result neuralNet.fitnessAssessed true So, I've tried many other things, such as moving the SpinWait into the Generation class, but still hangs. I've tried calling the function in Generation within a Task on a new thread, but when it attempts to run the coroutines it complains about not being on the main thread. So I have a function, in a class not inheriting from MonoBehaviour. It is called from a MonoBehaviour, and must pass in a function which takes a parameter of type NeuralNet, and returns a double. It must return a double after a coroutine has finished, but I can't be blocking the main thread.


How to reapply force applied to one object to another object Edit While I wasn't able to make the code work completely, I believe my question has been sufficiently answered. I want to make two objects move, react to collisions and other stuff as if they were one. For example, Objects A and B are entangled. When Object C rams into Object A and starts moving with it, Object B should start moving with it. When Object B hits a wall, Object A should act like it also hit a wall. I tried changing position speed every frame, but this only works when done in one direction. Now, I want all forces applied to any of the objects to also apply to the other objects entangled to it. EDIT The next step is making the thing work with one of the objects moving along a different axis(e.g. the opposite direction of the others) and at a different scale (e.g. speed is proportional to size). So fixed joints, while a working solution for the simplified version of the problem, don't work for me. UPDATE Here's the code so far, trying to figure out how to send the other object spinning in the same way as the first one, not sure how to set the position for the force(s?) applied using System.Collections using System.Collections.Generic using UnityEngine RequireComponent(typeof(Rigidbody)) public class EEScript MonoBehaviour public List lt GameObject gt activeObjects Start is called before the first frame update void Start() Update is called once per frame void Update() private void OnCollisionStay(Collision collision) OnCollisionEnter(collision) private void OnCollisionEnter(Collision collision) Rigidbody rigidbody gameObject.GetComponent lt Rigidbody gt () foreach (GameObject obj in activeObjects) Rigidbody rb obj.GetComponent lt Rigidbody gt () if (rb is null rb.gameObject gameObject) continue Debug.Log(collision.gameObject.name " gt " obj.name) for (int i 0 i lt collision.contactCount i ) ContactPoint co collision.GetContact(i) Vector3 relativePoint co.point rigidbody.centerOfMass Vector3 normal co.normal Vector3 impulse collision.impulse if (Vector3.Dot(normal, impulse) lt 0f) impulse 1 rb.AddForceAtPosition(impulse, relativePoint rb.centerOfMass, ForceMode.Impulse)


I can not proceed to my room menu using photon in unity when i use PhotonNetwork.JoinRoom() I have a TextMeshProUGUI called EnterRoomName and I am trying to enter the name of the room that I'm supposed to enter, but it's not working. This is my function public void JoinRoom() PhotonNetwork.JoinRoom(EnterRoomName .text) MenuManager.Instance.OpenMenu( quot loading quot )


NPC daily routines and scene loading I'm making a basic survival RPG in Unity 3d. I'm separating my world into different scenes to save memory but I'm not sure how I'm going to program NPC daily routines. For example, if the player arrives in a town scene in the morning, how do I ensure that the NPCs are working in appropriate places with the appropriate equipment? I suppose I could hard code it so NPCs are in certain places at certain times. Therefore, if the player arrives at 9 00am then all the NPCs will move to their 9 00am places. I'm just wondering if there is a better way of doing it than that. I can see myself needing to write a lot of code to cover all the possibilities so it could get really messy. I was hoping there was some way I could have the NPC routines continue seamlessly in the background but this would be taxing on memory if it's even possible. Any ideas pointers on this issue would be appreciated.


How to add user created data to drop down menu options So I'm trying to make it that I can have a dropdown that will have user created info appear in it. List lt engines gt engineList new List lt engines gt () public Dropdown engineSelect public class engines public string engineName public int featureNumber public int totalDevPoints public string optimizedGenre public engines(string name, int feature, int totalPoints, string opt) engineName name featureNumber feature totalDevPoints totalPoints optimizedGenre opt engines playerEngine new engines(engineName, numFeature, 0, whatGenre) Pretend player set engineName, numFeature, and whatGenre with text fields. I wanted to have it that the drop down would add in whatever new engines the player makes. How would I do that? I want to have it say select engine and then the player would pick from dropdown from engines they made(only saying engine names).


Can I switch off scenery elements on a 3D model? I am using a 3D asset that has flat scenery elements (3D island with 2D bushes). 1 Having encountered a number of problems with this scenery 2 I want to deactive it (not visible, not collidable, keep the island itself). Is this possible? 1 The asset set in question is http u3d.as content dexsoft games platformer 2 3Uo the problematic objects are things like AmbientOcclusion platform2 floating .fbx which (I can see visually) include bits like plant 9.fbx which are the misbehaving elements. 2 The bushes are collidable making it difficult to move around on the island. Specifically you can walk through them in one direction but not the other. On the suggestion of the creator, we unchecked "Generate colliders" on the island model, but doing that means the whole island has no collider and you fall through it! In addition, the alpha levels on the bushes stopped working, and they appear as rectangular elements (alpha values have been lost, replaced by gray white) I must've messed up the alpha value setting but can't figure out how to turn it back on. (If comments reveal these issues are fixable I'll expand them into separate questions.)


Check whether an object is fully inside overlapped by other objects in Unity3D? I have structures made of voxels (cube gameobjects), and I want to make complex structures from them. But I don't always want to place them on the grid. I want them to be more realistic, like diagonal (Don't mind those visual artifacts) (If I would want to make a fortress like this on the grid, these diagonals would be ugly and zigzaggy.) My problem is that due to this there would be double the voxels at the overlapping places. I want to remove every cube (for example from the selected wall object) which are being FULLY overlapped. This way there won't be double voxels (only partially at the edges, which is fine) and it would look good as well. How could I check this? I don't want to modify the structures manually because both the angle and the other object may vary, thus one structure would need lots of variations.


Have a particle system's particles obey transparency sort mode individually Background In a top down game, I have particles that spawn animated textures. I have my 2D renderer settings set up so that it orders sprites based on their position on th Y axis via "Transparency Sort Mode Custom Axis Y". The Problem But instead of sorting for each particle spawned, what happens is the particle system obeys the setting as a whole so that the sort order is only based on the particle's system's center. Is there a way to have each particle obey Transparency Sort Mode individually? What I want for each particle What actually happens Other Solutions Other people seem to have an old workaround to use GetParticles and setting their "order in layer" individually. See this thread from 2015 https forum.unity.com threads particle systems with sprites order in layer.464533 But I'm trying to find if there's a cleaner solution for Unity 2019 without having to fudge with "order in layer".


Start iTween MoveTo from a specific node? (Unity) I just started using iTween as part of my day night cycle. I'm trying to move the sun and moon along a curve, but I want have the sun moon start at a specific location depending on the time of day. That would mean beginning the MoveTo() function from, say, the 3rd node instead of the 1st node, but I can't figure out how to access specific nodes. If that's not possible, is there some other workaround? I thought of making several paths of two nodes each and calling the next path once the first one finishes, but then the object has to move in a series of straight lines.


Different resolution for UI? I'm developing my first game for mobile devices in Unity3D. My game uses a 720p resolution. Currently the UI uses the same one. So far so good. I heard that professional game developers create their games in a way where the UI uses a much higher resolution than the game itself in order to deliver high definition graphics for the UI system. So in my case does that mean I have to create a much higher resolution for the UI so it looks crisp and sharp even on large mobile displays (e.g. tablets like the iPad Pro, etc.)? Is 1080p a good resolution for the UI I'm creating? Or shall I stick with 720p? If I use e.g. 1080p for the UI do I need to scale down the UI in Unity3D?


Need help solving an acute triangle to find the distance to the outside of my object I recently asked a question here How would I check the range against the entirety of an enemy object, and not just it 39 s transform.position? That was accurately answered, and works perfectly fine. However, now I need to find the distance from the center of a non rectangular object to it's edge as illustrated here I have the length of Side A, and the angle between Side A and Side C, as well as the angle between Side A and Side B. I am missing a couple things The length of Side B The length of Side C My end goal is to get the length of side C. It is important to note that my math skills are barely comparable to first year college algebra. I heavily rely on the methods provided within Unity to calculate dot products, angles, and distances without much understanding of their inner workings. How would I go about accomplishing this?


What's the "appLinkUrl" parameter in the "AppInvite" method for? I'm trying to figure out what should I assign the appLinkUrl parameter of FB.Mobile.AppInvite method. In documentation it says The AppLink URL to identify your app and also used for deep linking Should i pass my Play Store link to it? Thanks in advance. The documentation page for FB.Mobile.AppInvite https developers.facebook.com docs unity reference current FB.Mobile.AppInvite


What is the cause of these WaitForFPS spikes and dips? In Unity, moving the player causes the camera to jitter. I went to the Profiler, and I saw these spikes On further inspection, all the yellow spikes were WaitForFPS(). I've tried every VSync setting in quality options, but none of them seem to fix this issue.


Unity Redraw canvas graphic on Update() using UnityEngine using UnityEngine.UI public class DrawLoad Graphic protected override void OnPopulateMesh(VertexHelper vh) float r rectTransform.rect.height 2.0f float widthFactor (rectTransform.rect.width 2.0f) r float y r float x 0.0f int t 20 t total vertices float a 360.0f (t 1) angle delta differences between each vertex float aC 0.0f incrementing angles from 0 gt 360 int maxi t 1 Vector2 vtR new Vector2 t UIVertex uivR new UIVertex t vh.Clear() for (int i 0 i lt maxi i ) y r Mathf.Cos(Mathf.Deg2Rad aC) x r Mathf.Sin(Mathf.Deg2Rad aC) vtR i new Vector2(x, y) aC a uivR i UIVertex.simpleVert uivR i .position vtR i 0,0 uivR i .color Color.green vh.AddVert(uivR i ) add center point Vector2 center new Vector2(0.0f, 0.0f) UIVertex c UIVertex.simpleVert c.position center 0,0 c.color Color.green vh.AddVert(c) for (int i 0 i lt maxi i ) vh.AddTriangle(t, i, i 1) use indexes, don't use count, start from 0 for (int i 0 i lt uivR.Length i ) uivR i .color Color.green vh.SetUIVertex(uivR i ,i) Hi, I wish to change the color dynamically of each assigned triangles. I have these code modified from Unity documentation and I tried the SetUIVertex method but it doesn't seems to work. What is the proper way to redraw the vertices. I want to make it in MonoBehavior.Update(). Any helps would be greatly appreciated. Thanks.


Fb.Feed dialog closes before saving I'm having trouble with the Facebook UnitySDK when I use the FB.Feed() method for posting on user's timeline. The share dialog closes before the post is completed, Right after i press the "Post" button. This only happens when I test the app on the iOS Device since on the Unity Editor it works fine and I can post on the user's wall. User Login and getting username and profile pic, for example, work fine. The problem is when I try to share the user's score on facebook. Here's my code for the method public void Share Score() FB.Feed ( toId "", link "http www.facebook.com appname", linkName "App Name", linkCaption "I just scored " " points", linkDescription "Playing this game is awesome!", actionLink "http www.facebook.com appname", actionName "Appname Fan Page" ) The only error that appears on XCode is the following 2015 02 11 10 13 07.025 hotdogcontest 749 224865 FBSDKLog FBLinkShareParams only "http" or "https" schemes are supported for link thumbnails


Find position in arc depending on the direction of the agent So what I am trying to do is to find a random point on the (green quot ) arc around the enemy Sorry for the bad drawing but Red (no go) Green ( Points the allied can go to) I know that unity has the following function Radius 5 randomDirection (Random.insideUnitCircle target.position).normalized Vector3 finalPosition target randomDirection Radius However, this is for a full circle. How can I achieve the closest half circle?


Double vision with Google Cardboard in Unity I am working on a VR app. I have a terrain and some cube placed in the terrain.Even I have added the Reticle to point at the cube and display some message when the user gaze at the cube. I have set the distortion to "None". The problem I am facing here is,when I run the app the cubes and the pointer(reticle) is seeing as double in the scene.What will be the reason for it.Can anybody help me out please.


Determine if AI can traverse a given spline I have some AI Agents that I want to navigate along a spline. The agents have a speed and a maximum turning radius. For some splines the curvature is too tight for the AI agents to navigate around and they end up shooting of the spline and then turning, which looks weird. How can I take a given spline and find the segments that are too tightly curved for a given agent to traverse without shooting off? I thought about just taking the angle between control points, but that alone won't account for the speed limitations that I want to impose as well. Can someone point me in the right direction? I am using Curvy for my spline implementation but using my own agent movement system to walk along the splines. http www.fluffyunderware.com pages unity plugins curvy.php


IndexOutOfRangeException Array index is out of range even though the inspector clues otherwise I am currently making a randomized infinite platform with GameObject already made platforms in 3 arrays. In the inspector everything is obviously running quite smoothly but I keep weirdly keep getting uncalled for errors like IndexOutOfRangeException Array index is out of range. Here is my code using System.Collections using System.Collections.Generic using UnityEngine public class BackFloorSetter MonoBehaviour public GameObject gameBackFloorsOne public GameObject gameBackFloorsTwo public GameObject gameBackFloorsFinal public Vector3 nextPosition public float unroundedFinalOrTwo public int finalOrTwo public float unroundedTwoFloor public int twoFloor public float unroundedFinalFloor public int finalFloor public GameObject currentSpawnFloor public float floorSpawnCounter public int counterGoal 5 void Start() nextPosition new Vector3(0, 0, 0) Instantiate(gameBackFloorsOne 0 , nextPosition, Quaternion.identity) void Update() floorSpawnCounter 1 Time.deltaTime if(floorSpawnCounter counterGoal) floorSpawner() counterGoal 5 unroundedFinalOrTwo Random.Range(0.6f, 2.4f) finalOrTwo Mathf.RoundToInt(unroundedFinalOrTwo) unroundedTwoFloor Random.Range( 0.6f, 3.4f) twoFloor Mathf.RoundToInt(unroundedTwoFloor) unroundedFinalFloor Random.Range( 0.6f, 4.4f) finalFloor Mathf.RoundToInt(unroundedFinalFloor) if (finalOrTwo 1) currentSpawnFloor gameBackFloorsTwo twoFloor if (finalOrTwo 2) currentSpawnFloor gameBackFloorsFinal finalFloor public void floorSpawner() nextPosition.x 232 Instantiate(currentSpawnFloor, nextPosition, Quaternion.identity) public void flatGroundSpawner() nextPosition.x 232 Instantiate(gameBackFloorsOne 0 , nextPosition, Quaternion.identity)


Use an image as mask only where pixels are opaque We are into a game where to build our tile map, we carve on an image with a mask (At first the whole map is an image, and we create holes on it with tiles to create the map and le the background show. It is like substracting instead of adding new tiles in any common tiled based game). We have done this with just a tile that acts as a mask using stencil buffer. The problem comes when we want to mask with tiles where all their pixels are not opaque, for example a slope. The problem is that it applies the mask as if all the pixels in tile where opaque and we want to apply the mask in two differnet ways 1) Keep the pixels of the big image where the mask pixels are opaque 2) Mask the pixels of the big image where the mask pixels are transparent (alpha 0) I have read a lot of info about using stencil and alpha blending but can't make it work. Checking the pipeline order it seems that stencil is applied after the fragment color has been calculated. Is it possible to access the alpha value at stencil stage and write to the stencil as needed to just mask part of the image (tile in my case). Update to add a visual example


How do I run code for a period of time and then return to normal behavior? i wanna run a code for my special power for five seconds only and then return to my normal working. when that power activates i am changing my player's material and i wanna return to my old material after those five secs are over. this is the code i tried void Start () transform.GetComponent lt Renderer gt ().material.mainTexture texts 0 void Update () if (condition) for (int t1 0 t1 lt 5 t1 (int)Time.deltaTime) transform.GetComponent lt Renderer gt ().material mats 0 transform.GetComponent lt Renderer gt ().material.mainTexture texts 0 this code breaks the game i think because unity is freezing when the condition is being met.


Unity how to put a target under a character's feet that follows ground model contours? In my current projects, one of the power ups needs to place a target marker centered on the position of the player triggering it the actual design for this is TBC, but will be a circle with a radius of 10 units. The ground for the playing arena is a model, and not flat. Assuming that I use a texture to show this target area, how can I have this texture render following the contours of the ground? Alternatively, any other approach to solving this would be appreciated. Thank!


How to temporarily increase the speed of a character in a Unity game As the title would suggest, I want to give a character a speed boost for x amount of seconds, while increasing their Gameobject's mass. During this little speed boost, I also want to add a script to another player that disappears when the speed boost dies out I am new to C , and Unity in general, any help would be appreciated. using System.Collections using System.Collections.Generic using UnityEngine public class PlayerAddMass MonoBehaviour Start is called before the first frame update void Start() Update is called once per frame void Update() if (Input.GetKey(KeyCode.Q)) rb GetComponent lt Rigidbody gt () rb.mass 10 rb GetComponent lt Rigidbody gt () rb.speed 5 The code above was found on a unity website of some sorts, and I modified it to set the speed and mass numbers (I changed the 0s into a 10 and a 5) The errors I get are "rb does not exist in the current context" x 4


Shader Directional Lights Depth Is there a way to retrieve the deph from directional lights ? I can access the ShadowMapTexture but this is not the depth. I found how to access the shadow map of, I think, every light type by using the defines such as SHADOW ATTENUATION(a) or directly the ShadowMapTexture, everything is located in the built in shaders. But I am wondering how could I access the depth of those lighting type. I found a way to access it for the spot light this way ShadowCoord.z which gives the depth scaled with ShadowCoord.w, which could be considered to the far plane, but am I right ? How could I do the same for the other light types such as directional or point lights ? For the moment I am stuck with directional lights, any clues ? Because if I try to access the depth for a directional light by using ShadowCoord.z it seems that it's more related to the depth view and not the light. Here I am, totally stuck with this directional lights.


Implementing Skyrim's save system in Unity Unity has it's own way of saving in which you can add values and any type of information to the registry and it will be saved for future use. However what happens when you try to create a more complex save system such as the one featured in Skyrim. In this case it even get's a screenshot of the moment you pause the game to save and uses it to identify the save file. Also all the current actions the user and the npcs where doing at the moment gets save. How can I implement this complex save system into unity using it's current way of handling save data?


UnityEvent Array coding C I am fairly new to Unity 5, as I was browsing through some prefabs, I found one for the Main menu in which UnityEvent was used in scripts to list down the menu options. This UnityEvent was an array UnityEvent Event, which was nowhere initialized to anything but was showing no compiler errors and also during run, it was pointing to some predefined sets which the author was mentioning in the user manual... My questions are Is it possible to use UnityEvent Array without mentioning the size of the array. What happens to the UnityEvent if we don't mention any of the events, but the Invoke functionality is called during runtime. Btw, the prefab i used from was Main Menu with Parallax effects


Making a zoom out in space map in Unity I'm new to unity, I was wondering how would one go into implementing a dynamic 2d space map. Let me give you an example what i mean. You see our solar system on the map, if you zoom out at a treshold value this solar system would just be represented by a name and our sun and around it you see adjacent solar systems. How would I do this in unity?


My player sprite get stuck to walls while moving along Hello, My player sprite is moving along the wall (not even diagonal, just straight down) and get randomly blocked in the corner of some walls. By blocked, I mean that the Y movement is stopped. If I move him away from the wall, he might not be blocked again by the same wall and get blocked at some other walls, always at a corner. The walls are all the same sprite and are of the same size. I use 2D Box Colliders for the walls. The player sprite has a Box Collider 2D and a RigidBody 2D. I am not using any physics codes, I would just like to make it work with the built in Unity physics. I move the player by adjusting the velocity of the rigidbody according to Input RigidBody2D rb GetComponent lt Rigidbody2D gt () float horizontal Input.GetAxisRaw ("Horizontal") float vertical Input.GetAxisRaw("Vertical") Vector2 movement new Vector2(horizontal, vertical).normalized speed Time.deltaTime this.rb.velocity movement The player is set like this Do you have any idea why it behaves like this and how I could fix it? Thanks for your help.