- RSS Channel Showcase 9864730
- RSS Channel Showcase 8450793
- RSS Channel Showcase 3950044
- RSS Channel Showcase 3780006
- 08/13/18--02:08: Answer by IvovdMarel
- 08/13/18--02:10: Answer by IvovdMarel
- 09/12/18--07:16: Answer by IvovdMarel
- 09/19/18--11:20: Answer by IvovdMarel
- 09/19/18--11:22: Answer by IvovdMarel
Is Container referencing the prefab? If you don't Instantiate the object, the Start function will never run on it.
The easiest way to have the camera follow the position and rotation of another object is to make it a child of that object.
If you really only want to follow the rotation and add an offset I would go for
transform.rotation = player.transform.rotation + Quaternion.Euler(45,0,0);
You can just look at the source-file at the bottom but probably worth checking out the video
A common mistake of the 'while' loop. Anything that you put in while will infinitely repeat until the condition is no longer true. This is very different then putting something in Update, which checks every frame, but just once.
In your case, Input.GetMouseButton(0) is true in one frame, and then the while loop runs infinitely in a single frame (until Unity crashes) since there's no condition for it to leave that while loop.
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
#elif (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8)
ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit))
endPoint = hit.point;
rb2d.AddForce(endPoint * speed);
You should (almost) never change the z-value of UI elements. To order, change the hierarchy in Unity. In this case, it seems like the blue background is actually part of the button. Therefore, when duplicated, it will be rendered on top of any other buttons after it in the hierarchy.
To avoid other rendering issues, also make sure the z-value of all elements is 0.