Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by prashantmgk · Aug 01, 2020 at 07:18 PM · particlesystemparticle collision

Unity Coin Collect Effect , UI Overlay

So I wonder if anyone knows how to obtain this effect.


As shown in the following video, the diamond sprites gets attracted towards the counter. Please help me obtain this effect.


My assumptions are, they probably used Particle effects and Force field. But, since I haven't done it, I have no exact idea.


Desired Effect

asd.gif (502.3 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ntsparmar · 22 hours ago

using UnityEngine; using DG.Tweening; using TMPro; public class GemMagnetEffect : MonoBehaviour { public GameObject Gemprefab; public GameObject _gemparent; public Transform Gemcollector, MoneyUIParent; public TextMeshProUGUI currencyText;

 private void Start()
 {

 }

 public void spawnDiamond(Vector3 pos, int coinAmount)
 {
     //iOSHapticController.instance.TriggerNotificationSuccess();
     //int coinAmount = Random.Range(1, 4);
     for (int i = 0; i < coinAmount; i++)
     {
         Transform t = Instantiate(Gemprefab.transform, transform.position, Quaternion.identity, _gemparent.transform);
         
         //disable sparkle particle
         t.GetChild(0).GetChild(0).gameObject.SetActive(false);
        // t.gameObject.layer = diamondLayer;
         t.gameObject.SetActive(true);
         Vector2 canvasPos;
         Vector2 screenPoint = Camera.main.WorldToScreenPoint(pos);
         RectTransformUtility.ScreenPointToLocalPointInRectangle(_gemparent.GetComponent<RectTransform>(), screenPoint, Camera.main, out canvasPos);
         t.localPosition = canvasPos;
         t.transform.localScale = new Vector3(1f, 1f, 1f);
         float size = Random.Range(30f - 5f * i, 30f - 5f * i);
         t.DOScale(new Vector3(size, size, size), 0.1f);
         Vector3 randomPos = new Vector3(Random.Range(t.localPosition.x - 100, t.localPosition.x + 100),
                                         Random.Range(t.localPosition.y - 100, t.localPosition.y + 100),
                                         0);
         float time = Random.Range(.3f, .6f);
         t.DOLocalRotate(new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)), time).SetEase(Ease.Linear);
         Sequence seq = DOTween.Sequence();
         Vector3 finalPos = Gemcollector.localPosition;
         seq.Append(t.DOLocalMove(randomPos, Random.Range(.3f, .6f)).SetEase(Ease.Linear));
         seq.Append(t.DOLocalMove(finalPos, time).SetEase(Ease.Linear));
         seq.Join(t.DOScale(new Vector3(15, 12, 15), time).SetDelay(0.2f));
         seq.OnComplete(() =>
         {
             //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
             Destroy(t.gameObject);

             PREF_DATA.COINS++;
             currencyText.text = PREF_DATA.COINS.ToString();


             MoneyUIParent.DOPunchScale(new Vector3(0.2f, 0.2f, 0.2f), .3f);
             MoneyUIParent.DOScale(new Vector3(1, 1, 1), 0.4f);
         });
     }
 }

 //public LayerMask diamondLayer;
 public void spawnCoinOnUI(Vector3 pos, int coinAmount)
 {
     int amountToAdd = 1;
     int remainder = 0;

     if (coinAmount > 100)
     {
         amountToAdd = coinAmount / 100;
         remainder = coinAmount % 100;
         coinAmount = 100;

         //add reminders to coin
         PREF_DATA.COINS += remainder;
     }


 

     for (int i = 0; i < coinAmount; i++)
     {
         Transform t = Instantiate(Gemprefab.transform, transform.position, Quaternion.identity, _gemparent.transform);
         t.gameObject.SetActive(true);
         //t.gameObject.layer = diamondLayer;

         t.localPosition = Vector3.zero;
         t.transform.localScale = Gemprefab.transform.localScale;
         t.transform.localEulerAngles = Vector3.zero;
         Vector3 randomPos = new Vector3(Random.Range(t.localPosition.x - 150, t.localPosition.x + 150),
                                         Random.Range(t.localPosition.y - 150, t.localPosition.y + 150),
                                         0);
         Sequence seq = DOTween.Sequence();
         

         seq.Append(t.DOLocalMove(randomPos, Random.Range(.3f, .6f)).SetEase(Ease.OutBack)).OnComplete(()=> {

             //t.GetComponent<diamondMove>().diamondTarget = Gemcollector.GetComponent<RectTransform>();
         });
         seq.Append(t.DOMove(Gemcollector.position, Random.Range(.3f, .6f)).SetEase(Ease.Linear));
         seq.OnComplete(() =>
         {
             //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
             Destroy(t.gameObject);
             PREF_DATA.COINS += amountToAdd;
             currencyText.text = PREF_DATA.COINS.ToString();
         });
     }
 }


}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

134 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why can't I add non-prefab colliders to a particle effects triggers list? 0 Answers

Particle emission on particle collision 2 Answers

How to make particles collide with something but at the same time phase through it 2 Answers

Shuriken collision with terrain? 0 Answers

Getting the position/intersection of collided particles 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges