Unity 2D - Instantiated prefab inconsistent position across devices?
I have made a 2d android racing game using unity 5. i was testing the game on my phone(Asus Zenfone 5 with lollipop) it worked perfectly also tested the game on other phone(Samsung Galaxy Duos with jellybean) worked Perfectly as well. BUT when i tested it on Samsung Galaxy s5 the instantiated prefabs have a different Y coordinate value(they start being instantiated from the middle of the screen & they were suppose to instantiate from the top corner). Vector3 carPos = new Vector3 (Random.Range(-0.95f, 1.0f), transform.position.y, transform.position.z); carNo = Random.Range(0, 4); Instantiate (cars[carNo], carPos, transform.rotation);
For a 2D game, you use Vector2s to save coordinates instead of a Vector3s. I believe that this problem occurs, because the screen size of the different devices are different. To solve this problem try using versatile measurements like Screen.width or Screen.height when positioning. For example, if you were trying to instantiate a car in the top right corner of the screen you would use Vector2 carPos = new Vector2(Screen.width, Screen.height); Instantiate (cars[carNo], carPos, transform.rotation); You can implement the random x coordinates of the cars with Random.Range() with respect to the Screen.width.
sending Post on facebook wall [closed]
Draw a rectangular over an image by code
How to implement debug logs in Android's JNI
Android - How to get the image using Intent data
Image OCR Android
Android: Identify that phone is connected to a guest network over wifi
Can't stop a service started with alarmManager
ProgressBar not updating correctly after return to Activity
Android child activity and orientation lock
Android - Proper way of using AsyncTasks?
In-App Payments for Android Amazon AppStore
Obfuscation error - NoSuchMethodError: android.view.LayoutInflater.inflate
Result from Native Call always Returns 1717986916
Android: RuntimeException with PreferenceScreen and Custom Attributes from inside a Library Project
SQLite - Select and Integer type
Can we give the integer value of the secondary camera in setVideoSource?