Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Arun8897 · Feb 17, 2018 at 04:57 PM · 2d-platformerendless runnerrandomspawningrandomizing

Want 3 different Random Platforms in x direction

I have 3 different platforms of various size

Platform one = 1 unit in size
platform two = 2 units in size
Platform one = 3 units in size

I want them to be generated in random order in X direction endlessly with random space (5-8 units) in between them.

Can anyone Help me

Comment
Add comment · Show 1
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
avatar image Arun8897 · Feb 17, 2018 at 05:44 PM 0
Share

Platform three = 3 units in size

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dmitriy-untilov · Feb 19, 2018 at 02:09 PM

Idea described in following pseudocode:

 var Platforms; //platform prefabs
 var startingPoint = vector3.zero

in Update function:

 Select Random platform from Platforms array and make Instance of prefab
 var space = random(5,8)
 platform.position = startingPoint
 startingPoint += platform.size + space //next position

Also you can optimize this algorithm. You can make a pool of predefined platforms and when some platform goes out of the camera you can swap platform`s position instead of using Instantiation each time.

Comment
Add comment · Show 9 · 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
avatar image Arun8897 · Feb 19, 2018 at 03:04 PM 0
Share

Bro can you explain me clearly. I didn't get what I expected

alt text

capture-platform.png (31.3 kB)
avatar image Xpartano Arun8897 · Feb 28, 2018 at 03:36 PM 0
Share

You didn't get what you expected because you expected the final code you want to implement. @dmitriy-untilov has showed you the way in pseudocode, and you should translate that to code. If you can't translate pseudo code to code I strongly recommend you watching all the official scripting tutorials from Unity's webpage. You can find them here: https://unity3d.com/es/learn/tutorials/s/scripting

Unity Answers is to submit doubts or issues and try to solve problems, not to tell what you want and expect someone to write down all the code.

Regards.

avatar image dmitriy-untilov · Feb 19, 2018 at 03:06 PM 0
Share

show your code and what you have please

avatar image Arun8897 dmitriy-untilov · Feb 19, 2018 at 03:16 PM 0
Share

Thanks for your help. I got It

avatar image Arun8897 dmitriy-untilov · Feb 19, 2018 at 03:21 PM 0
Share

I want the player to jump 2 time if I press any key 2 times & jump 3 time if I press any key 3 times. And other input should not work until the player complete 2 jumps if I press any key 2 times.

How can I do it.

avatar image dmitriy-untilov Arun8897 · Feb 19, 2018 at 03:29 PM 0
Share

To implement jumping you need to add Rigidbody2D component to your character and use rigidbody2D.AddForce(new Vector2(0, 10), Force$$anonymous$$ode2D.Impulse);

Show more comments

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

81 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

Related Questions

2D side scroller/flappy bird clone 0 Answers

Spawning prefabs randomly on top of existing tiles 2 Answers

how t make a random number generator for a 2d endless side scroller 1 Answer

Simple random spawning system for 10 items without duplicates 2 Answers

2D Player Movement 0 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