Leaderboard not working in Unity I'm trying to create a leaderboard for my game. I have the game created and added the leaderbaord using cloudonce. I have also created the app on google play console and linked the app to the game services. I have followed the following tutorial to create the leaderboard Leaderboard tutorial I have followed the exact same instruction as given in the tutorial. Once the game is over, the leaderboard button is activated. I have attached LeaderboardsButton script(this script comes with the CloudOnce package) to the leaderboard button. Here is the code in the game over panel for getting the score void OnEnable() DisplayGameOverScore() void DisplayGameOverScore() gameOverScore.text ((int)gameManager.playerScore).ToString() gameOverHighScore.text PlayerPrefs.GetInt( quot HighScore quot , 0).ToString() CloudOnceServices.instance.SubmitScoretoLeaderboard(PlayerPrefs.GetInt( quot HighScore quot , 0)) This is the CloudOnceServices script as per the tutorial public static CloudOnceServices instance private void Awake() TestSingleton() private void TestSingleton() if (instance ! null) Destroy(gameObject) return instance this DontDestroyOnLoad(gameObject) public void SubmitScoretoLeaderboard(int score) Leaderboards.HighScore.SubmitScore(score) I have attahced this script to an empty game object along with the InitializeCloudOnce script(this is provided with the CloudOnce package). I have also created an alpha test on googleplay. Once I open the link and start the game, the google play services console open and when I hit the leaderboard button, google play services console loads but after that nothing happens. It just goes back to the game. I read that other people ran into similar issues and the advise given was to check if the SHA1 certificate fingerprint is the same in app signing under release management and the credentials in GoogleApis. They both match. I'm not sure what the issue is?


I can t get a teleport to work c these are the pics of the inspect panel on the parts of the 3D pacman that you asked for. (I just added these photos because I couldn t while i was away and because even though the advice given so far was amazing, it didn t resolve my problem, so please help if you can) I ve been trying to make a teleport for a while and it works only part of the time. the collisions work because i put a debug.log in it but the teleporting part doesn t work. there are no errors in the collision, it just doesn t teleport the pieces of pacman. here is the script (it's not the most improved but i was trying to make it work) public GameObject pacman public GameObject Camera public GameObject pointLight public GameObject body public Vector3 pacmantele public Vector3 cameratele public Vector3 pointlighttele public Vector3 bodytele void OnTriggerEnter(Collider other) Debug.Log("works") pacman.transform.position pacmantele Camera.transform.position cameratele pointLight.transform.position pointlighttele body.transform.position bodytele here is a photo of the inspection panel on the non working teleporter


Mouse look rotation not rotating object axis in Unity So, I made a simple First Person Camera script for my game, and the way it's supposed to work is the camera is rotated by localEulerAngles to rotate the camera around, and then just the Y axis rotation is also applied to the character, so that he moves in the direction of the camera. This isn't how its working now. I've narrowed down the two most likely problems in the scripts, and this first one is from the camera controller player.transform.localEulerAngles new Vector3(0, rotationX, 0) cam.transform.localEulerAngles new Vector3( rotationY, rotationX, 0) Note the camera works just fine, and rotates perfectly in all directions. Secondly, the player movement controller, which might not be actually be moving locally? I can't tell. transform.Translate (new Vector3(0, 0, Input.GetAxis("Vertical") walkSpeed)) transform.Translate (new Vector3(Input.GetAxis("Horizontal") strafeSpeed, 0, 0)) There you go. Right now, even though the camera moves just fine with the mouse, and, incidentally, the whole script used to work, the player moves forward on the global Z axis with W and backwards with S, all the while acting like a shooter on rails. Thank you!


How do I get the player to collide with another object to use as a boundary? I'm trying to make a simple game where you move a sphere from left right and try to avoid falling cubes. If a cube touches the player (sphere), the player dies. I'm trying to set up boundaries using a cylinder with a collider, but every time I hit the collider boundary, the player disappears like they would if they hit a cube. Here is my player script using System.Collections using System.Collections.Generic using UnityEngine public class Move MonoBehaviour public float moveSpeed 1 Start is called before the first frame update void Start() Update is called once per frame void Update() transform.position new Vector3(Input.GetAxis("Horizontal") moveSpeed, 0, 0) void OnCollisionEnter(Collision collision) if (collision.gameObject.tag "Cube") Destroy(collision.gameObject) Destroy(gameObject)


How do I apply domain warping to my marching cubes voxel terrain in Unity? So, in GPU Gems 3 there is a cool warped terrain that I seek to replicate. Currently, I'm generating the terrain fine, but I want to add that warp effect. Do this before using 'ws' to sample the nine octaves! float3 warp noiseVol2.Sample( TrilinearRepeat, ws 0.004 ).xyz ws warp 8 Im wondering how to replicate the above code in C . What does the above code do? What type of variable is noiseVol2.Sample(x,y).xyz? I want to warp my own terrain, currently I have a system that creates octaves of perlin noise with certain frequencies and amplitudes. It looks something like this var perlin0 new Perlin3(0,baseFreq 4.03f, 0.25f) var perlin1 new Perlin3(1, baseFreq 1.96f, 0.50f) var perlin2 new Perlin3(2, baseFreq 1.01f, 1.00f) var perlin3 new Perlin3(3, baseFreq 0.49f, 2.00f) var perlin4 new Perlin3(4, baseFreq 0.24f, 4.00f) return new Density(ws gt start with plane float density plane.Evaluate(ws) add perlin noise to get density values at each ws co ord. 3 octaves currently (3 perlin noise ) density perlin0.Evaluate(ws) density perlin1.Evaluate(ws) density perlin2.Evaluate(ws) density perlin3.Evaluate(ws) density perlin4.Evaluate(ws) return density ) I've tried replicating it like so var q new Vector3(perlin0.Evaluate(new Vector3(0,0,0)), perlin0.Evaluate(new Vector3(5.2f, 1.3f, 1.3f))) var q1 new Vector3(perlin1.Evaluate(new Vector3(0, 0, 0)), perlin1.Evaluate(new Vector3(5.2f, 1.3f, 1.3f))) var q2 new Vector3(perlin2.Evaluate(new Vector3(0, 0, 0)), perlin2.Evaluate(new Vector3(5.2f, 1.3f, 1.3f))) density perlin0.Evaluate(p 4.0f q) density perlin1.Evaluate(p 4.0f q1) density perlin2.Evaluate(p 4.0f q2) I've read the article that igo Qu lez created, and implemented it like above. Am I doing something wrong? It looks the same without that, just using density perlin0.Evaluate(p) density perlin1.Evaluate(p) density perlin2.Evaluate(p) I want to know what I'm doing wrong, what I misunderstood and how to implement it correctly. This is all based off this lumpn's proceedural generation on github (I would link it, but I can't) Thanks. I would also want to know if there are any examples (I learn best from codebases) with this implementation using shaders. (Maybe it will run faster because it uses the GPU instead of the CPU?) This is still unanswered on how to do it on the CPU (and I'm still confused on how to do it on the GPU, do you have to do some vertex stuff? how do you pass in a noise texture through the shader?)


How to find position of the edge of an object? I have two planes and I want to put both planes one after another so that I can form a road. I set them from the editor and that was very easy but I wanted to do this from code. So in the code void Start() secondRoad.position firstRoad.position But this just set the second plane in the center of the first plane, kind of overlapping. But I want the second plane to be placed next to the first plane where it ends right the edge of the first plane. How will I do this?


How do I refer to a native library with Unity 5 on Android? I have a library called mylibandroid.a. This is given to me by another developer. I also have the iOS version of this lib, and have been able to access it from Unity. It is supposedly built for android. I have included it in my Plugins folder in my Unity 5 project, but I renamed it mylibandroid.so as droid libs use this naming convention. I can see the library included in the .apk file, so Unity seems to know it should go in there. My code looks like this public class AlmoTest MonoBehaviour if UNITY ANDROID DllImport("mylibandroid.so") private static extern void FreeGlobals() public void TestFreeGlobalsButtonPress() Debug.Log("Pressed") FreeGlobals() endif When my function is called, I get this error E Unity ( 4188) Unable to find mylibandroid.so I Unity ( 4188) Pressed I Unity ( 4188) I Unity ( 4188) (Filename . artifacts generated common runtime UnityEngineDebug.gen.cpp Line 56) I Unity ( 4188) I Unity ( 4188) DllNotFoundException mylibandroid.so I Unity ( 4188) at (wrapper managed to native) AlmoTest TestFreeGlobalsButtonPress () I Unity ( 4188) at AlmoTest.TestFreeGlobalsButtonPress () 0x00000 in lt filename unknown gt 0


Unity Messages in Compound Colliders Lets say I have a 2D character with two colliders a circle collider that represents the feet, and a box collider that represents the body. Lets say that the character is currently standing on the ground, i.e. only the feet collider is in contact with the ground collider. According to the Unity manual, I will receive an OnCollisionEnter2D message. That message contains a Collision2D object that contains an otherCollider field of type Collider2D. I don't see anything in that object that would tell me which of the two colliders the body or the feet initiated the message. So my question is this how do you figure out which collider in a compound collider initiated a collision trigger message?


Unwanted rotations with transform.RotateAround I didn't tough i would have issues with this, but unfortunatly I did. I have a Character (which is more a pile of cube) with a body, a empty GameObject for each leg attached to the body with a join and 2 cubes for leg too. The body and the two empty gameobject are child of a Empty gamebject. The 2 cube that represent leg are both child of one of the empty gameObject. What I want to achieve is to rotate the leg around the position of its empty parent by doing this if(Input.GetKey("l")) l leg.transform.RotateAround(l leg.transform.parent.transform.position, new Vector3(1,0,0), 75 Time.deltaTime) unfortunatly, I only want it to rotate on x, but all of the axis are changing, which lead to unwanted rotation. Now, I know rotations aren't independant like translations, but I don't know how to fix this. If possible, i'd prefer to rotate locked joint via script but I have now idea how, I haven't seen anything about it when I looked up 2


Background music not stopping while game is set to paused I am implementing pause game functionality in a Unity3D game using the following script public class PauseGame MonoBehaviour lt summary gt class to pause the game using Time.timeScale and implement the related behaviours associated the game lt summary gt region Fields Boolean variable that informs script if game should be paused or not, false by default. private bool isPaused false endregion region MonoBehaviour Messages At Start, void Start() Whenever 'ESC' key is pressed, toggle 'isPaused' boolean and call SetPause() to pause resume game void Update() if (Input.GetKeyDown(KeyCode.Escape)) isPaused !isPaused SetPause() endregion region Methods A function to pause resume the game public void SetPause() Debug.Log("SetPause") Invert 'isPaused' boolean and convert it into a float variable, being true 1 and false 0f. float timeScale !isPaused ? 1f 0f Set the Time Scale as 1(game runs normally) or 0(game pauses) Time.timeScale timeScale endregion All the game elements pause as expected using the above, except the background music. I can pause the background music by additionally referencing the AudioSource and disabling it while timescale is set to 0. However, I was wondering whether it was a bug. Kindly suggest.


How to create custom inspector to display generic Stack class I have a member that I would like to expose Serializable private sealed class InputGameObjectStack Stack lt GameObject gt public InputGameObjectStack() base( InputGameObjectStackSize) Inside the MonoBehaviour, I have SerializeField private InputGameObjectStack inputGameObjectStack Inside the editor script, I'm able to fetch the property from the MonoBehaviour object (as SerializedProperty), but there is nothing usable that allows me to traverse through the elements. Is there any way of showing the constents of the stack in the inspector as immutable (no functionality to push pop)?


Instantiating Prefabs at run time I'm trying to move my project to Addressables and upload assets, prefabs and screens to an archive on the server. I'm a new in Unity and this a bit challenging for me. I've prepared all prefabs for addressable usage and now I'm trying load them. All my prefabs have loads throw GameObject.Instantiate For example public class PlatformObject LocationObject other properties and methods public PlatformObject Clone() var clone ((Runner.PlatformObject)GameObject.Instantiate(this)) clone.Id this.Id clone.NextPlatforms this.NextPlatforms clone.IsStartPlatform this.IsStartPlatform clone.Level this.Level clone.Type this.Type clone.MinimumDistance this.MinimumDistance clone.AllowDispose false clone.Size this.Size return clone I've tried change this code for usage Addressables. public async Task lt PlatformObject gt Clone() var handle Addressables.LoadAssetAsync lt GameObject gt (this.name) var clone (await handle.Task).GetComponent lt PlatformObject gt () clone.Id this.Id clone.NextPlatforms this.NextPlatforms clone.IsStartPlatform this.IsStartPlatform clone.Level this.Level clone.Type this.Type clone.MinimumDistance this.MinimumDistance clone.AllowDispose false clone.Size this.Size return clone I've got a cloned object successfully, but object doesn't appears on the scene. Looks like object not initialized properly, bcouz I've got a lot of warnings like that Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject 'Mid Town 07'). UnityEngine.Transform set parent(Transform) I've googled and have found a few solution related with parent location. Made changed but it didn't help. I'm still getting those warnings.


Unity3d Do I need to destroy gameobject AND script? From proper leak protection do I need to delete both of these or will getting rid of one take care of both? Currently I am destroying the script AND the gameobject private void OnDestroy() Destroy(this.gameObject) Destroy(this)


Why does the player grab the object outside the trigger zone? I want the player to be able to grab an object (in this case the knife) when he is in the object's trigger zone. He can get the knife but there is a problem if I press grab button outside of the trigger zone, then he can get the knife immediately after entering the zone. I want Unity to get the input only when the player is in the trigger, otherwise it should not be working. Here's the grab script using System.Collections using System.Collections.Generic using UnityEngine public class Grab MonoBehaviour public GameObject player private bool grabbed public GameObject knifePosition private bool isInTrigger void Update() if (Input.GetButtonDown( quot Grab quot )) grabbed true else grabbed false if (grabbed amp amp isInTrigger) gameObject.transform.position knifePosition.transform.position private void OnTriggerEnter2D(Collider2D collision) if (collision.gameObject player amp amp grabbed) gameObject.transform.SetParent(player.transform) isInTrigger true Debug.Log( quot Picked up quot )


ClientDisconnected due to error Timeout UnityEngine.Networking.NetworkIdentity UNetStaticUpdate() Why am I getting this error. I think it has problem with port so I change port number and still getting same error. yesterday it was working fine but when I start today it giving me error like this. ClientDisconnected due to error Timeout UnityEngine.Networking.NetworkIdentity UNetStaticUpdate() I refer this question but, there is not any answer presence for this error.


Moving panel between two positions smoothly? I'm trying to make my panel moving from one position to another one smoothly. What I get is more faster no matter what I did to make it slower never get slow !! Both Vector3.Lerp and Vector3.MoveTowards did not give me a slow movement. Here is my script public GameObject gunsWindow private Vector3 a, b public bool open use inspector void Start() a gunsWindow.transform.position b new Vector3(100.0f, gunsWindow.transform.position.y, gunsWindow.transform.position.z) void Update() if(open) gunsWindow.transform.position Vector3.MoveTowards(a, b, Time.deltaTime 1) weaponPlane.transform.position Vector3.Lerp(a, b, Time.deltaTime) panel shaking else gunsWindow.transform.position Vector3.MoveTowards(b, a, Time.deltaTime 1) weaponPlane.transform.position Vector3.Lerp(b, a, Time.deltaTime) shaking


Using State Pattern with Unity I am new to Game Development and Unity. I have written a component for Jumping and Running, CharacterJumpAbility.cs and CharacterRunAbility.cs. I would like the Character to be able to Jump only if the Character is not moving. I came across a State Pattern but I can't understand how to apply it. For example if I want to Jump, first I must check if the Character is Running, but I have to do this in the CharacterJumpAbility.cs or in the CharacterController.cs (the component who handles inputs)? If I define a state for example public enum CharacterState Run, Jump For example if the player is pressing the space bar, I have to set the Jump state, the code that sets state CharacterState.Jump should be written in the CharacterJumpAbility.cs or in the component that handles inputs? And if I want to set a new state for example Jump, while I am running, this is clearly not possible, how to handle situations like these?


Texturing different block types on an optimized voxel mesh I have a cubic world (like Minecraft) where I'm generating chunks. In those chunks, only visible vertices and faces are generated. Currently, it means that if I have a 2x2x1 chunk, it will generate 8 triangles for the top part (2 for each block). I'm trying to generate only two following this greedy meshing method If I combine adjacent faces together, I'd still like to be able to draw transitions in materials between adjacent blocks, something like this As you can see it has 3 different tiles grass, dirt grass transition, and dirt. Currently, my shader looks like this Shader quot MultiTexture Diffuse Worldspace quot Properties Color ( quot Main Color quot , Color) (1,1,1,1) TexAbove ( quot Above texture quot , 2D) quot surface quot TexSide ( quot Side texture quot , 2D) quot surface quot TexBelow ( quot Below texture quot , 2D) quot surface quot TexTopSide ( quot Top side texture quot , 2D) quot surface quot Scale ( quot Texture Scale quot , Float) 1.0 SubShader Tags quot RenderType quot quot Opaque quot CGPROGRAM pragma surface surf Lambert struct Input float3 worldNormal float3 worldPos sampler2D TexAbove sampler2D TexSide sampler2D TexBelow sampler2D TexTopSide float4 Color float Scale void surf (Input IN, inout SurfaceOutput o) float2 UV fixed4 c if(abs(IN.worldNormal.y gt 0.5)) UV IN.worldPos.xz c tex2D( TexAbove, UV Scale) else if(abs(IN.worldNormal.x) gt 0.5) UV IN.worldPos.yz c tex2D( TexSide, UV Scale) else if(abs(IN.worldNormal.z) gt 0.5) UV IN.worldPos.xy c tex2D( TexSide, UV Scale) else UV IN.worldPos.xz c tex2D( TexBelow, UV Scale) o.Albedo c.rgb Color ENDCG How would I modify this shader to work with faces that have been merged together? Or would I have to keep separate faces per block and handle them individually?


Projector does only affect model I'm working on a simple selection of a RTS unit. Therefore I used a projector to display a circle on the ground around the unit. But it happened, that the circle is only displayed on the head of the unit placeholder, not on the ground. At first I thought it has something to do with the terrain, but as I added a Plane there was'nt a change. I followed the steps from this tutorial http hyunkell.com blog rts style unit selection in unity 5 (skipped the drag box part) Here's a screenshot from the scene I'm wondering how I can solve this. I'll provide every information you'll need.


Issue with multiplayer interpolation In a fast paced multiplayer game I'm working on, there is an issue with the interpolation algorithm. This interpolation is for a moving object not controlled by the local computer. The server sends packets with the object's position at a fixed rate. (red markers) The interpolation algorithm is attempting (and failing) to create a smooth path between the red markers. The results of this interpolation are shown by green and black markers. Green is the local position at the exact time a packet is received, and black is the local position at every frame. Green Local position when a packet is received (edited for clarity) Red Position received from packet (goal) Blue Line from local position to goal when packet is received Black Local position every frame On a network with a realistic amount of lag and packet loss, this is the result The local position (green amp black lines) seems to oscillate around the goals (red lines) instead of moving between them smoothly. This is how it looks on a perfect network with the object moving right to left. (0 ping, 0 packet loss, etc.) The code works like this Every x ms, receive a packet with a Vector3 position Set the goal to that position Set the positionAtLastPacket to the current local position Every frame, lerp from positionAtLastPacket to goal, attempting to reach the goal approximately when the next packet should arrive. If the next packet takes longer than expected, interpolation continues past the goal and becomes extrapolation. I believe what is happening is the extrapolation overshoots a bit to far. Over several packets, this issue compounds, causing the oscillation. local transform position when the last packet arrived. Will lerp from here to the goal private Vector3 positionAtLastPacket location received from last packet private Vector3 goal time since the last packet arrived private float currentTime estimated time to reach goal (also the expected time of the next packet) private float timeToReachGoal private void PacketReceived(Vector3 position, float timeBetweenPackets) positionAtLastPacket transform.position goal position timeToReachGoal timeBetweenPackets currentTime 0 Debug.DrawRay(transform.position, Vector3.up, Color.cyan, 5) current local position Debug.DrawLine(transform.position, goal, Color.blue, 5) path to goal Debug.DrawRay(goal, Vector3.up, Color.red, 5) received goal position private void FrameUpdate() currentTime Time.deltaTime float delta currentTime timeToReachGoal transform.position FreeLerp(positionAtLastPacket, goal, currentTime timeToReachGoal) current local position Debug.DrawRay(transform.position, Vector3.up 0.5f, Color.black, 5) lt summary gt Lerp without being locked to 0 1 lt summary gt Vector3 FreeLerp(Vector3 from, Vector3 to, float t) return from (to from) t Any idea about what's going on?


Calculating the weight of an object irrespective of the triangle or vertices count in Unity I have a meat piece which I want to weigh. Now there can be anything like fish, cheese, or other items that we can cut and measure. I want the weight to be determined by myself instead of determining from getting the surface of the item as it varies with different tris count. Currently, I am calculating the weight from the following code. public static float CalculateSurfaceArea(Mesh mesh) var triangles mesh.triangles var vertices mesh.vertices double sum 0.0 for (int i 0 i lt triangles.Length i 3) Vector3 corner vertices triangles i Vector3 a vertices triangles i 1 corner Vector3 b vertices triangles i 2 corner sum Vector3.Cross(a, b).magnitude weightMultiplier is a constant value for getting a reasonable weight value. return (float)(sum 2.0) weightMultiplier So if there's a meat piece like bellow and I want it to be a weight of let's say 3kg(6.6lb) then when I cut it into half it should give me values respectively (1.5kg). So I want the weighing factor to be in my control so that if in the future we have really detailed high poly items the weight shouldn't get affected by that.


How can I support many point light sources in a dynamically generated level in Unity? I'm currently working with a dungeon game which is similar to Dungeon Keeper by Mythic Entertainment. I'm using Unity and developing this game for Ipad 2 and above. Player can modify his dungeon, and I'd written a dungeon generator which creates it. In this case, I can't use lightmaps, because the dungeon has been created dynamically and player can tweak it. I also devised a way to combine separate game objects in a single mesh, so imagine that the entire dungeon (except special objects such as pillars, statues and mobs) is the single mesh. There's many point light sources (10 15 and above) on the stage, but Unity don't allow to use more than 8 light sources per object. So, if all dungeon cells are separated objects, I can use the diffuse or even vertex lit lighting, but if the entire dungeon is a single mesh, there's the hardware limit appears. Ways to solve this problem I'd divised Use separated geometry (tried) bad, because it harms berformance because there's many many many drawcalls (16 17 fps on Ipad 4). Use deffered shading (tried) bad, because it harms performance even more than separated geometry. Use a custom shader (haven't tried) I don't know how. Don't unite all cells in the single mesh but unite groups of cells to reduce the number of separated objects (haven't tried) Use the light manager (haven't tried) I don't know how. ??? How can I deal with it?


How can I get sensor data on iPhone onto a Windows PC? For use as a steering wheel I am making a Unity game. I want to be able to allow the phone to be used as a steering wheel, as input into the PC game. Technically, How can I achieve this? Can this be done through bluetooth? Thanks


How can I distribute the source code of my project without the imported assets? I have a Unity project that uses some assets that I downloaded for free in the Unity asset store. I would like to make my project open source and distribute its source code in GitHub. But, I do not want to put the assets I downloaded in my GitHub, since they are not mine. Also, these assets take a lot of space in my repository. Can I arrange my project in such a way that any user who downloads it will be automatically sent to the Unity asset store to download the required assets? I found that it works well with TextMesh Pro I can remove the TextMesh Pro folder from my Assets folder, and then when I open the project in Unity, it prompts me to re import TextMesh Pro, and when the import is done, the game works well. Is it possible to achieve a similar effect with other assets?


Using DLL's for a cross platform Unity Game Just a quick theoretical question so I don't hit a landmine further down development. In my current project, I have quite a lot of dll's that I made myself for use in Unity. If I were to develop for Android, would these dll's still function or is there another library format that Unity prefers to use? Basically, I'm looking for a rundown of all the ways you have to import libraries into Unity for use on a specific platform. For example, 1.) .dll files. Can you use them on other platforms? 2.) If not, how would I have to recompile code to allow me to access it the same way I currently do on a different plaform?


Why are there weird texture artifacts in baked light which don't appear with realtime light? This is the comparison of the same scene, realtime light vs baked light. What's am I wrong ? EDIT In particular, also texture are low quality (see image 2). Why ?


Procedural Islands Voronoi Pattern I'm trying to keep this as simple as possible, as I've found out the last few days this is a very difficult topic. I'd like to generate multiple flat islands, formed by a voronoi diagram. I've followed a long and (for me) difficult tutorial of building a procedural hexagonal grid just to find out it looks to artificial. I'd like to create a plane with faces divided in a voronoi diagram, and extrude multiple groups upwards to create islands. With that I'd like to achieve something similar as this http applemagazine.com wp content uploads 2015 10 image2.jpg Please help to get me started in the right direction, since my approach might be wrong in itself. EDIT I've found this https github.com jceipek Unity delaunay. Which draws lines in a voronoi diagram. Now I'm guessing the next step is to convert this to a mesh. Then I'd have to highlight random faces to be extruded to create the islands. Maybe this could be done with perlin noise, which I've just learned about. Extruding might not be the best way. Maybe deleting the faces that won't be land, and creating fall of edges (Like Wardy said). I'm doing my best to figure this out on my own, but any help is greatly appreciated.


Get all supported resolutions for a monitor I've been receiving complaints from users that my game doesn't support the 16 10 aspect ratio. Currently I list everything in Screen.resolutions in a dropdown and allow the user to pick from that. I have since come to the understanding that the first element is not necessarily the native resolution of the monitor. I've found the Display class but this appears to only give the native resolution, not all scaled resolutions. E.g. if the monitor is 1920x1080 then I need a list of 1600x900, 1280x720, 640x360 etc. I thought about just multiplying by some scale factor but then I'm afraid I'll get something obscure like 885x497.8. And if I have a pre determined list of resolutions for a specific aspect ratio, how do I support obscure aspect ratios like widescreen for example.


Where to put rigidbody on a car model ? I have a GameObject car like this MyCar Body with mesh collider Wheel Left with wheel collider Wheel Right with wheel collider ... and so on Where I have to put rigidbody ? Thanks


A Pathfinding lose target after spawning from script? I have been using A Path finding to enable object tracking. It works fine if I have both objects on the scene at the same time. However, if I were to use a script to spawn the seeking object instead, it will only track the first path to the object and not repath again. I am using the default AI Follow script and a prefab variable as the object to be tracked (which is an empty child game object to a moving character). Code import Pathfinding var tankTurret Transform var tankBody Transform var tankCompass Transform var turnSpeed float 10.0 var targetPosition Vector3 var seeker Seeker var controller CharacterController var path Path var speed float 100 var nextWaypointDistance float 3.0 private var currentWaypoint int 0 function Start() targetPosition GameObject.FindWithTag("GTO").transform.position GetNewPath() function GetNewPath() Debug.Log("GETTING NEW PATH!") seeker.StartPath(transform.position,targetPosition,OnPathComplete) function OnPathComplete(newPath Path) if(!GetNewPath.error) path newPath currentWaypoint 0 function FixedUpdate() if(path null) return Debug.Log("NO PATH!?") if(currentWaypoint gt path.vectorPath.Length) return var dir Vector3 (path.vectorPath currentWaypoint transform.position).normalized controller.SimpleMove(dir) tankCompass.LookAt(path.vectorPath currentWaypoint ) tankBody.rotation Quaternion.Lerp(tankBody.rotation, tankCompass.rotation, Time.deltaTime turnSpeed) if(Vector3.Distance (transform.position,path.vectorPath currentWaypoint ) lt nextWaypointDistance) currentWaypoint Any help will be greatly appreciated.


Check if vertex is visible in shader Im trying to figure out when a vertex is visible from the main camera. I have this function bool in frustum(float4x4 M, float4 p) float4 Pclip mul(M, float4(p.x, p.y, p.z, 1.0)) return abs(Pclip.x) lt Pclip.w amp amp abs(Pclip.y) lt Pclip.w amp amp 0 lt Pclip.z amp amp Pclip.z lt Pclip.w I call it in the vertex shader, and it works fine. The problem is when I have multiple cameras, and I only want to know if it is within the frustum on one of the cameras. If the vertex is not visible from my target camera, I want all other cameras to render it (if it is visible) a particular way (for example red). I am a little rusty on matrix transformations and the graphics pipeline, but maybe instead of passing UNITY MVP MATRIX into the in frustum function, I need to pass in the MVP matrix of the target camera? Or maybe just the View of the target camera needs to be replaced in.


How can I rotate a Transform over a specified time in a single line of code? How can I rotate a Transform over a specified time in a single line of code? I have had a lot of trouble with this in the past. I wrote a script which rotates a Transform by a specified rotation over n seconds, or rotates a Transform towards a Vector3 over n seconds, in a one liner. I hope it helps others in the future. See below.


3D Studio Max biped restrictions? I have a stock biped character in 3D studio max which has a jump animation. The problem I have with the jump animation is that there is actual y offset happening inside it which makes it awkward to play while the character is jumping since it's not only jumping in the game world but the jump animation is adding its own height offset. I'm tryuing to remove the jump animations height offset, so far I've found the root node and deleted all its key frames which has helped a bit. The problem I'm having now is that the character still has some height offset and if I try to lower it it has a fake 'ground' that isn't at 0 and the limbs sort of bend on the imaginary floor, si there a way to remove this restriction just for the jump animation? Here's what I mean http i.imgur.com qoWIR.png Any idea for a fix? I'm using Unity 3D if that opens any other possibilities...


Unity 2D map and walkable collisions I have a 2d player who can only walk on black area. There is a red collider so player can't walk past it. Player has capsule collider. The problem is player can't walk toward the edge with his feets becasue of the it's collider. But player would probably want to walk toward the edge. Here is a sketch I've made. Is there a way to tweak this ?


How can I attract repel the mouse cursor from particular UI controls? This question came from some of my students. I wanted to share it here so others can find amp improve on the solutions we've found so far. In particular, my answer below doesn't behave as well as I'd like in windowed editor mode UI buttons no longer respond to hovering the cursor. I welcome alternative answers that solve this more completely. We're making a visual novel game using the Fungus asset for Unity. We want to add a twist where some dialogue options are easier or harder to press, because they attract or repulse your mouse cursor. Unfortunately, we haven't been able to identify a cross platform way to manipulate the mouse's position, nor a way to create a "Fake" mouse cursor image that can still interact with Fungus's UI buttons. How can we pull this off?


Target Lower API Level than Package or Plug In Requirements I am working on a project that I want to use local mobile notifications for Android using Unity as game engine. I want to reach as much as users I can, so I want to target API level 16 for the lowest Android API level. As expected, when targeting Android API level 16 for a build, build fails with that error Execution failed for task ' processReleaseManifest'. Manifest merger failed uses sdk minSdkVersion 16 cannot be smaller than version 19 declared in library androidnotifications release C Users Tumay Varel.gradle caches transforms 2 files 2.1 71d39d4badfde5815e850866bcf079c9 AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion use a compatible library with a minSdk of at most 16, or increase this project's minSdk version to at least 19, or use tools overrideLibrary "com.unity.androidnotifications" to force usage (may lead to runtime failures) In documentation , it is explicitly saying that the package supports Android 4.4 (API 19) and higher API levels. I can handle this problem by targeting lowest API level 19, however I want to ask Is there a way to use this package or any other package or any plug in for required and higher API levels while not using for lower API levels than requirement at the same project?


Unity won't Instantiate() outside of Start(), even though code is the same I am trying to add a gameobject to my game using a socket connection. I have a SocketHandler class, which simply connects to my NodeJS socket server, which can also call a method on another class, which will add a new gameobject to the game. Here is how it basically works void Start () GameObject car Instantiate(CarGameObject) car.transform.parent this.transform car.GetComponent lt TestCar gt ().text.text "Volkswagen" This works fine and it adds the gameobject to the game upon starting. However, if I do something like this in my SocketHandler, it doesn't work var addCar new AddCar() socketio.On("addCar", (data) gt string str data.ToString() Car data2 JsonConvert.DeserializeObject lt Car gt (str) addCar.AddNewCar(data2) ) and then inside my AddCar class, I have the AddNewCar() method public void AddNewCar(Car input) GameObject car Instantiate(CarGameObject) car.transform.parent this.transform car.GetComponent lt TestCar gt ().text.text input.name it does not work. If I do a Debug.Log(input.name) inside the AddNewCar() method, it does log the name the server sends. It should do the exact same thing, but the AddNewCar() doesn't get added to the game. It simply does nothing. What could be wrong?


smoothly recenter view over time I'm currently using the Google Cardboard SDK for Unity to build a fighter pilot simulator. What I'm currently trying to do is recenter the view(CardboardHead) smoothly over time when the user looks away from the screen. This is because I want to put HUD elements out of the main central view that can be quickly seen with a "head jerk". I don't want to let the camera be free from constraints because I feel piloting is much better when the view is fixed and doesn't wobble about with every slight movement of the player's head. The Head already has a horizontal constraint that does not allow any later movement, but now I want to put a semi constraint on the vertical axis so that the player can quickly look up or down to see something like i.e. a fuel economy indicator and then have the view quickly "follow his gaze" and recenter itself. I noticed that the Cardboard plugin already does this type of constraint on the Head roll input when playing "in editor" and works as follows When you press and hold Ctrl and move the mouse left right the view rolls left right. Upon release of Ctrl the view smoothly rolls back to 0. This is the code in the Cardboard script bool rolled false if (Input.GetKey(KeyCode.LeftControl) Input.GetKey(KeyCode.RightControl)) rolled true mouseZ Input.GetAxis("Mouse X") 5 mouseZ Mathf.Clamp(mouseZ, 80, 80) if (!rolled amp amp autoUntiltHead) People don't usually leave their heads tilted to one side for long. mouseZ Mathf.Lerp(mouseZ, 0, Time.deltaTime (Time.deltaTime 0.1f)) var rot Quaternion.Euler(mouseY, mouseX, mouseZ) var neck (rot neckOffset neckOffset.y Vector3.up) NeckModelScale headView Matrix4x4.TRS(neck, rot, Vector3.one) How could I implement this for vertical rotation of the Head? In the Update method of the script that controls the Head it simply does transform.localRotation Cardboard.SDK.HeadRotation This is what I've tried but it doesn't really do anything except some jerky movements transform.Rotate(new Vector3(Mathf.Lerp(rot.eulerAngles.x, 0, Time.deltaTime (Time.deltaTime 0.1f)),0,0)) (I put this in the same Update function for the Head after the above line) Any ideas??


How do I get the position and rotation of an animated object in Unity? I have this object which is being animated, the animation moves a arm and hand. I want it to look like it's holding something but I can't move the object to the hand because even though the animation appears to move the world position of the animation object stays the same, the objects parent is the hand but it's still not moving to it. So how do I move the object to the animations hand while it's being animated in unity? Maybe this could help to visualize what my problem is I found another way around the problem attached the object as a child of the bone instead of the hand mesh. I still don't know why it didn't move with the hand.


Should I use a database to store 10 000 names in a sports game? I'm working on a single player sports game for a year or so and this doubt came up how should I treat store big amounts of data, like player names. Let's take an arbitrary number as example 10000 names, 5000 first names and 5000 surnames. These names would be equally divided between 100 countries, which give us 50 first names and 50 surnames per country. Should I have a local database with these names (or even these countries) considering this data will be needed to generate new players names during the course of the game? Would that introduce limitations, considering I want to make my game moddable by players, as much as possible? These doubts can be extended to other, more complex game entities, such as Players each one with their own face, attributes, team etc... Teams each one with its own crest, kit, squad etc... In my previous research about that, the SQLite popped up as a seemingly viable solution. It happens that I have almost no experience with DB's (specially in games) and would like to know if this is a good direction before start to study and try to implement it.


how to switch cameras with one button? using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class cameraswitch MonoBehaviour public Camera cam1 public Camera cam2 void Start () cam1.enabled true cam2.enabled false Button Button gameObject.GetComponent lt Button gt () Button.onClick.AddListener(baz) void baz () cam1.enabled false cam2.enabled true this is my code . how to switch between the cameras with one button . and Thank You.


How to link my weapons with their corresponding ammo supply in the Unity Inspector? In my game I would like to implement a universal ammo and weapon system that would be usable for any kind of weapon. So I declared an ammo class using System.Collections using System.Collections.Generic using UnityEngine System.Serializable public class Ammo public int MaxAmmo public int CurrentAmmo public Ammo(int maxAmmo) MaxAmmo maxAmmo public void MaxOutType() CurrentAmmo MaxAmmo public void GetAmmo(int amount) CurrentAmmo amount public void UseAmmo(int numOf) CurrentAmmo numOf Then I created a script to hold different Ammo types using System.Collections using System.Collections.Generic using UnityEngine public class AmmoSystem MonoBehaviour SerializeField public Ammo Basic new Ammo(200) public Ammo Rockets new Ammo(50) public Ammo AirRockets new Ammo(75) public Ammo Cells new Ammo(150) To organize my project I decided to make two weapon scripts one for nonphysical(Raycast) projectiles called RaycastingWeapon and an another for physical ones(like a rocket launcher) called PhysicalProjectileWeapon My plan was to create unique weapons using these two scripts from the inspector. These would use different kinds of ammo but would share the same script with different properties. The essential aspect here is that I would like to be able to select an ammo type from the inspector using a dropdown menu for example. Is it possible somehow or are there a better way of doing that?


Is async image loading possible? Can anyone tell me if there is a async version of LoadImage() method? I found about Resources.LoadAsync, however the method doesnt work. Thank you


How do I find the name of the current audio clip being played? I have a title scene and a credits scene that use the same music. When I start my game the title scene music plays, and I have my game set up so the audio manager is not destroyed on load. When I enter my credits scene I do not instruct any new music to play, but each time I reload my title scene the title music restarts because a script in the scene tells it do so. How can I get the name of the current audio track so that I will only play audio if it differs from what's currently being played? This is my "LevelMaster" script which is responsible for handling the audio in each scene. public class LevelMaster MonoBehaviour private AudioManager AudioManager SerializeField private string trackName private void Start() AudioManager GameObject.Find("AudioManager").GetComponent lt AudioManager gt () AudioManager.Play(trackName) public void PlaySound(string soundName) AudioManager.Play(soundName) public void StopSound(string soundName) AudioManager.Stop(soundName)


How can I avoid updating my Unity projects when I have two versions installed? I currently have two versions of Unity on my Windows computer. I would like to not update my projects to avoid compatibility issues like I had in the past. Installation in another folder goes just fine, but when I try to open Unity, it says that another Project is already opened and that if I want to continue I must update it. If I close this window, Unity aborts as well. Is there a way to avoid this behaviour?


How do I safely change properties on my skybox? Usually in Unity, when your scripts make changes to something at runtime, those changes are not persisted back to design time. This is generally considered a good thing. But for whatever bizarre technical reason, this does not apply to shader properties on materials. If you change something while the game is running, it stays changed! Generally the way to get around this is with a MaterialPropertyBlock, which also helps avoid generating a lot of garbage. But MaterialPropertyBlocks work with Renderers, which leaves out one rather important material the skybox. Right now, I have code that says RenderSettings.skybox.SetFloat( quot PropName quot , value) , and it's incredibly aggravating because it always needs to be reset afterwards. RenderSettings doesn't have a SkyboxRenderer property that I can use in conjunction with a MaterialPropertyBlock, so how can I change shader settings on my skybox and make them not persist after I exit play mode?


How to distort 2d perlin noise? I am using Unity's 2D Mathf.PerlinNoise(x, y) function and I would like to make it distorted. What I mean is described with this picture I made How can I do that? What transformations should I apply to Mathf.PerlinNoise(x, y) to achieve this effect?


Why doesn't the Camera.pixel(Height Width) match the Canvas size? I am making an app that has a custom viewport Rect like so When I check the sizes of this viewport rectangle in pixels with Camera.pixelHeight Camera.pixelWidth, I get the following values 743px, 770px. This looks correct. Now when I check my canvas in the Editor, I see the following values for the width and height Now I have a script that gets the width and height of the canvas. This is correct I get again the 743px and 770px. But when I position my UI element, it is outside because the positioning refers back the the incorrect values displayed in the canvas rectangle transform properties. What is happening here and how do it make the canvas use the correct values?


How can i scale a cube on one side on x only? I have in the Hierarchy a empty GameObject and a cube as child of it. The cube the child is at position 0,0,0 and scale 1,1,1 But when running the game the scaling is on both sides of the cube. I put the cube as child of the empty gameobject and scaling the empty gameobject but still it's scaling the cube on both sides. The script is attached to the empty GameObject using System.Collections using System.Collections.Generic using UnityEngine public class Walls MonoBehaviour Vector3 originalScale Vector3 destinationScale void Start() originalScale transform.localScale destinationScale new Vector3(100.0f, 0, 0) private void Update() if (transform.localScale.x ! 100.0f) transform.localScale new Vector3(1, 0, 0) This is a working solution using System.Collections using System.Collections.Generic using UnityEngine public class Walls MonoBehaviour public Transform objectstoScale private void Update() if (objectstoScale 0 .localScale.x ! 100.0f) objectstoScale 0 .localScale new Vector3(1, 0, 0) But i want to make that the same cube will also scale one side on the z. So the cube will be scaled on both x and z but without filling it one be like frames. So i tried this using System.Collections using System.Collections.Generic using UnityEngine public class Walls MonoBehaviour public Transform objectstoScale private void Update() if (objectstoScale 0 .localScale.x ! 100.0f) objectstoScale 0 .localScale new Vector3(1, 0, 0) objectstoScale 1 .localScale new Vector3(0, 0, 1) And i have now two cubes childs of the empty gameobject one cube position is 0.5,0,0 the second is 0,0,0.5 but what i'm getting is What i want to do is to create automatic a rectangle scaling a cube on 4 sides at the same time not filled rectangle. For example like this


unity2D swipe control's bool for animator doesn't work i was trying to make a control where the animation plays upon swiping one direction. each time i've make a tap swipe control, it just keeps popping messages like this. the tap animation works fine, but the animation for swipe controls just doesn't work well, the bool for them has assigned but did not make it 'true' when i swipe a direction, but the bool for the tap works, which is weird.(ignore the miss bool in the animator) it says that i need to assign the anim variable of the Swipe script in the inspector. but there is nothing left for me to assign, which doesn't make much sense for me. (refer to Region Animation) i've tried to make some adjustment with the script, but the results is the same, and it has no problems when build. which is why i need help for the animation stuff. using System.Collections using System.Collections.Generic using UnityEngine public class Swipe MonoBehaviour public Animator anim public bool tap, swipeUp, swipeDown, swipeLeft, swipeRight public bool isDragging false public Vector2 startTouch, swipeDelta private void Update() tap swipeUp swipeDown swipeLeft swipeRight false region Standalone Input if (Input.GetMouseButtonDown(0)) tap true isDragging true startTouch Input.mousePosition Debug.Log("Tapped") else if (Input.GetMouseButtonUp(0)) isDragging false Reset() endregion region Mobile Inputs if (Input.touches.Length gt 1) if (Input.touches 0 .phase TouchPhase.Began) tap true isDragging true startTouch Input.touches 0 .position else if (Input.touches 0 .phase TouchPhase.Ended Input.touches 0 .phase TouchPhase.Canceled) isDragging false Reset() endregion region Animation if (Tap) anim.SetBool("Tap", true) if (SwipeDown) anim.SetBool("Down", true) if (SwipeUp) anim.SetBool("Up", true) if (SwipeLeft) anim.SetBool("Left", true) if (SwipeRight) anim.SetBool("Right", true) endregion calculating the distance swipeDelta Vector2.zero if(startTouch ! Vector2.zero) if (isDragging) if (Input.touches.Length gt 0) swipeDelta Input.touches 0 .position startTouch else if (Input.GetMouseButton(0)) swipeDelta (Vector2)Input.mousePosition startTouch did we cross the deadzone? if (swipeDelta.magnitude gt 125) which direction? float x swipeDelta.x float y swipeDelta.y if (Mathf.Abs(x) gt Mathf.Abs(y)) left or right if (x lt 0) swipeLeft true else swipeRight true else Up or down? if (y lt 0) swipeDown true else swipeUp true public void Reset() startTouch swipeDelta Vector2.zero isDragging false anim.SetBool("Tap", false) anim.SetBool("Down", false) anim.SetBool("Up", false) anim.SetBool("Left", false) anim.SetBool("Right", false) public Vector2 SwipeDelta get return swipeDelta public bool Tap get return tap public bool SwipeUp get return swipeUp public bool SwipeDown get return swipeDown public bool SwipeLeft get return swipeLeft public bool SwipeRight get return swipeRight


Unity OnRenderImage hides UI I have a component which renders a few different cameras and the images. However, this obscures my UI when in Screen Space Overlay mode. I can put the canvas in WorldSpace mode, which works, but then the UI is affected by the image effect I've built and is, of course, not locked to the camera. Suggestions? Update additional details At design time, the OVR camera rig contains a single camera centered between the "eyes." This component is attached to the camera rig's centerEyeAnchor. At run time, the rig creates two additional cameras one for each eye. These aren't supposed to be modified by user code. (Among other things, their projection matrices are pretty weird.) I need to modify the image per eye. I created a new component which create two additional cameras per eye. One renders a low res version of the entire scene, the other renders a high res image of a portion of the screen, each to a dedicated RenderTexture. Pseudocode void Update() called once per frame called twice per frame once per eye void OnPreRender() called twice per frame once per eye void OnRenderImage(RenderTexture source, RenderTexture destination) low res render of entire scene var camOuter m cameras ... hi res render of part of the scene 10 20 of original image area var camInner m cameras ... update cameras to match current eye camera camOuter.copyFrom(Camera.current) camOuter.targetTexture m outerTexture render scene to low res texture camOuter.Render() camInner.copyFrom(Camera.current) camInner.targetTexture m innerTexture target texture that the Oculus wants to render to var ovrTexture Camera.current.targetTexture save projection matrix var originalProjectionMatrix camInner.projectionMatrix var scale new Vector3(m innerTexture.width 1.0f ovrTexture.width, m innerTexture.height 1.0f ovrTexture.height) zoom pan matrix to clip to part of the scene var gazeMatrix Matrix4x4.Scale(scale) offset projection gazeMatrix.m03 (1 2 gaze.x) scale.x gazeMatrix.m13 (1 2 gaze.y) scale.y camOuter.projectionMatrix gazeMatrix amp originalPRojectionMatrix render hi res portion of the scene centered at gaze pixel camOuter.Render() restore projection matrix cam.projectionMatrix originalProjectionMatrix composite images m material.SetTexture("InnerTexture", m innerTexture) m material.SetTexture("OuterTexture", m outerTexture) Graphics.Blit(null, destination, m material) (I'm also worried that there may be additional scene renders happening in the background.) The problem is that the UI does not render if set to Screenspace Overlay or Screenspace Camera. I can get it to render in Worldspace, which may be the only way to do this, but then it seems I'd need to create yet another hi res texture matching the viewport dimensions and render the UI layer to that, and keep it locked to the current eye's camera position. Alternatively, I could re use one of the current cameras, I guess, and just tweak its settings. Is there a better way to do this? Ideally, I'd like to have the engine just render the UI as it does in other applications without having to jump through hoops. However, at this point, I'll take anything I can get that works and looks good. Update the 2nd Okay, it looks like the UI is rendered perfectly if I use a regular camera instead of the OVR rig. ( Having the rig in the scene, though, prevents it from drawing at all.


How to make a cartoon like trail particle system? I'm currently working on an little Android game, it's a reaction casual game. Because the user needs to tap some balls flying around at the right moment, I want to add some new effects to them. So I looked at some other games and found this cool looking cartoon like effect. As you can see the ball there has an cool tail. So my question is, does anyone know how to recreate such a trail with the Unity particle effects or some other tools?


Unity 5 Texture Material rendering issue I am working on a Minesweeper clone that started as a Unity 4.6 project and ended up as a Unity 5 project. I have cube objects that use Legacy Shaders Diffuse. I am new to Unity 5, so I am not fully aware of the changes to the shaders. The following texture on cube objects does not render as it is (I think it used to). I want the flag appear on the cube as it is. What causes this output and how do I fix it?


No intellisense on my classes I've been using Monodevelop's current version and Unity 4. I don't get intellisense on the classes I've created but I do have intellisense on classes that are in Unity's framework. Bug or its just as it is? I use UnityScript class SomeClass extends ScriptableObject public function Test() return "" In another class, when I use a variable typed as this class I get no intellisense.


Unity Display array of Objects in inspector I have an array of ScritableObject's, which should only be displayed in the inspector if a boolean is true. How would I do this? With my current code, I get an error saying Cannot implicitly convert type Tile to Tile This is my current code using System.Collections using System.Collections.Generic using UnityEditor using UnityEngine CreateAssetMenu (fileName "Data", menuName "Tiles Map", order 1) public class Tile ScriptableObject public ETile eTile public Sprite sprite Space(5), Header("Variety") public bool variety Range(0f, 1f) public float varietyChance public Tile varietyTiles lt This should be hidden if variety is true public enum ETile Water, Grass CustomEditor(typeof(Tile)) public class MyScriptEditor Editor override public void OnInspectorGUI() var tile target as Tile tile.variety EditorGUILayout.Toggle("Hide Fields", tile.variety) if (tile.variety) tile.varietyTiles (Tile)EditorGUILayout.ObjectField("Tile", tile, typeof(Tile), allowSceneObjects true)


How to instantiate GameObject on client without network? When I NetworkServer.Spawn(ob) a gameobject and make it a child of a transform.parent after it spawns on both the server and client it usually lags, meaning it takes some secs to align with the transform.parent which is the player Example Instantiating a GameObject containing a ParticleSystem which gives the parent somewhat an effect, smoke or something in that direction, in the host client every object usually has a smooth movement where as in the connected client it goes very rough and slow, like every gameobject having a low fps except the main client player prefab So i was thinking spawning the same effect on both clients so it wouldn't have to sync from the server to the client which uses it instead it only would have to sync inside the clients game, it might not have the same particle movements but it wouldn't make a difference Here's the child's prefab network identity and transform


How to stop an animation on last frame until condition is met in Unity? I have an animation (fishing) I want to play backwards when the player catches something or cancels the action. Playing the animation backwards is as simple as setting the speed to 1, ie anim.SetFloat("direction", 1.0f) However, my fishing animation keeps playing until I have caught something, or cancel the animation. This means that the last frame of the animation is showing, but the time of the animation is still going. So the animation reaches the last frame then I stand there for 8 seconds, I catch something, so I change anim speed to 1 anim will now reverse those 8 seconds I was "standing still" first, before it even reaches the actual animation. I need to stop the animation time on the last frame (without leaving the animation), so that reverse will be instant. And to not exit the animation until the reverse is finished. Maybe there is some other way to do it, but I can't figure it out. I could create a seperate animation for when I want it to go backwards, but that seems sloppy.


How do I move a Unity object with velocity instead of force? I have a 2d car in Unity that I want to move, but Unity does this using relative force amp I want to use velocity. As we know if we add force, an object will move and never stop. I want to use velocity to control movement, because then the car will stop when its velocity is zero. using System.Collections using System.Collections.Generic using UnityEngine public class GamePlay MonoBehaviour public GameObject player public Rigidbody2D rb public float speed, steering void Start() void FixedUpdate() rb.AddRelativeForce(Vector2.up speed) rb.velocity Vector2.up Touch touch Input.GetTouch(0) if (Input.touchCount gt 0) if (touch.phase TouchPhase.Moved) Vector2 v Camera.main.ScreenToWorldPoint(touch.position) float pos touch.position.y player.transform.Rotate(0, 0, pos steering)


How to make a 2D semicircle sprite in Unity? I followed this answer https answers.unity.com questions 1008644 semi circle 2d collider.html and was able to create a semicircle collider But is there any way I can just crop the circle sprite to make it a semicircle? I tried looking for other documentation, but couldn't find any..


Unity2D Rendering multiple sprites as a single one I'm creating NPCs in Unity 2D using C , and I have 16x16 sprites for body, helmet, clothes and weapon. All these have a tile set which has been split in unity. I'd like to be able to render one of each part together, so I can drag the sprite to the field, and then it will be rendered on the NPC. IE, I drag a helmet sprite into the helmet field and that is the rendered helmet. I intend on having multiple NPCs, so I'd prefer to minimise the child objects. Multiple sprites will need rendering, however there's only one sprite renderer. Is it possible for me to combine the sprites (in code), and then render the final sprite? Or is there perhaps a better way? Thanks in advance!


Disabling, overriding or hooking a VS warning to Unity's Vector's ToString()? I've just spent 2 hours debugging a misbehaviour because ToString() truncates to 1 digit by default. I want to disable the parameterless version so I won't use it by accident and I will always have to define how much truncation I want. Or if this isn't possible I want to redefine it, so it will truncate to 3 digits for example. Or somehow hook a custom warning to it, so Visual Studio will tell me that I'm using it? Is this possible?


Exported shapekeys to unity don't play correctly (unity 2019 blender 2.79) Hopefully someone can shed some light on this I select all relevant parts of the mesh and armature etc and export to FBX 7.4 for use in Unity3d The model itself displays fine and so does the armature animations but the shapekeys come out really weird. Any ideas or do you need more info?


How can I stop this fixed update from executing so I want this FixedUpdate() Method to stop executing when the Method OnMouseDown() is executed. A bool doesn't work a if() statement also doesn't work Please use my whole code Please help ) Thanks, private void FixedUpdate() int random Random.Range(1, 4) if (random 1) m SpriteRenderer GetComponent lt SpriteRenderer gt () m SpriteRenderer.color Color.green if (random 2) m SpriteRenderer GetComponent lt SpriteRenderer gt () m SpriteRenderer.color Color.blue if (random 3) m SpriteRenderer GetComponent lt SpriteRenderer gt () m SpriteRenderer.color Color.yellow private void OnMouseDown() shouldexecute false


Unity AI issue with recalculating NavMesh at runtime I am using Unity NavMesh to control my units. I am running into an Issue when updating Navmesh at runtime, It seems agents re calculate their path whenever it is modified, which makes sense, but it causes this line (check if unit is on last corner) to return an IndexOutOfBounds error agent.steeringTarget agent.path.corners agent.path.corners.Length 1 I guess something is happening while re calculating path that might mess with this for 1 frame. I solved this by putting a try catch around it, but is there some better way I can manage this so I don't get the error at all?


Unity3D Using AddRelativeForce to push an object forever in zero gravity environment Ok, I use AddRelativeForce to basically push an object. But it suppose to keep flying and keep accelerating as I hold down the key because I didn't set gravity. I just started Unity3D last month, so pls give me some advice. Force of individual thrusters public float thrusterForce 10000 Whether or not to add force at position which introduces torque public bool addForceAtPosition false private bool thrusterIsActive false private Transform objectTransform private Rigidbody objectParentRigidbody void FixedUpdate() if (thrusterIsActive) if (addForceAtPosition) objectParentRigidbody.AddForceAtPosition (objectTransform.up thrusterForce, objectTransform.position) else objectParentRigidbody.AddRelativeForce (Vector3.forward thrusterForce)


2D physics on game object made up of components Say you want to let your users create a 2D airship (side view) made up of components. One component could be a floating balloon, another could be a storage room, etc. And say you want this airship to have physics applied to it as a whole, with each component playing a part in this. For example, balloons would take away from its down force and other compartments would apply down force to it. At the same time, the whole airship works as a whole (or at least the only physical separation would be between floater components and the others, which apply weight), so physics are applied to it as if it was one body. Now, how can this be managed? How can I customize a game object via a script, giving it different components with different weights, and have it behave like it was a single premade object? I'm sorry if the question is simple, but I'm only getting started with unity. Thank you very much! TL DR Customizable airship gameobject with different components that have different weights. How to make it behave as a single physics entity and manage its different components?


Is there any way to use events without breaking class and component separation? I just started using events, and got stuck a little. I have a problem with the following code class InputHandler public delegate void Shooting() public static event Shooting OnShoot void Update() if( fireButtonPressed) OnShoot() Rest of the class. class Weapon void Shoot() Do the shooting. void OnEnable() InputHandler.OnShoot shooting void OnDisable() InputHandler.OnShoot shooting class UI void UpdateBulletsCount(int bulletsLeft, int magSize) Update the UI. void OnEnable() InputHandler.OnShoot UpdateBulletsCount clearly can't do that. void OnDisable() InputHandler.OnShoot UpdateBulletsCount My UI class has a method to update the bullet count when you fire, reload or change the weapon. As you can clearly see, it takes in different parameters. This allows me to change the UpdateBulletsCount() to accept no parameters, and find the weapons info through GetComponent or Find, in order to update UI. However, then the UI class will depend on the Weapon class, which breaks the separation of classes and components that I am trying to achieve. Is there any way to use events without breaking class and component separation?


Trouble creating fog and lighting in unity I am trying to create a model in unity that looks like this picture by Escher I can create the lattice, however, I can not create the fog and background lighting effect. When I adjust the fog in Lighting the cubes just get more of the supposed fog color. Also I don't know how to eliminate the sky and make the lighting more like it is in the picture. Does anybody know how to great the fog and lighting effect I am looking for Thanks I previously posted this on unity Q and A and got no answer I can not post my other image with no fog because i do not have enough reputations. It is basically the image I posted just with more shadow and gray cubes.


UNITY I want to make my UI text fade in after 5 seconds I know this question has been asked and asked but none of the topics i visited gave me an answer. I'm making a game programmed in c where you control a boat and i want my UI to appear smoothly by fading in after X seconds. May someone help me?


vuforia how do I force objects into a 2D plane I'm working on a game in which cards are placed on a table and then rendered in augmented reality. These objects have 3D physics attached to them which doesn't work as well if they are either rotated or if the system mistakes them for being higher or lower then they really are. Is there a good method to force Vuforia Unity to place all items in the same 2D plane and keep all of them upright compared to that plane? I currently have the following code using UnityEngine using System.Collections public class projectioncode MonoBehaviour Vector3 p1 Vector3 p2 Vector3 p3 Vector3 v1 Vector3 v2 Vector3 normal use a plane with the following 3 coordinates public void setPlaneByPoints(Vector3 point1,Vector3 point2, Vector3 point3) p1 point1 p2 point2 p3 point3 v1 p2 p1 v2 p3 p1 normal getNormal(v1,v2) public Transform projectTransform(Transform input) input.position projectPoint (input.position) return input projects a 3d point into space Vector3 projectPoint(Vector3 point) Vector3 vOToPoint point p1 vector between origin and point float dist Vector3.Dot (vOToPoint, normal) distance plane to point return point dist normal caclulates the normal of 2 vectors Vector3 getNormal(Vector3 v1,Vector3 v2) Vector3 res (Vector3.Cross (v1, v2)) res.Normalize() return res This seems to project objects onto a plane but the results tend to be inaccurate and result in weird movements, particularly when moving the camera around. This is what it looks like


How to play a sound by C that is linked to the object with AudioSource? I trying to play a sound while the player is ontriggerenter. The sound is linked to the object with a AudioSource component. But notting happened. using UnityEngine using System using System.Collections public class FloatBehavior MonoBehaviour Vector2 floatY float originalY public float floatStrength 1 AudioSource triggerAudio Reference to the AudioSource component. void Start () this.originalY this.transform.position.y triggerAudio GetComponent lt AudioSource gt () Debug.Log (triggerAudio) void Update () transform.position new Vector3(transform.position.x, originalY ((float)Math.Sin(Time.time) floatStrength), transform.position.z) OnTriggerEnter 2D void OnTriggerEnter2D(Collider2D other) If gameObject comes in contact with player if (other.gameObject.tag "Player") Play the hurt sound effect. triggerAudio.Play () Trying to debug, but the triggerAudio object will retrieve woodstump 3 (UnityEngine.AudioSource) UnityEngine.Debug Log(Object) FloatBehavior Start() (at Assets C Objects FloatBehavior.cs 17). What am I missing in my script? Should I use AudioClip also?


FBX model from Blender doesn't show it's surface in Unity3D I've create a model from Blender and exported it as .FBX file. However when I import this into Unity, the surface is missing.how can i fix? Screenshot attached in Blender it look like this in Unity it look like this which only shows it inside


adapting a Unity gravitational script to allow moons I'm using this script http wiki.unity3d.com index.php Simple planetary orbits to get a solar system going in Unity, but it doesn't seem to support creating bodies that orbit other moving bodies (or I am using it incorrectly). Any idea about how to modify it so that it does (or just use it correctly)? I've been beating my head against this problem for a couple hours, and I really don't feel like I have any idea what I'm doing. Thanks in advance.


Buggy behavior on basic hinge joint (pinball flipper) I'm trying to make a pinball flipper, but before I begin working on the script to incorporate user controls, I want to get the rotational movement working. Basically it rotates in a circle around the left most point. Clearly one option is to make half the flipper invisible. This is the easiest way but it leaves me still not really understanding how to work with rotation. For example lt o gt where o is the midpoint. I want it to rotate along the same axis, but without the left half of the shape o gt I have tried watching this video a couple times but am coming short of understanding how the hinge joint works. I attached one my left flipper and set the axis to 0,1,0 so it rotates along the y axis (remaining parallel to the playfield). I also moved the anchor to the leftmost position. I have left the rest of the hinge joint at its default configuration. Here is some evidence the placement of the hinge joint (it's the little yellow arrow at the left of the flipper) the hinge joint config The buggy behavior The left paddle's rigid body (it is locked on all position and all rotation except y) What I'm really trying to do is have the flipper rotate from it's leftmost point as the origin. I just want it to free rotate when the ball hits it.


Unity3D, how much code do you write? I'm curious to know the workflow when creating a game in Unity3D? Does it generate a lot of code for you? My understanding is that you describe the game in Unity and do scripting on the back end to do the logic. Kind of like you use Unity to describe the puppets and you use a scripting language as the puppet master.


sample project that mix unityscript and c I like the simplicity of unityscript, at same time I also like the plenty of c library and open source projects. I prefer to put my model controller logic flow in unityscript using standard unity3d sdk and invoke c extension library. Is there any sample project demonstrate how to mix the two scripts in one project? Your comment welcome


Unity Ragdoll Colliders don't collide I have a humanoid character with Ragdoll setup in Unity. However the box capsule colliders on the various parts of the body don't collide with other static geometry. They do collide with the ground but not with any other static meshes. Is it possible to use them as colliders towards static meshes and what do I need to do for it to work?


Rigidbody freeze rotation around global Y My player is a cube that moves in all directions, but cannot jump. I want to achieve that the cube cannot rotate around global Y axis, but can rotate around global X and Z. This cannot be simply done by freezing the local Y rotation, since the cube can fall from higher ground and rotate mid air after that the local and global y axes are not parallel anymore and some other axis should be frozen. Currently, I am using this line transform.rotation Quaternion.Slerp(transform.rotation, Quaternion.Euler(transform.rotation.eulerAngles.x, Mathf.Round(transform.rotation.eulerAngles.y 90) 90, transform.rotation.eulerAngles.z), 1f) which is located in the FixedUpdate(). The resulting movement is shown in this video. Clearly, this always snaps the axis that is parallel to the global Y to the closest 90 angle. This solution, however, has a few unwanted side effects. One of them is clipping with the terrain or other player cubes, the second one is that the cube randomly rotates if walking over the edges or corners, and the third one is that if one cube is on top of another and both have this script attached, they start lagging, jittering and sometimes spinning. I also tried by freezing the rotation based on what side of the cube is quot on the bottom quot , but this does not work OK, since it often happens that the cube does not rotate for exact 90 when it drops from higher ground and ends up frozen standing on only one edge, just slightly off from being on the ground with the whole bottom side. What is the quot to go quot solution for this type of movement?


Xcode project runs on device, but not simulator I built a 2D game using Unity3d 5.1.1. When i build and run the project with iPhone connected, the game runs fine on the device. But when i select simulator instead of device, i get an error " does not have an architecture that can execute" . I run the game on iPhone 4S, but cannot run on the iPhone 4S simulator. Similarly, i selected iPhone 6, 5 etc and get this error every time.


How to push an object? I would like to "push" an object using a raycast. With the following code, the problem is that depending of player rotation, i don't push the object but i pull it. What am i wrong ? Vector3 fwd transform.TransformDirection(Vector3.forward) if (Physics.Raycast (RayCastSpawnOut.transform.position, fwd, out hit, 5)) if (hit.transform.tag "MyObjectTag") GameObject myobj hit.transform.gameObject Rigidbody myobj rb myobj.GetComponent lt Rigidbody gt () Vector3 dir transform.position myobj rb.transform.position dir.Normalize() Normalize to get the correct direction myobj rb.AddRelativeForce (dir 0.5f, ForceMode.Impulse)


Angle between start and current rotation I'm facing problem of the operations on rotations. I have a wheel with a start rotation of (0, 0, 0). The player has to rotate wheel 270 degrees in Y axis either left or right. During the rotation slider should indicate progress of the rotation. For example if player rotated 135 degrees in right direction, slider is 50 filled to the right. The thing is that I'm not sure how to get the value of which the player rotate the object. For example when I start rotating right my angle changes from (0, 0, 0) to (0, 359, 0). How can I resolve this issue so it knows that change from (0, 0, 0) to (0, 359, 0) means player rotated only 1 degree?


How to seamlessly handle multiple procedural 2D levels in Unity3D? I have a dungeon generating algorithm, but I would like to generate X levels, which are all connected somehow. I have a few approaches, but all of them has problems and questions, and I wonder how i.e. Diablo II handles them so seamlessly. 1. Approach Upon leaving a level, generate the next one on the fly. This would be the easiest, but would result in a relatively long loading screen everytime the player enters a new level. So generating the levels should be at the beginning of a new game, thus the next level will just have to be loaded, which is much faster. In theory not even a loading screen is necessary. 2. Approach Generate every level at the beginning of a new game and store them. Okay, now levels just have to be loaded, which could be done under half a second. No loading screen is necessary, maybe just a fade out fade in. How do I store them? Make custom files (i.e. scriptable objects) for them, or is there a simpler way? 3. Approach Generate and load every level at the beginning. Zero loading time, because everything is already generated and loaded into the tilemap. But how do I guarantee that levels don't collide, and the player can't see level Y from level X if there are lots of levels? And wouldn't it affect the performance? Because everything is loaded all the time. Yes, renderers, rigidbodies, scripts, etc can be turned off, improving the performance a lot... but still... this seems wrong. What is the best way to solve this problem?


How would I apply force to a bullet in 2D? I wrote the code below in order to try to get a bullet to fire at a specific angle for my top down shooter. However when I press space the bullet just spawns in front of the game object despite it having a bullet speed. I made sure that my bullet prefab has a rigidbody and I am calling to it in my script. using System.Collections using System.Collections.Generic using UnityEngine public class FireAway MonoBehaviour private Vector3 mouse pos private Vector3 object pos private float angle private float bulletSpeed 1 public GameObject ammo private Rigidbody2D rb2D void Start() rb2D ammo.GetComponent lt Rigidbody2D gt () Update is called once per frame void FixedUpdate() Point the cannon at the mouse. mouse pos Input.mousePosition mouse pos.z 0.0f object pos Camera.main.WorldToScreenPoint(transform.position) mouse pos.x mouse pos.x object pos.x mouse pos.y mouse pos.y object pos.y angle Mathf.Atan2(mouse pos.y, mouse pos.x) Mathf.Rad2Deg 90 Vector3 rotationVector new Vector3(0, 0, angle) transform.rotation Quaternion.Euler(rotationVector) if (Input.GetKeyDown("space")) GameObject BulletPlayer (GameObject)Instantiate(ammo, transform.position, transform.rotation) bullet.transform.LookAt(mouse pos) rb2D.AddForce(BulletPlayer.transform.forward bulletSpeed)


Fast zoom in and out in Unity Editor Is it possible to zoom out and zoom in in Unity Editor in Scene View faster than just with the help of scroll wheel on the mouse? I hope there are exist some shortcut for that. Am I right?


360 degree viewer for AR I want to implement a 360 degree viewer for Augmented Reality in Unity. Augmented Reality means in this case, that I want to place an image like an interface mockup in my viewer which has transparency. The transparency is getting filled with the real world. So the real world part is working without problems, but that is also the reason, why a sky box is not possible since the sky box would block that. So I already had 2 approaches A sphere with a shader which rendered only the inside (turned the normals), worked on my MAC, but didn't render anything on my vr ar device (Samsung GearVR)... Here a picture how it should look like and does look like in the Unity Editor. But nothing of this "crosshair" is showing up on the GearVR A sphere or cylinder where I turned the normals beforehand in Blender, didn't apply the texture correctly and didn't show anything in Unity and on Device except a blank color.


Wheels not facing right direction when car faces different directions I am creating a real time multiplayer driving game in Unity. I am using google play's real time multiplayer service. I am having an issue where the wheels of the cars that are over the network are not facing the right direction. What I am currently trying to do is just add the calculated steering angle to the current rotation of that particular player's car, but for some reason the wheels face the wrong way and rotate incorrectly if the car is facing certain directions. Logically I thought what I have is correct. Basically for each wheel I use this code car.transform.rotation Quaternion.Euler(0, car.transform.rotation.y steerAngle, 0) So I find the rotation of that car and then I add the steer angle to it. Why wouldn't this work?


How can I detect that the mouse is over a button so that I can display some UI text? I have a scene, where a panel containing 24 buttons. I need to show some piece of text when hover a mouse cursor over the button. For example, for detecting clicks, I'm using onClick event trigger, but I can't find anything related to something like a onHover event. I have Googled and read the docs, but could not find anything. Can anybody help me with that? Code var button panel.GetChild(0).GetComponent lt Button gt ()


Unity create Animated Tilemap? Im trying to create an Animated Waterfall Tilemap from a tutorial video. In his video when the author right clicks he can see a Animated Tile under CREATE option. But In my case its not there !! Please see picture below.


3D Studio Max biped restrictions? I have a stock biped character in 3D studio max which has a jump animation. The problem I have with the jump animation is that there is actual y offset happening inside it which makes it awkward to play while the character is jumping since it's not only jumping in the game world but the jump animation is adding its own height offset. I'm tryuing to remove the jump animations height offset, so far I've found the root node and deleted all its key frames which has helped a bit. The problem I'm having now is that the character still has some height offset and if I try to lower it it has a fake 'ground' that isn't at 0 and the limbs sort of bend on the imaginary floor, si there a way to remove this restriction just for the jump animation? Here's what I mean http i.imgur.com qoWIR.png Any idea for a fix? I'm using Unity 3D if that opens any other possibilities...


Offset input sent to blend tree based on Character's Local Rotation I am developing a top down twin stick shooter. I am running into a issue where if I change my character's rotation, the Unity Blend Tree animation does not play the correct animation that corresponds to that relative rotation. For example if my Character is facing north and I walk forward, the animation plays fine, but if I rotate my character 180 degrees (facing south), when I walk forward it will play the backwards animation. https media.giphy.com media cmx1aOm0UOjCed8MJT giphy.gif I believe this is because I am just sending the inputs from the analog stick, and not offsetting the values based on the rotation of the character. I am using 2 floats (horizontal and vertical) to control the blend tree. How can I offset the float values from the input based on the character's local rotation? Current code below, void Update() if (!ReInput.isReady) return Exit if Rewired isn't ready. This would only happen during a script recompile in the editor. if (player null) return GetInput() Move() Look() private void GetInput() Get the input from the Rewired Player. All controllers that the Player owns will contribute, so it doesn't matter whether the input is coming from a joystick, the keyboard, mouse, or a custom controller. mhorizontal player.GetAxis("Move Horizontal") get input by name or action id mvertical player.GetAxis("Move Vertical") lHorizontal player.GetAxis("Look Horizontal") lVertical player.GetAxis("Look Vertical") fire player.GetButtonDown("Fire") void Move() if (mhorizontal ! 0 amp amp mvertical ! 0) Vector3 rightMovement right moveSpeed Time.deltaTime mhorizontal Vector3 upMovement forward moveSpeed Time.deltaTime mvertical Vector3 heading Vector3.Normalize(rightMovement upMovement) transform.forward heading transform.position rightMovement transform.position upMovement animator.SetFloat("Vertical", mvertical, 0.1f, Time.deltaTime) animator.SetFloat("Horizontal", mhorizontal, 0.1f, Time.deltaTime) void Look() if (lVertical ! 0 amp amp lHorizontal ! 0) float cameraFacing Camera.main.transform.eulerAngles.y Vector3 inputVector new Vector3(lHorizontal, 0, lVertical) Vector3 turnedInputVector Quaternion.Euler(0, cameraFacing, 0) inputVector transform.LookAt(turnedInputVector transform.position)


How to apply Collider to Particle and what components are needed for particles? i want to apply collider to particle system because if i applied the collider to particle ,if any other game object touched to that particle its gives some action or do some operation.so only i need.


How can I change the parents rotation so the childs rotation is looking at a specific direction I have a child object which is always having different positions and rotations (thats my VR Headsets Eye Gameobject) I cannot modify the position and rotation of that. I want to set my view to a certain "startposition" and "startrotation" so the player always has the same view at the start of the game. The childs local position is always set to some values. So I cannot unparent it. If I unparent it, I change his position. now.. It works with the position. Parent.transform.position 2 ParentStartPostion Eye.localPosition This line of code here sets my parent object so that my Gameobject "eye camera" is where i want it to be. For the rotation part, i would do following Eye.parent null unparent the eye to the world Parent.transform.position Eye.position set my Parent to the same position as Eye Eye.parent transform parent it back. Local Eye should be 0.0.0 now. Parent.transform.rotation Quaternion.LookRotation(StartForward, StartUp) i can rotate the at the direction I want it. But after I unparent my Eye the position of the local(which is also global) is set to a different value. And after I parent it back, its set to the old value again. Eye.parent null unparent my eye to the world Eye moves anyway because its movend by SteamVR Parent.transform.position Eye.position set my Parent to the same position as Eye (works) Eye.parent transform parent it back. Local Eye moves back where it was and there is a distance between parent and eye again. Parent.transform.rotation Quaternion.LookRotation(StartForward, StartUp) the rotation changing my eyes position because its parented. Also the rotation is wrong. And now i dont know anymore how to solve this problem. so... i painted my problem in paint for better understanding


How should I animate sprites with separate body parts? I am not an artist. I have a 2D Sprite broken up into different body parts that I want to animate. I know how to do it in Unity, but every artist I know would prefer to use Flash. I am trying to figure out if I should do it in Unity, or learn how to do it in Flash. My understanding is that in Unity, I'd have to animate directly, or Flash would output sprite sheets. Is there anything Flash offers for animating sprites that Unity does not? Is there a benefit to using sprite sheets over animating directly? Is there an option I should consider over Flash and Unity?


About tiles in games I'm trying to learn how to develop games in Unity and my base is tiled games, I would like to know if a simple tile is an image (sprite in 2D) or a game object in 3D. Since I'm trying to do some kind of 3D tiles with interaction with the user like press to do something an animation, I would like to know how it works.


How to Make Border of 2D Game in Unity I have a border by default. But, I'm having trouble detecting if my object collides with the border. I am looking for efficient ways to do this, and I am not sure what should I use. I thought using a Tilemap might work. But, it was only giving me a grid, not a Tilemap. Even then, I was unable to figure out how to use the grid. How should I go about creating this?


How can I use one method and also switch between a coroutine and the main method? Now I'm using two methods, one as StartCoroutine and one not. What I want to do is to have just one method and when I set the StartCoroutine variable to true or false when the game is running I want it to switch between the coroutine and the main. Is there a simple way to do it with one method and not two, if not, how do I achieve this? using System.Collections using System.Collections.Generic using UnityEngine public class Grid MonoBehaviour public GameObject gridBlock public int worldWidth 10 public int worldHeight 10 public bool StartCoroutine false public float spawnSpeed 0 void Start() if (StartCoroutine) StartCoroutine(GenerateGridSC()) else GenerateGrid() private void GenerateGrid() for (int x 0 x lt worldWidth x ) for (int z 0 z lt worldHeight z ) GameObject block Instantiate(gridBlock, Vector3.zero, gridBlock.transform.rotation) as GameObject block.transform.parent transform block.transform.name "Block" block.transform.tag "Block" block.transform.localPosition new Vector3(x, 0, z) IEnumerator GenerateGridSC() for (int x 0 x lt worldWidth x ) yield return new WaitForSeconds(spawnSpeed) for (int z 0 z lt worldHeight z ) yield return new WaitForSeconds(spawnSpeed) GameObject block Instantiate(gridBlock, Vector3.zero, gridBlock.transform.rotation) as GameObject block.transform.parent transform block.transform.name "Block" block.transform.tag "Block" block.transform.localPosition new Vector3(x, 0, z)


How to rotate and move an object in precise time frame My task is to rotate and move an object into a new position and rotation in a given time. Say I have to move a cube from (0,0,0) (0,0,0) to (1,1,1) (0,90,0) in 5 seconds. Could anyone explain to me please how to achieve that? My experiment is private IEnumerator DoMove( float time, Vector3 targetPosition ) foreach(WayPoints wp in tposes) float counter 0 float duration wp.timeStamp while (counter lt duration) counter Time.deltaTime Vector3 curpos cube.transform.position Quaternion crot cube.transform.rotation float time Vector3.Distance(curpos, wp.position.position) (duration counter) Time.deltaTime cube.transform.position Vector3.MoveTowards(curpos, wp.position.position, time) cube.transform.rotation Quaternion.Lerp(crot, wp.position.rotation, time) yield return null Debug.Log( quot Reached position quot wp.position.position quot in time quot Time.time) The cube gets to its position in time, but rotation is late. The end position of the cube should be (2,2,2) (0,120,0), but it stops moving at (2,2,2) (0, 110,0). There are two positions I want the cube to be in (1,1,1) (0,90,0) in 5 seconds (2,2,2) (0,120,0) in next 4 seconds


How can I change view to orthographic using a menu? I'm writing the custom menu using MenuItem and I'm stuck trying to make scene view orthographic when 5 is pressed. What is the object or method I can use to set scene's view to orthographic (I don't mean the main camera, but the main view shown in the window). This is a C code of what I was trying to achieve MenuItem("View SetOrtho 5") static void SetOrtho() var scene ... assign scene scene.setOrtho(true) set orthographic view to the scene


Unity Animator animations fail to play only when triggered by user input I have a unity animator setup like so. When the game runs, I can trigger each state in the state machine with user input. I can use HasExitTime flag to trigger the animation, and it will play through and loop infinitely as expected. However, when I try to use the GearChange trigger, the state machine progress bar plays, the correct box is triggered, but the animation itself doesn't play! I'm at a total loss as to what the problem is here, as everything else is exactly the same, minus the user input. The console isn't showing any errors, the animation simply doesn't respond to the state machine. What am I missing here? Unity version 2020.1.0f1 So I deleted the animator, and setup everything again the exact same way. Now the animation won't play, period. The state machine progress bars are still triggered as expected, but the animation won't play. In the transition preview, the animation won't play there either.


If a 3d surface is occluded by another 3d surface, does this have any effect on the performance and rendering speed? We have a 3D character who is wearing a gauntlet on his forearm and visibility of which can be turned on and off. Would it be better to create two versions of arm, one without extra triangles that are hidden beneath the gauntlet? Or we can just one model with gauntlet as separate object which can be turned on and off ? Does the hidden triangles have any effect on rendering or are they completely ignored by engine? We are using Unity 3D.


Manipulating an animation towards a target object (ie. The hand and arm lean towards the target) I am trying to make a boxing game just for fun (I dont expect the end product to be anything decent lol) . I have my boxers in the ring and they are animated quite well so far, with Idle, and punch Left and Right. They also rotate so they are always looking at each other. What I want to do is give the punch some aim towards the head. I will give the punch a set amount which it can move from the standard animation and move the hand bone in the direction of the targets head object. But I don't know how to do this S So far i have used dragged the 3 animation files into Mecanim and coded it to do the animations when a button is pressed. Is there a way to manipulate the animation in this way? (ie. actually make the arm reach towards the target object )


How to build a C library for Unity as a pure Visual Studio project The aim is to build a relatively simple (2D) game in Unity with most of the game logic in a non visual AI. The AI needs a lot of testing and debugging independently of any visuals (which is best done using VS tools), and the API connecting them is one class and a few methods properties. A future version might not even use Unity. So the question is how to set up a VS solution file to build the AI for testing and debugging while remaining compatible with the Mono build environment used by Unity. Yes, I know it has to be C 4, but beyond that? At present I'm copying CS files around and that doesn't feel right. Just to make it crystal clear, the AI has no dependency on Unity and will be built in a project that has VS testing and code analysis but no Unity tools or imports. In future it may be used with a different engine.


Is it efficient to use colliders on UI canvas in Unity? Basically I have a task where the player will be able to drag an object (as UI Image), and place it inside a bag (another UI image). What's the best optimized way to do so? As I researched, I do not think that using colliders for images is the "best" way to do it. Additionally, I was thinking about checking if the position of the image while dragging overlaps an element however, I do think that would be performant as that would require checking the position on each frame instead of "OnTriggerEnter". What would be the best way to implement such function? Thanks amp Regards, HurpaDerpa


Creating a simple countdown timer in unity Hello's I was looking for a way to do a countdown timer in unity and stumbled across this solution public float timeRemaining 10 private void Update() if (timeRemaining gt 0) timeRemaining Time.deltaTime else WinGame() Which at first seemed pretty elegant and easy to use, however, I was thinking about it, and wouldn't this be inconsistent for players with different FPS? For example, if the player has 60 FPS vs 30 fps it would take longer for the player having 60 FPS to reach 0 on time remaining.


Load large quantities of data in Unity3D I'm building an Android app using Unity3D where users can visualize data immersively. The data is immutable and stored using a MySQL database hosted on cPanel. When the user clicks a button in the environment, it starts the creation of a chart. First, contacts a .php file present in the server responsible to query the database, fetching the data and make it available to the Unity controller which then adds the points to the chart. This works fine for small quantities of data. To increase performance, thought of exporting from MySQL as CSV and transform to one JSON, instead of querying a database or try to make MySQL transform to JSON, but I'm afraid this won't be enough. Could also extract as CSV and use a 3rd party for reading it. How would you load the data in such case to have the best performance?


Health bar without image collapsing to the centre in Unity 2D I am trying to create a health bar that collapse symmetrically to the centre. The color palette of my game is minimal and the health bar is only one color that does not change with size. I am new to Unity and am not sure how to achieve this. This video uses a GameObject with an Image component, adds the health bar sprite to the image, makes the Image type fill and then changes the fill amount from the script. I have two questions for my particular case, I would prefer not to use an image. Since the bar is one color I can use color selector to make the bar, but then it does not have the fill type. Is there a way to do using only color? The the bar is anchored at one end left or right. I want to anchor it at the centre. One work around is to use two objects side by side and fill them in opposite directions to get the desired effect. Is there a better way?