I am trying to make a game like temple run 2. I want the same effect as stated in question and as attached screenshot. I tried with Animation its working when I animate the coin to center top but no luck with top left corner. Please Help. Thanks
Here is code:
if (col.gameObject.tag == "500") {
score = CryptograpicEncryption.GetInt ("ScoreKey") + pick500;
CryptograpicEncryption.SetInt ("ScoreKey", score);
ScoreCount.text = "Cash Collected: " + CryptograpicEncryption.GetInt ("ScoreKey").ToString ();
col.gameObject.GetComponent<Animator> ().SetTrigger ("openNote");
col.gameObject.transform.GetChild (1).GetChild (1).gameObject.SetActive (false);
col.gameObject.GetComponent<Animator> ().SetTrigger ("highLeft");
}

It depends on your game but here are some options:
Add an empty gameobject to your character and carefully set its position so that it always be positioned behind the desired ui object. Then move the coins from 3d space into the 3d space position of the game object.
Remove the coin as soon as the player get it, then create an identical coin using UI.Image in its place (in 2d space of canvas) immediately moving to the corner of canvas. You can convert 3d space position to 2d using 2dPosition = Camera.main.WorldToScreenPoint(3dPosition)
You can calculate the 3d position of the corner of the canvas using 3dPosition = Camera.main.ScreenToWorldPoint(2dPosition) and make the coins follow that location. But the location changes overtime as the camera moves so you should recalculate it every frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With