Unity cloning parabolic gold coin method

Source: Internet
Author: User
Tags pow


1. Prepare the object we want to clone: gold coins

public gameobject coin;

2. Calculate the function of the parabola and figure out the location of the clone according to the function:


<summary>//    Cloning of parabolic gold coins////</summary>//    <param name= "pos" > Clone the location of the first gold coin </ Param>    //<param name= "num" > Clone gold Number </param>    //<param name= "spacing" > distance between 22 coins </ param>    void Loadcoinmethod (Vector3 pos,int num,float spacing)    {        Vector2 inityz = new Vector2 (pos.z, POS.Y)///record parabolic first gold position        float Sysmmetryaxis = inityz.x + (num/2 + (num% 2 = = 0)? 0.5f:1) * spacing;//calculates parabola symmetry 
   float hight = inityz.y + Mathf.pow ((pos.z + Spacing-sysmmetryaxis), 2)/num;//parabolic 0 parameters for        (int i = 0; i < nu M i++)        {            pos.z + = spacing;            Pos.y = Hight-mathf.pow ((Pos.z-sysmmetryaxis), 2)/num;            Gameobject Tempcoin = (gameobject) instantiate (coin,pos,quaternion.identity);                    }    }

3. View (num = 15,spacing = 1.2f):




Unity cloning parabolic gold coin method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.