Unity Creating a panel that stretches using anchors Relative newbie to Unity so please excuse any oversights. I have a component (canvas panel) that I'm wanting to add a panel to, so that when the parent component's height changes, the child panel's height changes to match. I've achieved this manually using the inspector (see top half of attached pic) to set the anchor points at min(0.5, 0) and max(0.5, 1) (pivot is unchanged at (0.5,0.5)). I want to create that stretching panel in scripting, and have the following code that results in the bottom half of the attached pic where the rect transform's anchors aren't set at all. GameObject panel2 GameObject.Find("Panel2") GameObject divider new GameObject("RunTimeLine") divider.layer LayerMask.NameToLayer("UI") divider.transform.SetParent(panel2.transform) CanvasRenderer c divider.AddComponent lt CanvasRenderer gt () RectTransform rt (RectTransform)divider.AddComponent lt RectTransform gt () Image img divider.AddComponent lt Image gt () img.color Color.red rt.localPosition new Vector2(0f, 0f) rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 20) rt.anchorMin.Set(0.5f, 0) rt.anchorMax.Set(0.5f, 1) Any suggestions? I've also tried setting the min max offsets and pivot but haven't been able to create what I've got manually in the inspector.


Unity3d "random" transform position values on editor Run into some strange behavior on editor position values. https youtu.be DUBpbOUkbfo As you can see we have two cube object with colliders on both and rigidbody on parent. After start play mode parent object editor values sets to some random numbers while transform.localPosition and transform.position is still (0,0,0). This somehow related to parent child physics hierarchy but can't understand how.


Animated Energy Combo Bar (Unity 4.6) How could I achieve the animated Combo bar effect used in Ski Safari Ski Safari Adventure time? Preferably with Unity 4.6 UI. General explanations also welcome! Links to videos showing the wanted effect https www.youtube.com watch?v CnfCkqiM890 t 4m46s and https www.youtube.com watch?v aqj61liRJ74 t 7m00s


Unity Renderer "raycasts" from top down? I'm trying to have objects in a game be selectable only from a top down orthographic camera view. I think having physics colliders might be overkill for that especially because this only needs to be in 2D and not 3D. Is there another method that might be better, such as something like a renderer quot raycasts quot , but perhaps even more performant as it is just from the orthographic 2D top down view


Textures selectively not applying in Unity On certain imported objects (fbx) in Unity, upon applying a material, only the base colour of the material is applied, with none of the tiled texture showing. This isn't universal on a test model only some submeshes didn't show the texture, while some did. I have tried every combination of import calculate normals tangents to no avail. FYI I'm not exactly experienced with the software or gamedev in general this is to make a small static scene with 3 4 objects max. One model tested was created in 3DSMax, the other in Blender. I've had this happen on every export from Blender, but only some submeshes from the 3DSMax model (internet sourced to test the problem)


Best client server architecture for a mobile management game? For the past year I have worked on a small company that develops a traditional browser based strategy game, of the likes of Travian or Ogame, but using a more interactive approach like Tribal Wars 2. The game is made in a simple php server without frameworks and a simple mysql database, and all of the game happens in a single static page that is changed through ajax calls and has a map made in pixi.js. The automatic updates are delivered to the client side through polling the server which then queries some specific database tables made for the purpose for changes. While this approach is solid and works, it has 2 big problems Having a mobile app is increasingly more important and there are not enough resources for having two separate codebases. Having a app which is simply a wrapped webview is also not a solution because the performance of a really complex page with a giant webgl map is, while usable, really subpar Polling the server for changes creates a lot of programing challanges that make some simple tasks really complicated and creates a lot of convoluted code if we dont want to hurt the game performance, as we are not going make dozens of database queries every 5 seconds. I want to start developing a game idea that I have that is basically inserted in the same genre and which is going to be, at least initially, mobile only. The real problem here is that after reading a lot on the internet, I am confused on what should be a good client server architecture for me to start prototyping in a way that I do not run in the problems mentioned above. Basically, above all, I want the server to be able to know which page screen state is each client looking at, and be able to send them messages when another client changes something on that specific screen. It would also be nice if the solution is something lightweight on the server side to be able to scale a little. Client side I was thinking about Unity because of being cross platform, of all the environment around it (ads, analytics, a lot of support and answers on the internet), and because I have previous development experience with it. Server side is the real question. Simple http calls will not work and so PHP is out of the equation. I have though about using node.js with socket.io to use websockets solving the polling problem. Is this a good idea? Would it be better to store the game state in a relational or nosql database in this case? Would this work on unstable mobile conections? Lots of people seem to use a c and sockets for unity. Would this be overkill in this situation? Taking this approach how would the data be stored? would it be feasible with a linux server or would I need a windows server? Would this work on unstable mobile conections? Don't know, I'm open to suggestions. tl dr I want to make a mobile management game in unity but am confused what to choose for the server side architecture considering that I want the server to be ablose to send a message to the client without the client asking for it. Is there anything I should take in account? Sorry for the broad question and thanks for the help.


Unity, interior poly always missing in clothing I've modeled interior polygons but for some reason they do not show up in Unity. I've tried changing import settings for normals to both calculate and import... How do you have a tshirt's interior poly show up?


Game (Physics) work in Unity Editor Remote but won't on Android? I have a script attached to a car game object that allows the player to tap the screen and then accelerate, the game object has a RB2D and collider set to it , it works fine in Unity Remote , but when I download the APK , as soon as I tap the screen , collisions go completely bezerk and the car just starts ignoring collisions , what's going on? As I need this to work to complete my game , as the player can move side to side with the accelerometer but I also want them to move forward when they touch the screen. Also , my game is 2D. Plus , since then , when the car ( my object) collides with anything else in the scene , it ignores it ( the obstacles just have Box Colliders on them). I had to freeze rotation so it could stop spinning out when it hit soemthing , now it just won't recognize collision at all. What's going on? The code I think is causing the error starts at line 32. I have obstacles the player has to dodge and they all have box colliders and an appropiate script attached to them as well ( so when they collide with my player , it destroys it) I've figured it out , Collision works when I first start the game , but when the player dies and I press "Replay" , it goes crazy. Here's the script that controls the enemy cars spawning , what the hell do I do to fix this? Code (CSharp) using System.Collections using System.Collections.Generic using UnityEngine public class EnemyCar MonoBehaviour public float speed public float acceleration 0.5f Use this for initialization void Start () Update is called once per frame void Update () speed Time.deltaTime acceleration transform.Translate(new Vector3(0, 1, 0) speed Time.deltaTime) void OnCollisionEnter2D(Collision2D col) if (col.gameObject.tag "Coin") Destroy(col.gameObject) I've done everything in the book trying to solve this , re install unity , add different colliders etc. What's weirder is that it is FLAWLESS in Unity Remote and the Editor , these issues only arise when I test out the apk. Here's how my game usually looks when the collisions work. Now when it collides with a car ( on android) , it just ignores it and is slightly pushed back. Help me! Here is my script attached to enemy cars ( the cars that should destroy the player on Collision) using System.Collections using System.Collections.Generic using UnityEngine public class EnemyCar MonoBehaviour public float speed public float acceleration 0.5f Use this for initialization void Start () Update is called once per frame void Update () speed Time.deltaTime acceleration transform.Translate(new Vector3(0, 1, 0) speed Time.deltaTime) void OnCollisionEnter2D(Collision2D col) if (col.gameObject.tag "Coin") Destroy(col.gameObject) Also here is the inspector view of my Player Car Here is the inspector view of an enemy car ( they all have the same things)


How can I use Body tracking in Android using ARCore or some other libraries? I know that ARCore on Android doesn't support Body Tracking like ARKit does. But is there some alternative or workaround to achieve it? Some other SDKs or Libraries or maybe even if there is some way to do it through ARCore itself? To make it clearer I plan to use something like this in an AR game for Android. I plan to develop it in Unity 2019.4.x. My search result in Google didn't yield a useful result as it gets mixed with ARCore Motion Tracking (which isn't what I am talking about here) or implementation with ARKit. But I got a little hope that there might be some way out after reading this post on Unity Forums.


How can I draw gizmos and move the drawn gizmos when moving the transform in the editor in scene view? public void OnDrawGizmos() if( thisT null) thisT transform if(!Application.isPlaying amp amp posBuffer ! thisT.position startPosOffset) posBuffer thisT.position startPosOffset if( positionSphereDepth 1) positionSphereDepth positionSphere if( spawnSphereDepth 1) spawnSphereDepth spawnSphere Gizmos.color Color.blue Gizmos.DrawWireCube ( posBuffer, new Vector3( spawnSphere 2, spawnSphereHeight 2 , spawnSphereDepth 2)) Gizmos.color Color.cyan Gizmos.DrawWireCube ( thisT.position, new Vector3(( positionSphere 2) spawnSphere 2, ( positionSphereHeight 2) spawnSphereHeight 2 ,( positionSphereDepth 2) spawnSphereDepth 2)) posBuffer is Vector3 spawnSphereDepth is float The problem is that it's drawing the cube in the center of the scene view window and when I'm changing the transform position the cube Gizmo is not moving. Is there a way to draw the DrawWireCube so it will be position around the transform and when moving the transform that the gizmos draws will move with it too ?


Endless runner character stops moving unexpectedly I've been trying to make an endless runner game in Unity in which a player moves forward automatically and can move from x to y axis while still moving forward. I do not know how to program so I used a Template. Since then, my player stops moving forward when there is no box collider in front of it. it stops when there is a box collider by the sides and even when it's at the front. It's really frustrating. Below is the script I used using System.Collections using System.Collections.Generic using UnityEngine public class NewPlayerScript MonoBehaviour private CharacterController controller private Vector3 direction public float forwardSpeed public float maxSpeed private int desiredLane 1 public float laneDistance 4 public float jumpForce public float Gravity 20 void Start() controller GetComponent lt CharacterController gt () Update is called once per frame void Update() direction.z forwardSpeed if (controller.isGrounded) if(forwardSpeed lt maxSpeed) forwardSpeed 0.1f Time.deltaTime direction.y 1 if (Input.GetKeyDown(KeyCode.UpArrow)) Jump() else direction.y Gravity Time.deltaTime if (Input.GetKeyDown(KeyCode.RightArrow)) desiredLane if (desiredLane 3) desiredLane 2 if (Input.GetKeyDown(KeyCode.LeftArrow)) desiredLane if (desiredLane 1) desiredLane 0 Vector3 targetPosition transform.position.z transform.forward transform.position.y transform.up if (desiredLane 0) targetPosition Vector3.left laneDistance else if(desiredLane 2) targetPosition Vector3.right laneDistance transform.position Vector3.Lerp(transform.position, targetPosition, 80 Time.deltaTime) private void FixedUpdate() controller.Move(direction Time.fixedDeltaTime) private void Jump() direction.y jumpForce I really dont know what the problem is. I have the character controller and the sphere collider enabled in my inspector for my character and I have only the box collider enabled for my prefabs.


Unity Mirror client scene.local player.connection to client.client owned object not working in client U hmm I'm new to mirror networking I just wanna find objects that the local player has authority, but it doesn't work on client, is there a solution to this? Well I could make an object tracking script but that will complicate things. This question might look like I haven't research anything, truth is I've searched everywhere there is just no documentation for this


UniRx Subscribing to ReactiveProperty condition I'm trying to track a cold source with a contiguous range, and every example I've seen involves discrete increments or events that are already handled, so I'm vague on how to apply it. Here's what I have ReactiveProperty lt float gt CurrentAlpha new ReactiveProperty lt float gt (msg.GetComponent lt CanvasRenderer gt ().GetAlpha()) CurrentAlpha.Where(x gt x lt 0.0f).Subscribe(x gt Debug.Log( "CurrentAlpha CurrentAlpha Observed") img.transform.SetParent(null) Destroy(msg) ) I verified the alpha value, but never received notice when it reached 0. What have I mistaken? EDIT Found that it's actually subscribing to the value returned, which will always be 1. The value it receives is outside managed code, so there's no object property to observe, and CanvasRenderer itself doesn't observe it. Is it possible to observe a method's return value?


Mathf.Hermite not available in Mathf I see here that Hermite should be function in the class Mathf. However, when I try to use it, the compiler tells me that Mathf doesn't contain a definition for Hermite. This is an example float fNewDistance Mathf.Hermite( initialDistance, GoalDistance, fTime) What am I doing wrong here? Thank you!


How can I detect a long press then activate an animation? How can I detect a long press on a touch screen then activate an animation? And when the finger is released, play another animation smoothly? Let's take for example the main character in Crossy Road when the user presses down, the chicken "squats" and when the user releases their finger, the chicken jumps. Same concept. C .


Using a state pattern across multiple controllers general architecture advice I'm trying to implement a state pattern having skated by with enums forever and have hit a bit of a wall when it comes to it's implementation in my game. It's a grid based strategy game with an MVC hierarchy. The general flow is InputManager gt CursorManager gt GridManager. So if the player presses "Up", the InputManager will translate that to the appropriate action and notify the CursorManager. The CursorManager will then update the cursor's world position and then then prompt the GridManager to find what's in the hex in order to update the UI with terrain unit info. My new addition is thus having the GridManager change the cursor's state depending on what's in the tile. You pressed up? Let's let the cursor state dictate what happens to the grid. So naturally I created a cursor state object in the CursorManager, but suddenly realized each state needed decent amount of shared information across different the two controllers. For instance, public class FreeCursor CursorState public override void ActionPressed() currState gridManager.selectTile(cursor.position) So this means the FreeCursor state would need reference to the GridManager object, reference to the cursor GameObject, and also a reference to the current state itself. All 3 of those are already in the CursorManager, so it's no problem, just throw them all in a constructor FreeCursor(CursorState context, GridManager gridManager, GameObject goCursor) But d'oh, when gridManager.tileSelected() completes, it should return the new state. So the GridManager should be saying public CursorState selectTile(Vector3 position) ... return new FreeCursor(this) ...Except now we're missing the GameObject and the current cursor state, which aren't accessible in the GridManager. So I could go one or two ways make the GridManager also contain a reference to the context, so it becomes return new SelectedUnitState(this, CursorManager) and changes our flow to be InputManager gt CursorManager lt gt GridManager. Or I could say screw it, throw the cursor state and GameObject into the GridManager and call it day. ...But both feel just wrong? The latter through combining two somewhat distinct controllers the former by making the state be passed it's own containing object like a poor man's reflection or something. Because if I do that, I might as well just use Unity's GameObject.Find(Cursor). Am I wrong to think this? And if so, is the problem with my implementation of the state pattern or the way I've laid out my 'architecture'? tl dr How do you handle a state pattern with data from multiple controllers? Thanks!


How can I create a mirror with Unity? Can anyone explain how I can create a mirror effect like the one in this YouTube video using Unity Pro? I know that I need to use render textures to do it, but I am not sure how.


how to save Audio Volume to playerprefs to mute all scenes sounds Please Explain me how to Save or Set Audiolistner or scene Audio to playerprefs to control game all scene sound by a simple Button On and Off .. Please Give Me C sharp Script as a Example To Mute and UnMute Full Game All Scenes Sound from Scene 1. Thanks ..Waiting


How can I randomize my speeds just once, each time values are changed in the Inspector? private void SpeedUpdater() if (changeSpeedOnce false) foreach (WaypointsFollower follower in waypointsFollowers) if (randomSpeed) follower.speed Random.Range(minRandomSpeed, maxRandomSpeed) else follower.speed speed changeSpeedOnce true I'm calling SpeedUpdater from inside the Update. The problem is that if I'm not using the private flag bool changeSpeedOnce it will give each follower speed a random value every frame but I want that when it's random it will give each follower speed only one random speed value that is why I'm using the changeSpeedOnce flag. but then I can't change the speed in run time when the game is running because changeSpeedOnce is false now. I'm stuck here. From one side I want to give only one random speed value to each follower but I also want to do it any time in the run time when I'm changing the speed value in the Inspector.


Random Direction Vector Relative To Current Direction I have a 2D vector where the x and y values are randomly generated using a range between 1 and 1 respectively. I use this as the direction to move an object in which works great. var direction Vector2(Random.Range( 1f, 1f), Random.Range( 1f, 1f)) What I would like to do is after some period of time, randomly generate a new direction vector, but this time keep the same "relative" direction that it currently has. Probably within 45 degrees or so on either side of the current direction. So I'd like to randomly generate a new direction vector within a range of 45 degrees on either side of it's current direction vector, and start moving in that new direction. Does that make sense? I'm not quite sure how to go about this, but I'm sure this isn't too difficult if someone could help get me started. Thanks!


Unity3D, How do I press one key and then cant press another key while the one is pressed? I am making a horror game, and I want to press a key to look up while I am idle, that i've done but if I press the W key it stands in idle but floating forward. How can I disable the W key while I press the F key to look up ? Everything works fine I can press F and the LookUp Animation is being played and if KeyUp on F the Animation goes back to Idle. My problem is if I am in LookUp Animation when I press F, I can also press W to go forward but its floating not walking. I want to deactivate this function so I can just press F when I am Idle. Thanks for help. my Script public float speed 10f public Rigidbody rgb public Animator anim bool walk false Use this for initialization void Start () rgb.GetComponent lt Rigidbody gt () anim GetComponent lt Animator gt () Update is called once per frame void Update () float move Input.GetAxis ("Vertical") anim.SetFloat ("Speed", move) if (Input.GetKey (KeyCode.W) walk true) rgb.transform.position new Vector3(0, 0, 1) speed Time.deltaTime Debug.Log("Walking") else walk false Debug.Log("Idle") if (Input.GetKey (KeyCode.F)) anim.SetBool("LookUpIdle", true) rgb.transform.position transform.position else anim.SetBool("LookUpIdle", false)


Unity display message upon keypress? Hi I'm trying to get NGUI's HUDtext to display a set of text message one of which being "Try using WASD to move" and displaying "Well done!" upon input of any of the four keys. Unfortunately I'm not well versed in C and am currently stuck and unsure how to implement this. using UnityEngine using System.Collections using System public KeyCode KeyCode.Alpha2 public class Test MonoBehaviour public int seen 123 public HUDText hudText void Start() StartCoroutine(MyCoroutine()) Debug.Log(KeyCode) Tutorial () void Tutorial() while (true) while (!Input.GetKeyDown(KeyCode.Return)) Debug.Log ("Hit return") IEnumerator MyCoroutine() hudText.Add("Welcome", Color.white, 3f) yield return new WaitForSeconds(3) Wait one frame hudText.Add("This is System Defence", Color.white, 4f) yield return new WaitForSeconds(4) hudText.Add ("Try using WASD to move", Color.red, 3f) yield return new WaitForSeconds(3) I would appreciate it if someone could tell me how would I go about doing this.


How do i draw a ray in unity So i am trying to scrap together something for vr in which the locomotion is about the player holding the direction where he wants to go to(basically planning what he is going to do)while holding down the button a ray is beeing drawn and when the player lets go the character moves until he reaches the end of the ray i tried looking up something but couldnt find anything regarding something like this


Unity Adjusting 2D physics for different mobile resolutions I created a test project to see how different mobile resolutions affects Unity's 2D Physics. They way I handled the resolutions was to contain all the objects (including non UI objects) in a Canvas and use a Canvas Scaler component to adjust for multiple resolutions. Although this approach is probably not one of the ways the Canvas was not meant to be used, it works well when working with a single orientation. Despite the quick solution to handle the multiple resolutions, there seems to be the issue of the physics acting differently depending on what aspect ratio is being used. Images can be viewed here http imgur.com a p5wmf The green and blue blocks both have the Rigidbody2D and Box Collider 2D components. The floor (big white block) only has a Box Collider 2D component. As you can see from the images above, the different aspect ratios cause the blocks to collide with the floor at different times. Also, when using rigidbody.addforce in the Y direction, the different aspect ratios cause the blocks to jump at different heights. Obviously these issues could cause an unfair advantage in a game with support for several resolutions. So how would I go about adjusting the physics so that the blocks fall and jump at the same rates relative to the different resolutions? Also if there is a more practical way to adjust for multiple resolutions that doesn't involve a plugin and doesn't break physics, let me know!


Overlap transparent particles without blending? (Unity) I'm trying to create a continuous output of light from an object (like the exhaust of a space ship), and I thought I'd use particles to achieve this. But I'm running into a problem with alpha blending. I'd like to decrease the particle system's alpha over time, but because there's such a high density of particles, they end up evaluating to a solid color for most of the system's duration. This blog post basically shows what I'm trying to achieve https mispy.me unity alpha blending overlap The idea is to use a stencil test to make sure pixels in a sprite particle aren't gone if they're overlapping another sprite particle. Pass Stencil Ref 2 Comp NotEqual Pass Replace Then the author adds an alpha cutoff to make sure transparent pixels on an underlying sprite don't prevent new pixels from being written. half4 frag (v2f i) COLOR half4 color tex2D( MainTex, i.uv) if (color.a lt 0.3) discard return color But this solution requires you to eliminate soft edges, so I'm thinking it wouldn't look good in a particle system. The author also hinted at an alternate solution involving ZTest, but I can't visualize what that would be.


Script not working (Function not changing value) I have this script that I made for an FPS character. public class Player Movement MonoBehaviour public CharacterController controller public Transform camera public float gravity 9.81f public Transform groundCheck public float groundDistance 0.4f public LayerMask groundMask bool grounded public GameObject joystick public bool isMoving public float speed 12f public float turnSmoothTime 0.1f float turnSmoothVelocity public float jumpHeight public Vector3 yPosition public bool jumpAble true Update is called once per frame void FixedUpdate() grounded Physics.CheckSphere(groundCheck.position, groundDistance, groundMask) if (grounded) yPosition.y 2f jumpAble true Vector3 direction new Vector3(joystick.GetComponent lt Joystick gt ().inputDirection.x, 0f, joystick.GetComponent lt Joystick gt ().inputDirection.y) isMoving direction.magnitude ! 0 ? true false if (isMoving) controller.Move(direction speed Time.deltaTime) yPosition.y gravity Time.deltaTime UnityEngine.Debug.Log(yPosition) controller.Move(yPosition Time.deltaTime) public Vector3 Jump() UnityEngine.Debug.Log(jumpAble) UnityEngine.Debug.Log(grounded) if (jumpAble amp amp grounded) jumpAble false yPosition.y Mathf.Sqrt(jumpHeight 2 gravity) UnityEngine.Debug.Log(yPosition.y) UnityEngine.Debug.Log(yPosition) return yPosition return yPosition The game operates on mobile touch controls, and the Jump() is called when the jump button is pressed. However, the character does not jump when I press the button, even though the function is being called, and the yPoisition is being changed in the function. I know that changing the yPosition should make the player jump, as when I add this code to the Update if (Input.GetKey(KeyCode.Space) amp amp jumpAble) fallDown.y Mathf.Sqrt(jumpHeight 2 gravity) Everything works fine. Why is the new yPoisition value not being passed to Update, and why is this happening?


How can I play a YouTube video in Unity if given the YouTube URL link? How can I play a YouTube video in Unity if given the YouTube URL link? I am using 2019.4.13 Is there a way to open webpages?


Problem when importing fbx in Unity made in Blender First I will explain how do I make my object in Blender I want to make an object with a texture that have transparecies (png image). I unwrap my object and then apply the image to it in the UV editor. Then I export my object as fbx. To try the transparecy first I imported a PNG image as a plane on Blender and adjusted the necessary things in order to make work the transparency. You can appreciate the settings I used in the following image Until there is all fine. The problem appears when I import the fbx in Unity. The material that I created with the png image is not well visualized. When I import the fbx object in Unity, this messages appears in the Materials tab What do I have to set here in order to visualize well the image with its alpha channel working? Furthermore, if I try to change the material settings it is impossible because I cannot click the different options as they are disabled Can anybody tell me what I'm doing wrong? I don't know if my error is when creating the material in Blender or when I import the fbx in Unity.


Lighting changes when loading scene I have a script that changes the levels using Application.LoadLevel (sceneNameToChangeTo) Once a level is loaded using that code when testing with the editor, the lighting changes dramatically. I've checked if something changes in the light or lighting settings, but it doesn't. This is a screen of how the scene looks when I simply press RUN in the scene in the editor Notice the blue tints from the sky etc. This is clearly PBS lighting. Now after I use my code to change the scene to another one and then back to this one, the scene looks like this What am I doing wrong? I am using Unity 5.0.1. This effect does not happen on mobile devices.


(Hitbox) OnTriggerEnter2D only work if enemy is moving (UPTADE) I am developing a 2D Topdown Rpg Game. I have a problem with trigger colliders. I have button which make active an object and use it like Hitbox when i press button destroy enemy if it is touching hitbox but there is a problem about something. When i press button enemy is destroyed if only enemy is moving when it stop i cant destroy it How can I fix this? This is my hitbox's destroy script private void OnTriggerEnter2D(Collider2D other) if (other.tag quot Enemy quot ) Destroy(other.gameObject)


How to properly synchronize achievements on Google Play Services? I have a mobile game with achievements on android, so the achievements are using Google Play Services. For a couple of reasons, I must track the progress on the achievements locally (or so I think) because If the user is not connected to the internet Some achievements have complex "step" that the simple increment system provided by the Google Play Service (number of steps, current step) cannot track. When the game starts, the local copy data on the achievements is synced with what is on Google's server. Either both are the same, do nothing the local copy has more progress than what is shown on Google's so update Google data (that happens if you play offline) the copy on Google's server show more progress than locally so update the local data (that happens if you play on a different device) Clearly, there's a way to abuse the system here. Given two players with different achievement progress (Player A (lots of achievements), Player B (few achievements)) they can do the following Using Player B's device, Player B signs out of his account Player A signs in (the current active Google Account is now Player A) Start the game All of Player A's achievements are synced locally (they had more progress than the previous local version of Player B) Player A signs out and Player B signs in Re start the game the local copy will show as more advanced than Player B achievements, therefore they will get updated. How do people deal with this problem? Not care? Key the local achievement progress to the logged in player (which causes some problems)? Not to track anything related to the achievements locally (but how to deal detect being offline?)


Unity Apply different Near Far clip plane value for different layer I am Lerping the Near value of my camera, from 0 to 38, and it gives this result change near clip plane effect As you see, it gives a nice effect. But now I would like the effect to occur only for one specific layer. How can I do that?


Tire mesh rotates faster than wheelcollider in Unity I have a car in Unity. Scripts are C . I have noticed that my tire meshes' rotation is faster than whellcollider rotation. I am using this code for wheel rotation flWheel.localEulerAngles new Vector3(flWheel.localEulerAngles.x, flWheelCollider.steerAngle flWheel.localEulerAngles.z, flWheel.localEulerAngles.z) frWheel.localEulerAngles new Vector3(frWheel.localEulerAngles.x, frWheelCollider.steerAngle frWheel.localEulerAngles.z, frWheel.localEulerAngles.z) flWheel.Rotate(flWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) frWheel.Rotate(frWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) rlWheel.Rotate(rlWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) rrWheel.Rotate(rrWheelCollider.rpm 60 360 Time.deltaTime, 0, 0) I found this from here Does anyone know how to fix this? Edit Using AquaGeneral's answer I could able to solve rotation problem. But now front right tire position changed to rear left tire position and rear right tire rotated 180 on Y axis. need help


How do I stop my skeleton from playing the walking animation? I'm trying to get a Skeleton Model to go from its walking animation to its idle animation using a bool that checks for input. Currently, in game, the skeleton doesn't leave its walking animation and stays in it even when not walking. Here is the code I'm using public class SkeletonMove MonoBehaviour private float velocity 5f public bool isWalking false Vector2 input void Update() GetInput() if (Mathf.Abs(input.x) lt 1 amp amp Mathf.Abs(input.y) lt 1) return Rotate() Move() void GetInput() input.x Input.GetAxisRaw( quot Horizontal quot ) input.y Input.GetAxisRaw( quot Vertical quot ) void Move() controller.Move(transform.forward velocity Time.deltaTime) anim.SetBool( quot Walking quot , isWalking) if (input.x ! 0 input.y ! 0) isWalking true if (input.x 0 amp amp input.y 0) isWalking false


How to rotate the transform only on the Y? private Update() Here the transform player should rotate facing the opposite direction. Determine which direction to rotate towards Vector3 targetDirection targetToRotateTo.position transform.position The step size is equal to speed times frame time. float singleStep rotationSpeed Time.deltaTime Rotate the forward vector towards the target direction by one step Vector3 newDirection Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f) Draw a ray pointing at our target in Debug.DrawRay(transform.position, newDirection, Color.red) Calculate a rotation a step closer to the target and applies rotation to this object transform.rotation Quaternion.LookRotation(newDirection)


How to divide sprite sheet, but keeping the in same png? first post here, but couldn't find an exact answer in your database, so guess I'll have to ask. I want to know how it is possible to create a ".META" file for a .png so you can extract individual sprites in a spritesheet without having to save all the sprites in individual .png's. I know it's possible since the developer in the tutorial HERE is using a spritesheet like that. Thank you very much in advance.


How to get the physical camera sensor size on iOS Android in Unity I'm trying to get the physical camera sensor size on iOS and Android mobile devices for intrinsics calculations. On Android the sensor size should be found in the SENSOR INFO PIXEL ARRAY SIZE (Android CameraCharacteristics API). However I don't find a way to access that array via ArFoundation. I can imagine to write a plug in for that, but I would also require a plug in for iOS so I don't know if that's the right way to go. Is there maybe another (easier) way to get the physical sensor size?


Unity Exporting and Importing Terrains To provide modding support via Unity editor, I need to export terrains in editor and load the exported terrain in runtime. Is this possible by any manner?


Unity2D Pressing my mute button twice in order for it to set music back to 1 So far my mute button works, its just that I have to press my button twice (when game is restarted) in order for it to put my volume back to 1. Does anyone knows the problem. Anyway this is my script public bool mute void Start() check if the player has a music volume preference if (PlayerPrefs.HasKey("musicVolume")) if yes, apply it. GetComponent lt AudioSource gt ().volume PlayerPrefs.GetFloat("musicVolume") private void Muted () AudioSource audioSource gameObject.GetComponent lt AudioSource gt () mute !mute if (mute) gameObject.GetComponent lt AudioSource gt ().volume 0 PlayerPrefs.SetFloat("mute", 0) else gameObject.GetComponent lt AudioSource gt ().volume 1 PlayerPrefs.SetFloat("mute", 1) write new music volume preference to persistent storage PlayerPrefs.SetFloat("musicVolume", audioSource.volume) Thank you. )


Should I package and sell my game on the unity3d asset store? I'm trying to figure out if I should refurbish and refactor a game I and some friends have made. It's released on kongregate and wasn't a super hit but I feel there's a lot of interesting techniques and solutions going on that new or intermediate developers would like to see. The only thing that's holding me back is that I don't know if people are interested in it at all. Would you be interested in buying the source code and assets for this game? Check it out and you'll see that there's a lot of things happening in the game. If we packaged it and sold it, we would of course tidy it up a bit which would involve more work so I would really appreciate your honest opinion. We've looked around and haven't found actual released games in the unity3d asset store. Maybe we just didn't look enough though. We're thinking of setting a price tag of between 150 and 200 . What's your opinion on this price? And in general, what's your opinion on selling assets and source code? Should I be wary of any legal implications (like my customer licensing my stuff and then forbidding me from selling it)? I posted this over at UnityAnswers as well but I know I rather go here for gamedev questions so I'm hoping other unity devs will drop by here too. Edit Reconsidering after getting some great advice we'll probably rip out the assets only and market those as space stuff or something. We'll then market the assets with the help of some free classes of code showing off some of the examples that were hard for us to do when we were (more) beginners. The unify wiki might benefit from having some of the code that we've done and that isn't all that hard but a bit tedious. If we actually "finish" the game (it is indeed an asteroids spinoff and was never intended to be anything else, apart from some sandbox modes we've been experimenting with) we'll probably sell it with a decent price tag for an indie game like this.


Animator from another gameobject keeps disappearing from script on play I am working on a gun script and it worked fine until earlier today when I made a change to the script and it stopped working. I put it back, but for some reason now the animator object attached to the script keeps disappearing. using System.Collections using System.Collections.Generic using UnityEngine public class RifleShooting MonoBehaviour private float NextTimeToFire 0f private int CurrentAmmo private bool IsReloading false Space(10) Header("Floats") public float Damage 10.0f public float Range 100.0f public float ImpactForce 60f public float FireRate 15f public float ReloadTime 1.0f Space(10) Header("Others") Space(5) Space(10) Header("Others") Space(5) public int MaxAmmo 10 public Camera FPSCamera public Animator GunAnimations public ParticleSystem MuzzleFlash public GameObject impactEffect public bool AllowedToShoot true Start is called before the first frame update void Start() GunAnimations GetComponent lt Animator gt () if (CurrentAmmo 1) CurrentAmmo MaxAmmo private void OnEnable() IsReloading false GunAnimations.SetBool("Reloading", false) Update is called once per frame void Update() if (IsReloading) return if (CurrentAmmo lt 0) StartCoroutine(Reload()) return if (AllowedToShoot false) return if (Input.GetButton("Fire1") Input.GetButtonDown("Fire1") amp amp Time.time gt NextTimeToFire) NextTimeToFire Time.time 1f FireRate Shoot() IEnumerator Reload() IsReloading true Debug.Log("Reloading...") GunAnimations.SetBool("Reloading", true) GunAnimations.SetBool("IsShooting", false) yield return new WaitForSeconds(ReloadTime .25f) GunAnimations.SetBool("Reloading", false) yield return new WaitForSeconds(.25f) GunAnimations.SetBool("IsShooting", true) CurrentAmmo MaxAmmo IsReloading false void Shoot() shooting script here Also if it helps here is what I see in the console when I try to fire MissingComponentException There is no 'Animator' attached to the "M4A1" game object, but a script is trying to access it.


Dynamic items in Scrollable Vertical Layout overlap Unity I have followed steps from this tutorial site to create dynamic scrollable vertical layout. I am trying to show 10 prefab buttons in a scrollview dynamically. I can see buttons at runtime, but they are overlapped. ScrollPanel Content Container I am probably missing some components tweaks. Or problem is due to anchors? Please guide me to resolve this issue. Thanks.


What is a good way to code dialogue creation? I'm thinking of making a single method class something that will handle my dialogue in the game. AKA, something like Main text Choice 1 Choice 2 So I want a method that will able to put different strings into the main text section and also different strings into the Choice options. I've been thinking about solutions, and so far I've come up with just a simple method that accepts parameters for main text, choice1 and choice2 problem being that the strings called will be quite long and I think it looks a little clumsy? Also I won't want to have 2 choices every time, OR I want to have multiple "pages" of dialogue show up before you need to take an action. This would require me to overload methods which may turn out quite ugly? So yeah I don't have a lot of experience with this and method overloading is all I've thought about for now. I've given thought to interfaces abstract classes but I'm not entirely sure if they're even relevant for what I want to do. Any thoughts?


Unity Unable to blend 2D Light renderers I've followed the documentation on Unity regarding 2D lighting. It said to turn on Alpha blending in the options. But this is how it turns out If Alpha blending is off If Alpha blending is on I'm not entirely sure why it's turning black. These are my settings for the 2D light I've checked my layers, specifically the tile map floor, and it's on the Default layer. I just want my lights to blend well.


Unity 5 how to toggle realtime global illumination I am using Unity 5.5. Is there a way to enable and disable precomputed realtime GI at runtime? and if so, how can I do it? The idea is that I want to set dynamic lights as a graphics quality option that the player can choose to toggle.


How can I edit multiple sprites in Sprite Editor at once? I have 100 sprites in one atlas. I want to edit some of them with same values. For example, I want to edit sprite's position no 1 30. Do I have to edit them one by one? Is there any function like Shift drag for selecting several sprites?


Create and serve AssetBundle at runtime What I am developing is not a game, but is done in Unity3d, so I believe here is a good place to ask. Context The unity application runs in the WebPlayer inside a web application Case User uploads a file on the website Webserver processes the file, does conversion and business stuff. Ends up with a DAE(Collada) file The DAE file that has been generated on the server needs to be loaded and shown in the Web player inside the browser of the one who uploaded it Now, I am not very well versed in Unity, so I just want to lay out what I expect to do, and then hope to get feedback on whether that is smart, or whether there is a better approach. So starting from top down, here's my thinking In order for the Web Player to find the file and use it as an asset, it should be an AssetBundle, which I can load with UnityWebRequestAssetBundle.GetAssetBundle that shouldn't be much trouble. If the AssetBundle is stored somewhere that the web app can serve it, I expect that to just work? I see in docs that Unity can load "AssetBundles from the project folder", but I don't expect that "project folder" is part of the game when loading from a URL. How would it? In order to generate the AssetBundle, I would need to have a Unity application running on the server (a headless build of unity), which would pick up the generated DAE file and use BuildPipeline.BuildAssetBundle to create the AssetBundle and store it where the web app can serve it The communication between browser, unity web player, web app server, and unity server instance is something I can manage on my own. I can work with sockets and jslibs to sort out my needs, so that doesn't need to be described here Instantiating the GameObject after loading the AssetBundle into the Web Player, I expect to be simple, just following the docs for the AssetBundle Extra credit Sources for how to do the headless unity instance would be great. Sort of like a game server, but not really caring about clients connecting, but rather working with the filesystem on the server


Where how do I store configuration files in Unity development? I am transitioning from working with cocos2d iphone to Unity. One particular thing I loved were the .plist files you could easily put any sort of configuration data you wanted for game levels, stats, etc. Now, with Unity, I am not entirely sure if I am supposed to be using such files. I suppose I can, but I'd rather adapt myself to whatever Unity developers use. What is the equivalent to property list files in Unity development? Plain text files?


Position and rotate a 2D point array into a 3D world I have a set of 2D points (defining a flat 2D 'connect the dots' shape). I want to calculate the 3D positions for these 2D points at a specific 3D position and rotation. For example, say I have five 2D points forming the shape of a 2D hexagon. I want to place this hexagon shape at a specific location in my 3D world, at a specific rotation. I need to calculate new 3D coordinates for each of the 2D points. If it matters, the 2D points will center around (0,0). What magic formula do I need to do to accomplish this translation? Is there a built in method (in Unity) to do this? Each point will be perpendicular to the rotation angle direction, so will I need to calculate the cross product? Then somehow use this to remap each 2D point? I should have paid more attention to this in school, all those years ago (I can't even remember if I actually learned this before!). Any help will be appreciated. Thanks. Here's some basic code to illustrate Vector3 position Where in 3D to place the 2D shape Quaternion rotation What 3D rotation to apply to the 2D shape. Should be a Vector3? Vector2 shapeIn List of 2D points defining shape Vector3 shapeOut List of updated 3D points at its new position and rotation shapeOut new Vector3 shapeIn.Length for (int p 0 p lt shapeIn.Length p ) shapeOut p MagicFormula(shapeIn p )


How to delete a score after collecting all collectibles I'm making a small game for my English class, and in the beginning, you have to collect rocks. I already have the code for counting how many rocks have been picked up, and the GUI to display while the game runs. After the player collects all 9 rocks I would like for the GUI to disappear or delete itself since it won't be used anymore throughout the game, and for new text to appear at the top of the screen saying "Go To The Lottery" I'm still very new to Unity so posting the code, and then following up with a brief explanation as to what does what would be majorly appreciated (but not at all demanded) Both codes are in JavaScript pragma strict static var currentScore int 0 var offsetY float 40 var sizeX float 100 var SizeY float 40 function OnGUI () GUI.Box (new Rect (Screen.width 2 sizeX, offsetY, sizeX, SizeY), "Rocks Collected " currentScore) This is my GameMaster script, which is in a empty game object galled " GM" pragma strict function OnTriggerEnter (info Collider) if (info.name "Player") GameMaster.currentScore 1 Debug.Log ("Picked stone up") Destroy (gameObject) This is my RockCollection script and it's what actually tells the GameMaster script to add 1 to the score and then delete the rock so you can't continuously pick it up


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 implement UI in Unity using Chromium? I'm looking for an alternative to UI Builder. Ideally I'd like to have basically a Chromium instance atop Unity3D which would have its JS calls somehow land in the C (maybe in the quot Update quot loop it listens to a constant stream of potential calls and the parameters will correspond to function names in my Unity code, I don't know) here's what I found which doesn't quite live up to my expectations Unity WebView doesn't support Windows. 3D WebView for Windows and macOS (Web Browser) requires the UI to be served on an actual live URL and for Unity to access it via that URL and for all interaction to be handled via API, impractical or slow at best. PowerUI HTML CSS is interesting, but was made in 2011. The documentation is all gone. the support for css feature is probably incredibly slim. Embedded Browser looks pretty good, but I'm unsure that it could be bent into a UI system. I want it to frame my game, not to cover it. Coherent Gameface looks probably the best, although the CSS implementation seems a tad lackluster. Also this project was started in 2012, it's probably carrying very old, very slow code. This Unity forum thread may be relevant. Chromium Embedded Framework was a tool used by some assets on the asset store to create chromium UI but it has been removed. If not using these assets, how can I implement my idea of using Chromium as my UI layer?


What is the "Unity" way to approach tech design for a 2D game like this? So I come from C land where I've always done every little thing myself. Now I'm getting into Unity and C and I'm ironically overwhelmed with the domain. I'm starting off with this simple little 2D game and I'm wondering... if someone can point me to the correct tools that would lead to a successful implementation of this game. Here is a quick mock up I did in paint These are the parts of Unity I've investigated Tilemap Canvas GridLayout Prefabs GameObjects (these seem fundamental to Unity, heh). After researching these topics, and playing around a bit, here are my initial questions How do you approach Canvases in Unity? I could see this being split into 5 separate Canvases, one for each local body of UI. Or 1 Canvas for the game board, and 1 canvas that contains a single overlay with all of the other UI components. But then how do those components typically get positioned? Is it common practice to place by absolute coordinates? I guess I'm getting hung up on.. how do I place my canvas for the game board in that position relative to all the other UI elements? I'm a C application developer so if I'm doing UI at all I'm used to layout systems. I'm not sure how common that is in this ecosystem. Should I even use TileMap for this? It doesn't seem like I need that kind of power. My grid is finite and fits on screen. My gut reaction is that I should just instantiate a bunch of colored squares at first. But I'm not really sure the best approach to that either. GridLayout on a canvas? Absolute coords? TileMap? What other tools should I be looking at? By tools I mean Unity concepts I didn't mention above. My initial thought is to just have a backing data structure that holds all the data for the grid, and then I just render... prefabs? based on that data? Maybe I just want someone to tell me I'm on the right track or quot no you're doing it totally wrong use this other thing quot , heh.


How can I play an animation only using C , without animation controller, or create an animation controller at runtime entirely from script? I've been looking around for a while trying to figure out how to play simple animations with Unity via ONLY C script, with no drag and drop involved. So far I've found various tutorials explaining how to manually set up a animation controller for each object, then manually select each animation state and manually create a transition then manually set the transition length to the most minimum possible etc... I was wondering if there's a simple way to just do something like... gameObject.playAnimation( "stand still which would be the name of the action state created in blender or other animation software ", "loop") ...WITHOUT creating an animation controller manually at all, I haven't been able to find any resource to do this simple thing yet.


How do I determine distance of a point within a ProBuilder mesh? As in the title, I have an effect prepped for my game which applies certain derived parameters to a post processing effect after the player enters a boundary I created with ProBuilder. Finding how far inside the bound the player is that is, how far the player would have to travel, at minimum, to leave it would help me scale this effect. It is not an axis aligned boundary, and its sloped shape is fairly important. Having the effect go full on on crossing the boundary would be jarring to the player. I'm tempted to resort to traditional edge testing with this, but I would like to highlight that it will be done at least once per frame on multiple objects, so I would like to keep it as simple, and non home rolled, as possible. The other possibility would be to keep track of time exposed and scale it by that but this isn't ideal and I'm seriously curious as to whether a penetration depth testing method exists out of box. A requested image of my setup It is laterally symmetric, and that is unlikely to ever need to change. However, future volumes are likely to have varying angles and heights. Depth is more or less irrelevant, as while I'm using 3D, this game has the physics of a 2D platformer so you can consider it to have infinite depth if you need to. As you can see on the right, I've added almost nothing to it, other than the MagneticField.cs custom script (which does not even reference the mesh, only whether it's been crossed) and a debug class, TriangleReport.cs, that I'm working on right now. One thought I had was to get triangles for the top, bottom, left, and right edges, use them to define planes, and then determine the distance from those planes but if you've got something better I am all ears!


Why don't we assign a class for each gameobject type in unity? I used to create games from scratch with C . There, people would create a "class Bullet", and add functionality to that class so that we can instantiate objects of class Bullet at runtime. However, in Unity (which I'm new to), we need to create a Bullet GameObject in the editor, and then assign "class BulletBehaviourA MonoBehaviour" to the Bullet GameObject. I don't really grasp this logic. Why don't we have a class for the Bullet in Unity?


Unity game crashing when dialogue with NPC initiated I have 3 NPCs in my "Game". When the player walks up to any of them, they're supposed to have their own dialogue I've tested this, and they do. I tried to create a display that shows this dialogue text using a TextMeshProUGUI attached to a blank GameObject called dialogDisplay (tagged DialogDisplay). There is one DialogDisplay object in the scene that I'm trying to get each of my NPC's to use. I tried to make the display object inactive in the NPC Start() function, and enable it when it's time to display the NPC's next sentence. When I run my game, I get an error on line 21, where SetActive() is called "Object Reference Not Set to an Instance of an Object". Here's the NPC script (DisplayNextSentence() is at the bottom, where dialogDisplay is used) public class NPC Character private bool charInRange public Dialogue dialogue public bool talkedTo false private Queue lt string gt sentences public TextMeshProUGUI textPro public GameObject dialogDisplay private bool isTalking Use this for initialization void Start () charInRange false textPro FindObjectOfType lt TextMeshProUGUI gt () dialogDisplay GameObject.FindGameObjectWithTag("DialogDisplay") dialogDisplay.SetActive(false) Update is called once per frame void Update () if player is in range and presses space, triggers NPC dialogue if (charInRange amp amp Input.GetKeyDown(KeyCode.Space)) TriggerDialogue() if Player gameObject is in NPC collider, player is in range void OnTriggerEnter2D(Collider2D other) if(other.gameObject.tag "Player") charInRange true if player exits NPC collider, player is not in range void OnTriggerExit2D(Collider2D other) if (other.gameObject.tag "Player") charInRange false if NPC has been talked to before, displays next sentence if not, loads dialogue and displays first sentence private void TriggerDialogue() if (!talkedTo) talkedTo true StartDialogue(dialogue) else DisplayNextSentence() loads a queue with lines from Dialogue and displays first sentence public void StartDialogue(Dialogue dialogue) sentences new Queue lt string gt () foreach (string sentence in dialogue.sentences) sentences.Enqueue(sentence) DisplayNextSentence() displays next sentence in the queue public void DisplayNextSentence() string sentence bool done false if last sentence in the queue, display it again if (sentences.Count 1) sentence sentences.Peek() textPro.text sentence Debug.Log(sentence) return sentence sentences.Dequeue() textPro.text sentence dialogDisplay.SetActive(true) while (!done) Debug.Log("In WHile Looop") if (Input.GetKeyDown(KeyCode.A)) done true dialogDisplay.SetActive(false) Grateful for any insight or tips you can provide. Happy to provide further information if it helps. Thank you!


Unity's "Stats" window displays bizzare number of triangles and vertices In my Unity scene I have 7 8 Barrels (with lids) each at about 2 400 triangles. 4 planes, each at at the very most 200 triangles camera, 3 lights, a FPS controller When I turn on the "Status" button in the lower left view port, it reports "14.1K triangles and 12.k vertices" I've double checked everything, there's no way the elemens in the scene can amount to so many triangles. The barrels in both Blender and Unity report having the number of triangles I've specified above Here's a Blender screen shot And here's one from Unity I've also checked the Hierarchy panel to see if I haven't accidentally duplicated stuff which might get to be on top of stuff (such as 100 barrels all in the same position so as to look as if there's just one there), and this is not the case. So my question is am I misinterpreting the Unity stats window? Is it a bug in the reported triangles count there? Or am I just completely missing how all this works ?


Unity3d CarController character positioning issue I use the unity standard asset components CharacterController and Car and put an empty gameobject onto the car where the camera should be placed when i am inside the car. The empty gameobject is called "Driver". The character controller has an empty called "Head" where its head is. When i get in the car i perform the following operation GameObject car GameObject.Find("Car") transform.position car.transform.Find("Driver").transform.position Vector3.up 1 transform.parent car.transform.Find("Driver").transform Camera.main.transform.position car.transform.Find("Driver").transform.position Camera.main.transform.rotation car.transform.Find("Driver").transform.rotation and to get out of it, i use the following GameObject car GameObject.Find("Car") transform.position car.transform.position transform.parent null transform.rotation Quaternion.identity Camera.main.transform.position transform.Find("Head").transform.position My problem is when i get into the car and out again, the character is positioned at the position where i have entered the car, so it doesnt seems to update its position with the car movement. What am i doing wrong? Thanks in advance


How do I move a game object instead of the entire scene in Unity? I'm trying to move GameObject between scenes but when I do it moves my whole scene instead of just that one game object. How do I move just the game object and not the whole scene? I have tried SceneManager.MoveGameObjectToScene(UIRootObject, sceneToLoad) and DontDestroy but it keeps moving my whole scene new scene.


Can you use a standard multi thread if only reading unity objects? First of all I know about coroutines and how to use them (they're awesome). A friend of mine was telling me about the way the he implemented his saving system in a game he was working on, after asking him what he was using I found out that he is using system.threading and not coroutines to save data. I know that Unity isn't thread safe but apparently he has had no issues with saving which leads me to wonder if it is ok to use normal threads as long as you're only reading data and no pre existing data is modified in the gameworld? would this affect the game at all (other than some moving objects being slightly ahead of where they should be because of the time it took to get to that object and save it)?


Controlling Unity 3D cube with remote gyroscope This probably will go into conceptual things as well, but what I would like to do is take a Raspberry Pi (with a Sense Hat), transmit the gyro values to Unity, and effectively have a 1 1 realistic representation of orientation changes. I have no problem transmitting values from the Pi to Unity (though learning about hidden firewall rules was fun), however I am lacking some understanding of how to transform raw gyro values to something representative in Unity. I have not calibrated the Sense hat recently, but know that is something that should be done. For example, I am transmitting the pitch roll yaw values from the Pi (resting normally, these are about 100.30272132022793, 351.3885231076573 354.9306950697191). I have a cube gameobject that I've flattened out and set to the origin. My question is basically, what is the best way to translate raw values from some anonymous object to the Unity coordinate system, and have it rotate appropriately? I don't necessarily want its position to change, just rotation. Screenshot for reference. Raspberry Pi sending gyro data is on the left, Unity is on the right. Tabletop (flattened cube) is what I'd like to rotate to simulate a ball balancer.


Simple Game Feasibility Unity Turbo Squid 0 ? I've been coding 2D games exclusively for a while, partly because I have very limited graphics skills, partly because it takes less effort to make something look great, and partly because I have very limited time in which to code. I have an idea for a very simple 3d kids game that I'd like to build it would be based around a player roaming a randomly generated city and looking for a particular building (eg. dollar store, grocery store, bank, etc.) My question is Would it be feasible to build this in Unity, using only free models and animation (presumably from Turbo Squid), in a decent time frame? In terms of features, this would range in extremes from "generate some random buildings, paths, and select one as the winning building to locate" to adding people to talk to, objects to interact with (water, ladders, keys and locks, ropes, etc.) I haven't touched 3D modelling for years (I used 3D Studio Max 3.x back in high school), and I don't have 3 4 hours to spend creating, rigging, and animating models. That's really the crux of my doubt. I also don't have cash that I can spend on models animation. So to summarize, my main two questions are Is it feasible to create a decent quality game using free stuff from Turbo Squid? Are many most all of the models from TS compatible with Unity?


Stop Camera up movement I am developing 3D game , the main camera is child of player. When player jumps camera too gets move up with player as its child of player.Is there anyway to stop this behavior? The only thing I can guess is to make camera separate gameobject and let it follow player EDIT After applying Everless Drop 41's script, here is what main problem arises


How do I check if animation is of Animation Type "Humanoid"? One can set the Rig Animation type of an animation to quot Generic quot , quot Humanoid quot , etc. How could I check by script if an animation rig has been set to type quot Humanoid quot ?


why does my objects only spawn once or really slowly? public GameObject fallingRockPrefab public Vector2 spawnsMinMax float randX float randY void Update() if (Time.time gt nextSpawnTime) float SpawningInBetween Mathf.Lerp(spawnsMinMax.y, spawnsMinMax.x, Difficulty.GetDifficultyPercent()) print(SpawningInBetween) nextSpawnTime Time.time SpawningInBetween randX Random.Range( 5.6f, 5.6f) randY 5.57f SpawnPosition new Vector2(randX, randY) Instantiate(fallingRockPrefab, SpawnPosition, Quaternion.identity) I set the quot spawnsMinMax quot over at the inspector in Unity as high as I can like (25 or 30 etc) but it still spawns once or like 1 or 2 per second. Even I set the number as low it can go, it still spawn in the same way. How do I fix this?


Keypress Left is called twice in Update when key is pressed only once I have a piece of code that is changing the position of player when left key is pressed. It is inside of Update() function. I know, Update is called multiple times, but since I have an ifstatement to check if left arrow is pressed, it should update only once. I have tested using print statement that once pressed, it gets called twice. Problem Position updated twice when key is pressed only once. Below given is the structure of my code void Update() if (Input.GetKeyDown (KeyCode.LeftArrow)) print ("PRESSEEEEEEEEEEEEEEEEEEDDDDDDDDDDDDDD") How can I fix this?


Why is my enemy kill code not working? I'm trying to make an enemy for my game, and everything works, except for the bit of code where the enemy is supposed to die. My player attacks but nothing happens. I filled in the prefabs, I have the right tags, I tried remaking it and I can't find anything that is wrong. What am I doing wrong? pragma strict var EnemyItself GameObject var EnemyCorpse GameObject function OnTriggerEnter(other Collider) if (other.gameObject.tag "Hero Punch") EnemyItself.SetActive(false) EnemyCorpse.SetActive(true)


Instances in the Unity Profiler Timeline What do Instances mean when you click on an operation in the Timeline section of Unity Profiler? In this example Total 11.90 ms (10 Instances)


Adding 90 degree Y rotation into script I'm using the following script to move a spray bottle around a head. It should looke like in a barber shop. The code works fine I have assigned the script to the spray bottle, and I have set the head as the target. One thing that is wrong is that the spray bottle needs to have a 90 yaw rotation in order to face the head. I have tried the wildest things to include these 90 degrees, all produced weird results. Could anybody state how to include this 90 Y rotation into the script? Thank you very much! using UnityEngine using System.Collections AddComponentMenu("Camera Control Mouse Orbit with zoom") public class MouseOrbitImproved MonoBehaviour public Transform target public float distance 5.0f public float xSpeed 120.0f public float ySpeed 120.0f public float yMinLimit 20f public float yMaxLimit 80f public float distanceMin .5f public float distanceMax 15f private Rigidbody rigidbody float x 0.0f float y 0.0f Use this for initialization void Start () Vector3 angles transform.eulerAngles x angles.y y angles.x rigidbody GetComponent lt Rigidbody gt () Make the rigid body not change rotation if (rigidbody ! null) rigidbody.freezeRotation true void LateUpdate () if (target) x Input.GetAxis("Mouse X") xSpeed distance 0.02f y Input.GetAxis("Mouse Y") ySpeed 0.02f y ClampAngle(y, yMinLimit, yMaxLimit) Quaternion rotation Quaternion.Euler(y, x, 0) distance Mathf.Clamp(distance Input.GetAxis("Mouse ScrollWheel") 5, distanceMin, distanceMax) RaycastHit hit if (Physics.Linecast (target.position, transform.position, out hit)) distance hit.distance Vector3 negDistance new Vector3(0.0f, 0.0f, distance) Vector3 position rotation negDistance target.position transform.rotation rotation transform.position position public static float ClampAngle(float angle, float min, float max) if (angle lt 360F) angle 360F if (angle gt 360F) angle 360F return Mathf.Clamp(angle, min, max)


Retractable object in unity I'm trying to get the physics of a retractable object in unity, So I will be able to quot launch quot an elastic cable (similar to rope physics) out of an object (e.g. A gun), And the cable will gradually exponentially quot roll back quot into the object. A good reference would be Batman's grapple gun. I thought of utilizing it using a spring joint, but I can't really get the exact mechanics I'm trying to achieve. Any ideas? Thank you in advance.


Why is clicking too fast giving me a missingReferenceException in Unity? I made a small method that will quickly give the player a "flashlike" display when a sheep is killed. However clicking too fast will trigger a missingReferenceException. Because it registers the raycast a second time. Is this due to the delay on the DestroyObject() or something else? private IEnumerator startFlashing(GameObject sheep) sheep.gameObject.GetComponent lt Rigidbody gt ().freezeRotation true sheep.gameObject.GetComponent lt Rigidbody gt ().velocity Vector3.zero sheep.SetActive(false) yield return new WaitForSeconds(theTimeBetweenFlashes) sheep.SetActive(true) DestroyObject(sheep.gameObject, 0.1f)


JSON Parse (Invalid Value) My settings.json (generated with JsonUtility.ToJson) "masterVolume" 0.10000000149011612, "fullScreenMode" 1, "cheatsEnabled" false Offending line SettingsData sd JsonUtility.FromJson lt SettingsData gt (Application.dataPath " Settings settings.json") My SettingsData class. System.Serializable public class SettingsData SerializeField public float masterVolume SerializeField public int fullScreenMode SerializeField public bool cheatsEnabled public SettingsData(float masterVolume, FullScreenMode fullScreenMode, bool cheatsEnabled) this.masterVolume masterVolume this.fullScreenMode (int)fullScreenMode this.cheatsEnabled cheatsEnabled I really can't fathom why it's having trouble reading this back in, I even tried to save the enum as an int instead, but still no luck.


Unity Objects become black when size is changed to smaller While working with Unity 5.4, my models become black when I resize them to a smaller scale. When I make the models bigger they are fine. I am using a directional light . On the image below as you can see on the left the model is fine. But the others are black. HOPE YOU CAN HELP.


Button Press Detection not working while detecting collision I am trying to make a sign that brings up a panel when you press Enter while the player is over the sign. The code I have written is using System.Collections using System.Collections.Generic using UnityEngine public class SignScript MonoBehaviour public GameObject Panel void OnTriggerEnter2D(Collider2D other) if (other.tag "Player") UnityEngine.Debug.Log("Triggered1") if (Input.GetAxis("Submit") 1) UnityEngine.Debug.Log("Triggered2") if (Panel false) Panel.SetActive(true) UnityEngine.Debug.Log("Triggered3") I added code that prints "Triggered1", "Triggered2", and "Triggered3" to the Debug Log when you reach certain parts of the code. When the player is over the sign and is pressing Enter, it should print "Triggered2". For some reason, it is not doing this. Does anyone know why?


Generating the distance of an intersection through a box from the camera in Unity C So, I recently saw this fantastic video by Sebastian Lague about planetary generation https www.youtube.com watch?v lctXaT9pxA0 amp t 1100s And I decided to replicate it, however, on a flat plane, not a sphere.In the video, (at timestamp linked) he uses some mathematical expression to figure out the distance of the camera's vector through an arbitrary sphere, and uses this to shade the ocean. I can't figure out how to write a similar estimator for an arbitrary rectangular prism. Anyone have any ideas? EDIT I have shifted to using surface shaders, but I can't figure out how to compensate for distance in depth Shader quot Custom SurfaceDepthShader quot Properties ColorShallow ( quot Color Shallow quot , Color) (1,1,1,1) ColorDeep ( quot Color Deep quot , Color) (1,1,1,1) MainTex ( quot Albedo (RGB) quot , 2D) quot white quot Glossiness ( quot Smoothness quot , Range(0,1)) 0.5 fadeDepth( quot Base Alpha quot , Range(0,1)) 0.5 InvFade ( quot Soft Factor quot , Range(0.01,3.0)) 1.0 SubShader Tags quot Queue quot quot Transparent quot quot RenderType quot quot Transparent quot LOD 200 CGPROGRAM Physically based Standard lighting model, and enable shadows on all light types pragma surface surf Standard vertex vert alpha fade nolightmap Use shader model 3.0 target, to get nicer looking lighting pragma target 3.0 sampler2D MainTex struct Input float2 uv MainTex float4 screenPos float3 worldPos float eyeDepth half Glossiness half Metallic fixed4 ColorShallow fixed4 ColorDeep sampler2D float CameraDepthTexture float4 CameraDepthTexture TexelSize float InvFade float fadeDepth void vert (inout appdata full v, out Input o) UNITY INITIALIZE OUTPUT(Input, o) COMPUTE EYEDEPTH(o.eyeDepth) void surf (Input IN, inout SurfaceOutputStandard o) Albedo comes from a texture tinted by color fixed4 c tex2D ( MainTex, IN.uv MainTex) ColorShallow smoothness come from slider variables o.Smoothness Glossiness float rawZ SAMPLE DEPTH TEXTURE PROJ( CameraDepthTexture, UNITY PROJ COORD(IN.screenPos)) float sceneZ LinearEyeDepth(rawZ) float partZ IN.eyeDepth float dist distance( WorldSpaceCameraPos, IN.worldPos) float fade 1.0 if ( rawZ gt 0.0 ) Make sure the depth texture exists fade saturate( InvFade (sceneZ partZ)) o.Albedo lerp( ColorShallow, ColorDeep, fade) c o.Alpha c.a fade fadeDepth ENDCG FallBack quot Diffuse quot


First object jumps on re entry of second colliding object The scenario is that I have two objects Object A and Object B. The Object A is lying on the ground and when Object B enters the collider of Object A, the Object A moves (only X and Z axis) with Object B. The movement works well with the script shown below. The issue is that most of the time, the Object A's initially position shifts by few meters whenever Object B enters its collider. I feel it is related to offset position. What should happen is that, Object A should be the same position when Object B enters the collider and move along with Object B only when Object B moves. So how do I fix this? private Vector3 offsetPosition public Transform ObjectB public bool ObjectB Collision false void Start () offsetPosition ObjectB.transform.position this.transform.position void ObjectB HasEntered() offsetPosition ObjectB.transform.position this.transform.position Update is called once per frame void LateUpdate () if (ObjectB Collision true) this.transform.position new Vector3 (ObjectB.transform.position.x, this.transform.position.y, ObjectB.transform.position.z) new Vector3 (offsetPosition.x, 0, offsetPosition.z) public void OnTriggerEnter (Collider col) if (!enabled) return if (col.gameObject.name quot Object B quot ) ObjectB HasEntered() ObjectB Collision true public void OnTriggerExit (Collider col) if (!enabled) return if (col.gameObject.name quot Object B quot ) ObjectB Collision false


How to get position of next object that closest to player,when player is move forward to nearest every time? I have a scene that looks like the following picture The Player has a RigidBody2D and all the steps have a BoxCollider2D. All steps are tagged with a 'step' tag. I would like to let the player move to the next step, every time the user presses a key. In this case, I'll need to get the position of the next step that is the closest to the player, every time the player moves to the next position. I have tried the following so far using UnityEngine using System.Linq public class Box MonoBehaviour the rigidbody of the box private Rigidbody2D player2D Start is called before the first frame update void Start() player2D GetComponent lt Rigidbody2D gt () void Update() if (Input.GetKeyDown(KeyCode.Space)) Vector2 targetPosition GetNextTargetTransform(player2D.position ) here set trajectory to move from current position to target position Vector2 trajectory SetTrajectory(player2D, targetPosition) player2D.AddForce(trajectory, ForceMode2D.Impulse) after reach the position update player position to current position player2D.position targetPosition public Vector2 GetNextTargetTransform(Vector2 player2Dposition) GameObject step GameObject.FindGameObjectsWithTag("step") here is the code to get the nearest object using LinQ var nearest step.OrderBy(t gt Vector2.Distance(player2Dposition, t.transform.position)).FirstOrDefault() Transform nearestPosition nearest.transform Vector2 targetPosition new Vector2(nearestPosition.position.x, nearestPosition.position.y) return targetPosition I am able to get the position of the first step when a button is pressed, but when I press the key again, I am unable to get the position of the next step (and thus remain on the first position). I've added player2D.position targetPosition after AddForce(...) and the player will directly appear on the first step and move to the next one, which is not the result I want. Question How do I get the position of the nearest step, every time the player moves to a new step?


Unity How to make script work with duplicated objects? I have an object in my game that, when clicked, causes the player to move toward it. It does this by sending its position to the player's SetTarget function. The player's Move function then heads toward the position. This is working, but when I duplicate the object and click on it, the player still moves toward the original object's position. When I print debugging statements to the console, it appears that both positions are being calculated, but the original position is the last one and wins out. (I'm using the object's this.transform.position to send the position to the player's SetTarget function.) Can I not duplicate objects like this and expect the script to work? Do I need to use a prefab? If so, how? I know how to create prefabs but am not sure what I would need to change with the script or other settings when they are created. Thanks. Here's the code public class PotController MonoBehaviour private GameObject chefObject void Start () chefObject GameObject.Find ("Chef") void Update() if(Input.GetMouseButtonDown(0)) print ("pot clicked!") ChefController chefScript chefObject.GetComponent lt ChefController gt () print (this.gameObject.transform.position) chefScript.SetTheTarget (this.gameObject.transform.position) public class ChefController MonoBehaviour private Vector3 target public float speed 2 Use this for initialization void Start () target this.transform.position private void MoveTowardsTarget() Vector3 targetPosition new Vector3(0,0,0) targetPosition target Vector3 currentPosition this.transform.position check distance to target if(Vector3.Distance(currentPosition, targetPosition) gt 0.4f) Vector3 directionOfTravel targetPosition currentPosition directionOfTravel.Normalize() this.transform.Translate( (directionOfTravel.x speed Time.deltaTime), (directionOfTravel.y speed Time.deltaTime), (directionOfTravel.z speed Time.deltaTime), Space.World) void Update () MoveTowardsTarget () public void SetTheTarget (Vector3 position) target position


Images disappear when camera zooms in there is no problem when the camera is away, but as I zoom in to the game, the images disappear and I can't see the game properly. What is the reason ?


Can the GUI be used to create game objects? I want to be able to position 10 various game objects (sprites) within the area of the screen which will be dynamically sized accordingly to the screen size of the device. The area in which I want to position the items will be about 70 of the screen. The objects will be rectangles with irregular size (slightly irregular). The object should be positioned randomly (or in grid) within this area but they should not overlap. The objects will be a drop targets for other object which I will drag onto them. To summarize I need The area in which I can place objects. Random object position er. As I have been reading and watching various tutorials I have become very confused about how should I approach this. Should I use a Rect to draw the area on which I will then place the objects, or should I use GUI UI elements i.e. panel? Are the GUI UI elements suitable for achieving this or are they meant to be only used to create games menus not for actual game play?


How to apply a script to multiple Objects in Unity? In Unity, I've almost 200 or more objects. I wish to apply single script to all those objects. I'm a beginner amp learning scripts in Unity. Edit At the time of editing the scene itself.


Blender mesh mirroring screws up normals when importing in Unity My issue is as follows I've modeled a robot in Blender 2.6. It's a mech like biped or if you prefer, it kindda looks like a chicken. Since it's symmetrical on the XZ plane, I've decided to mirror some of its parts instead of re modeling them. Problem is, those mirrored meshes look fine in Blender (faces all show up properly and light falls on them as it should) but in Unity faces and lighting on those very same mirrored meshes is wrong. What also stumps me is the fact that even if I flip normals in Blender, I still get bad results in Unity for those meshes (though now I get different bad results than before). Here's the details Here's a Blender screen shot of the robot. I've took 2 pictures and slightly rotated the camera around so the geometry in question can be clearly seen Now, the selected cog wheel like piece is the mirrored mesh obtained from mirroring the other cog wheel on the other (far) side of the robot torso. The back face culling is turned of here, so it's actually showing the faces as dictated by their normals. As you can see it looks ok, faces are orientated correctly and light falls on it ok (as it does on the original cog wheel from which it was mirrored). Now if I export this as fbx using the following settings and then import it into Unity, it looks all screwy It looks like the normals are in the wrong direction. This is already very strange, because, while in Blender, the original cog wheel and its mirrored counter part both had normals facing one way, when importing this in Unity, the original cog wheel still looks ok (like in Blender) but the mirrored one now has normals inverted. First thing I've tried is to go "ok, so I'll flip normals in Blender for the mirrored cog wheel and then it'll display ok in Unity and that's that". So I went back to Blender, flipped the normals on that mesh, so now it looks bad in Blender and then re exported as fbx with the same settings as before, and re imported into Unity. Sure enough the cog wheel now looks ok in Unity, in the sense where the faces show up properly, but if you look closely you'll notice that light and shadows are now wrong Now in Unity, even though the light comes from the back of the robot, the cog wheel in question acts as if light was coming from some where else, its faces which should be in shadow are lit up, and those that should be lit up are dark. Here's some things I've tried and which didn't do anything in Blender I tried mirroring the mesh in 2 ways first by using the scale to 1 trick, then by using the mirroring tool (select mesh, hit crtl m, select mirror axis), both ways yield the exact same result in Unity I've tried playing around with the prefab import settings like "normals import calculate", "tangents import calculate" I've also tired not exporting as fbx manually from Blender, but just dropping the .blend file in the assets folder inside the Unity project So, my question is is there a way to actually mirror a mesh in Blender and then have it imported in Unity so that it displays properly (as it does in Blender)? If yes, how? Thank you, and please excuse the TL DR style.


Real Time Speech Verbal Communication with a Mecanim Character What would be the simplest method of integrating real time verbal communication within a mecanim character that is already being used in a Unity app project? Something like an SDK or toolkit? I have such a character that is animated by a motion capture device, so the user puts on the suit and the Unity character is driven by receiving live motion data. This is the non verbal part for research in Social Sciences amp Psychology. I tried integrating the Virtual Human Toolkit into my Unity app to use its real time speech amp lip sync amp facial gestures, but their character is set up in a complicated way, so I still cannot animate it by using my motion capture device. So, now I am thinking what is the next best thing to do with a Unity mecanim character to make it say something, etc...?


Why is unity's RaycastHit2D contact point is slightly off This is a small test I made, basically I have a simple BoxCollider2D that has the top surface aligned with the x axis. It's just a 1x1 cube placed at (0, 0.5). Now when I cast a ray down from position (0, 1) I would expect the resulting RaycastHit2D's contact point to be (0, 0) however when I log the contact point, it shows it is slightly over the actual surface at (0, 2.384186E 07). So the question is, why does this happen? Also, can it be fixed somehow (like tweaking settings or something)?


Convert a modified Transform.forward to world space I am trying to make an electricity system, where it is given the start and end points, and it works out a random sequence of points in the rough direction of the end point. These points are set as vertices on a line renderer, and it should end up joining up as a bolt of electricity. My problem is that it needs to move 'forward' from start to end. The easy solution is that the electricity comes from a game object, which is set to LookAt the end point. Then, every time it sets a 'nextPoint', it adds to the transform.forward. nextPoint new Vector3 ((startingPoint.forward.x divergence.x), (startingPoint.forward.y divergence.y), distance) divergence is a Vector3 containing a random increase on the x and y axis, and 1 on the z axis. This works, in a way. The problem is that it then assumes these are world space coordinates. So the line will go from starting point, to (eg. 0.3, 0.75, 1), and then back to the end point. I can't find a localToWorld conversion for a vector though, so I am not sure how to get the transform.forward whatever, converted from local to world space.


How can I call Schedule() on interface that inherits from IJob So I have a voxel terrain engine, and I have an interface that all meshing jobs should inherit from. That looks like this (simplified from the actual) public interface IMesherJob IJob VoxelDataVolume lt byte gt VoxelData get set NativeArray lt MeshingVertexData gt OutputVertices get set NativeArray lt ushort gt OutputTriangles get set One example of a meshing job is marching cubes, which looks like this public struct MarchingCubesJob IMesherJob So here's my question If I have a reference to an IMesherJob, can I somehow call Schedule on it? If I have a reference to MarchingCubesJob, I can call Schedule on it This works MarchingCubesJob myMeshingJob GetMeshingJob() JobHandle handle myMeshingJob.Schedule(voxelCount, 64) But this does not work IMesherJob myMeshingJob GetMeshingJob() JobHandle handle myMeshingJob.Schedule(voxelCount, 64) I noticed that Schedule() is an extension method for T where T struct, IJob so that might be interfering with it, but it should still work because IMesherJob inherits from IJob


What is causing my 3rd person camera to lose rotation on the z axis? I've been working on a 3rd person camera on unity for a couple weeks, but I've pretty much hit a wall, specifically to do with my camera's rotation. When I rotate it on its x and y axis it won't have a problem, but when it gets to the z axis (180 degree's on the x axis), it loses the ability to rotate at all. This is the code I've been using void Start() controlls camera relevent to player position offset new Vector3(Player.position.x 3.0f, Player.position.y 2.0f, 0) offset transform.position Player.position localtoworldY transform.TransformPoint(Vector3.left) void Update() need to give proper rotation of the camera around the player offset Quaternion.AngleAxis(Input.GetAxis("Mouse X") turnSpeed, Vector3.up) offset offset Quaternion.AngleAxis(Input.GetAxis("Mouse Y") turnSpeed, localtoworldY) offset transform.rotation Quaternion.LookRotation(offset, Vector3.up) transform.position Player.position offset transform.LookAt(Player.position) print(transform.rotation) If the y axis go to 6.4 positive, it should stop but not stop working, same as if the camera hits a mesh or terrain. If the camera changes in any direction regardless of x or y axis,player should be able to move relative to the direction that the player is pressing (IE when the player press left, the Homicida malorum will move left regardless of the angle of the camera). Any advice or an explanation as to why this is happening would be much appreciated.


Unity Grid Layout causing multiple draw calls We are developing a game in Unity 4.6.6 for both Android and iOS. Currently I am building the game UI with the new Unity UI system. In particular I am building a button list to create kind of inventory slots using the Grid Layout. I have noticed that my draw call count is increasing considerably despite having my UI in an atlas (using Sprite packer) and using the same font all over the UI. After some tests I noticed that one draw call is generated per each UI Text and UI image present in the scene composing each button when using a Grid Layout Group, when the Grid Layout is not used the draw calls are reduced noticeably. 7 elements without Grid Layout, results in 2 draw calls (Screenshots taken in play mode) 7 elements WITH Grid Layout, resulting in 14 draw calls (Screenshots taken in play mode) I have no idea if it is possible to reduce the number of draw calls when using the Grid Layouts.


How does Application.genuine work? In Unity, does anyone know exactly what is behind the scenes of Application.genuine? More specifically, I would like to understand its exact process so I can understand If I can use it safely without "false negatives". If it considers text (or other) assets stored in a Resources folder (e.g. my level config files). Just for context, I want to say that my target platform is iOS.


Tilemaps not showing up on Android build I'm having trouble developing a 2d game for Android. I use tilesmaps for the ground and a few other things. On the editor, everything works fine and dandy. But, when I deploy to a phone(Build and Run), the tiles aren't there. It's like they never existed. I go back to the editor and they're there. I play the game directly from the editor and they're there. I even play the game while running unity remote, on the test phone, and the tiles are there. No idea what's going on. This only happens with tilemaps. Everything that isn't a tilemap is visible. I'm running Unity 2019.3.0f6


Script not working (Function not changing value) I have this script that I made for an FPS character. public class Player Movement MonoBehaviour public CharacterController controller public Transform camera public float gravity 9.81f public Transform groundCheck public float groundDistance 0.4f public LayerMask groundMask bool grounded public GameObject joystick public bool isMoving public float speed 12f public float turnSmoothTime 0.1f float turnSmoothVelocity public float jumpHeight public Vector3 yPosition public bool jumpAble true Update is called once per frame void FixedUpdate() grounded Physics.CheckSphere(groundCheck.position, groundDistance, groundMask) if (grounded) yPosition.y 2f jumpAble true Vector3 direction new Vector3(joystick.GetComponent lt Joystick gt ().inputDirection.x, 0f, joystick.GetComponent lt Joystick gt ().inputDirection.y) isMoving direction.magnitude ! 0 ? true false if (isMoving) controller.Move(direction speed Time.deltaTime) yPosition.y gravity Time.deltaTime UnityEngine.Debug.Log(yPosition) controller.Move(yPosition Time.deltaTime) public Vector3 Jump() UnityEngine.Debug.Log(jumpAble) UnityEngine.Debug.Log(grounded) if (jumpAble amp amp grounded) jumpAble false yPosition.y Mathf.Sqrt(jumpHeight 2 gravity) UnityEngine.Debug.Log(yPosition.y) UnityEngine.Debug.Log(yPosition) return yPosition return yPosition The game operates on mobile touch controls, and the Jump() is called when the jump button is pressed. However, the character does not jump when I press the button, even though the function is being called, and the yPoisition is being changed in the function. I know that changing the yPosition should make the player jump, as when I add this code to the Update if (Input.GetKey(KeyCode.Space) amp amp jumpAble) fallDown.y Mathf.Sqrt(jumpHeight 2 gravity) Everything works fine. Why is the new yPoisition value not being passed to Update, and why is this happening?


Why is transform.up behaving differently for different functions? Can anyone please explain to me what i'm doing wrong here? As I see it the raycast is the only one using transform.up correctly, though why not Debug.DrawLine() and lineRenderer.SetPosition(1, transform.up maximumBeamLength) using UnityEngine RequireComponent(typeof(LineRenderer)) public class LaserBeam MonoBehaviour SerializeField private float maximumBeamLength 5f private LineRenderer lineRenderer private void Start() lineRenderer GetComponent lt LineRenderer gt () void Update() lineRenderer.SetPosition(0, transform.position) RaycastHit2D hit Physics2D.Raycast(transform.position, transform.up) Debug.DrawLine(transform.position, transform.up maximumBeamLength, Color.blue) Debug.DrawLine(transform.position, transform.up , Color.red) if (hit.collider) lineRenderer.SetPosition(1, new Vector3(hit.point.x, hit.point.y, transform.position.z)) else lineRenderer.SetPosition(1, transform.up maximumBeamLength)


Painting a Wall and Calculating the Paint Percentage in Unity I'm trying to paint a wall in Unity by following this tutorial however I don't know how can I calculate the paint percentage and not paint the lines that have been already painted, and also not go beyond plane boundaries. Painting needs to be using swerve mechanics. What would be the approach to accomplish this?


Why does my mesh move when i add an avatar? I've imported a wall model into my scene, it snaps to the other walls fine until I add an avatar to the model to animate it, then it moves. here's some picture to explain The first picture in the scene This picture is in the game


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


How do I increase the spawn rate of an object as the "difficulty" goes on? I just want my objects to spawn in a faster rate as time goes by. The print(SpawningInBetween) print out shows the percentage of the difficulty overtime. This is the code I have public Vector2 spawnsMinMax Spawn Positions Vector2 SpawnPosition float secondsBetweenSpawn 1 float nextSpawnTime void Update() if (Time.time gt nextSpawnTime) float SpawningInBetween Mathf.Lerp( spawnsMinMax.y, spawnsMinMax.x, Difficulty.GetDifficultyPercent()) print(SpawningInBetween) nextSpawnTime Time.time SpawningInBetween nextSpawnTime Time.time secondsBetweenSpawn ... I was thinking of going like this if(Time.time gt Difficulty.GetDifficultyPercent lt 0.9) but it got a compiler error.


Black screen after running emulation mode in the Unity Editor for hololens I am having issues with black screen when running the emulation mode or simulator for Microsoft hololens. In the preview the camera shows what the user should see. I see no obvious reason to behave like this and no error warning is given. I am using code snippets from the Origami tutorial,except I chose to use RayCastNonAlloc. Movement.cs public class Movement MonoBehaviour public GameObject person public float seconds private Vector3 point new Vector3(0,0,0) private RaycastHit rayHit new RaycastHit 5 void OnSelect() person.transform.position Vector3.Lerp(person.transform.position, point, seconds Time.deltaTime) Update is called once per frame void Update() if (Physics.RaycastNonAlloc(Camera.main.transform.position, Camera.main.transform.forward, rayHit, Mathf.Infinity, 0) gt 0) foreach (RaycastHit hit in rayHit) point.x Mathf.Clamp(hit.point.x, 290f, 6970f) point.y Mathf.Clamp(hit.point.y, 40f, 1860f) point.z Mathf.Clamp(hit.point.z, 1700f, 140f) Scene.cs using UnityEngine using UnityEngine.XR.WSA.Input public class Scene MonoBehaviour public GameObject cursor public GameObject Focused get private set public Scene Instance get private set private GestureRecognizer recognizer private MeshRenderer Renderer private readonly RaycastHit rayHit new RaycastHit 5 void Awake() Instance this recognizer new GestureRecognizer() recognizer.Tapped (args) gt if (Focused ! null) Focused.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver) recognizer.StartCapturingGestures() Renderer cursor.GetComponent lt MeshRenderer gt () void Update() GameObject oldFocused Focused if (Physics.RaycastNonAlloc(Camera.main.transform.position,Camera.main.transform.forward,rayHit,Mathf.Infinity, 0) gt 0) Renderer.enabled true foreach ( RaycastHit hit in rayHit) cursor.transform.position hit.point cursor.transform.rotation Quaternion.FromToRotation(Vector3.up, hit.normal) Focused hit.collider.gameObject else Focused null Renderer.enabled false if (Focused ! oldFocused) recognizer.CancelGestures() recognizer.StartCapturingGestures()