Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Pranav-Paharia · Mar 03, 2015 at 06:19 AM · distribution

Coin Genration Algorithm in Runner Game

I'm making a runner game sequel like subway surfer. Here are the following mechanics I've done:

  • Platform Generation

  • Enemy Generation

  • Power up Generation

  • Point Generation

    Out of these I have problem in generating points algorithm. I have a vision of having points like Subway Surfer game. And right now I was just able to put them randomly on the lanes. Here is my code for Random distribution in lanes.

public void PositionCoins(Vector3 position) { int maxZ = (int)position.z + 17; int minZ = (int)position.z - 59; for(int i = 0;i < coinList.Count;i++) { int randomZ = Random.Range(minZ,maxZ);

         int randomLane = Random.Range(1,5);
         int lane;
         if(!coinList[i].activeInHierarchy)
         {
             if(randomLane == 1)
             {
                 coinList[i].transform.position = new Vector3(-1.35f,1.2f,randomZ);
             }
             else if(randomLane == 2)
             {
                 coinList[i].transform.position = new Vector3(0.05f,1.2f, randomZ);
             }
             else if(randomLane == 3)
             {
                 coinList[i].transform.position = new Vector3(1.45f,1.2f, randomZ);
             }
             else if(randomLane == 4)
             {
                 coinList[i].transform.position = new Vector3(2.85f,1.2f, randomZ);
             }

             coinList[i].SetActive(true);
         }
     }
 }

Now what I want is coins like Subway Surfer randomly distributed in a group of 4-5 coins, equally spaced. Any help is appreciated.

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 alok-kr-029 · Mar 03, 2015 at 06:30 AM

I am not reviewing your code but I will explain what I did in my game a Year ago I made a group of prefabs of coins with onTrigger in it and then randomly instantiate those prefabs with equal spacing

which worked perfectly .

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

21 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

Related Questions

Which game portal websites accept Unity webplayers? 31 Answers

I finish a game and I want distribute it, what I need? 1 Answer

Game Distribution dvd 0 Answers

how do i distribute data over a network once. 0 Answers

About Transprent mode 2 Answers


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