Gui object movement in canvas

Updated on October 7, 2018 in [A] Brackeys Courses
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on October 7, 2018

Hi guys;

Im trying to instantiate a gameobject into a canvas and make it move across the screen using rigidbody added to it and all seems fine until in changed the csnvas resolution to an ipad scrren size, then the gameobject movement becomes slow and all gameobject falls on each other which isnt happening on iphone screen resolution..

 

 

Below is my code for instantiating gameobject into canvas

public IEnumerator SpawnCups(int prefabIndex = -1){
 while (true) {
 yield return new WaitForSeconds (2s);
 GameObject go;
 if (prefabIndex == -1) {
 go = Instantiate (activeTiles [RandomPrefabIndex ()]) as GameObject;
} else {
 go = Instantiate (activeTiles [prefabIndex]) as GameObject;
 }
 go.transform.SetParent (NozzleMouth);
 go.transform.position = NozzleMouth.transform.position;
 go.GetComponent<RectTransform> ().localScale = new Vector3 (1, 1, 1);
 }
 }

 

Below is the cod for gameobject movement in the canvas

void FixedUpdate () {
 rb.velocity = new Vector2 (10f 0);
 }

 

 

Please Help

  • Liked by
Reply