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
3
Question by abda · Jan 23, 2014 at 06:19 PM · infinite terrain

Making infinite terrain

hey guys how are you doing

i want to know how to make an infinite terrain that repeats itself like subway surfers for an example ..

Thanks

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by JeChris · Sep 03, 2014 at 11:58 AM

You can do infinite terrain in fact. You should use fractal generation of heighmap in realtime.

Generate heighmap on heighnour terrain and update it when hero moving and you will get infinite

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
avatar image
1

Answer by fafase · Jan 23, 2014 at 06:25 PM

You cannot make infinite terrain. You can make it real long so that it looks infinite but technology does not allow infinite for computers.

Now to answer your question, I have not play subway surfer but it looks like this old thing we had on tv in the 80's with a guy called Hugo and a mine cart.

The easiest way would be to have the guy not moving in forward space, just left and right. Then the world is moving in front of him. Then when you reach a certain point of the level, let's say 1/2 of it because then you would start seeing the edge of it, you instantiate a new portion of level adjacent to the other one. When you reach the end of the old portion, you remove it. And you repeat that "infinitely". On top of that, Subway surfer seems to use a fog to hide the end of the track and the new one created.

The reason why it is better to keep the guy static is because if you go for reaaaaal long, then when you reach 10000, float value loses accuracy (Unity will show a warning). You can still start from -10000 until 10000 which is about 20km walk (semi marathon) but I would recommend the static guy instead.

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
avatar image
0

Answer by viju · Aug 22, 2016 at 12:27 PM

An alternate way of doing it is to create a long 'Plane' 3D object (Scale: X= 50, Y=1, Z=500; Position: 0, Rotation: 0). Let us call it 'Ground'. Create a green material and apply it to the plane to give it a green landscape look.

Create another plane in the middle (Scale: X=1, Y=1, Z=500; Position: X=0, Y=0.2, Z=0, Rotation: 0). Let us call it 'Path'. Create a dark-grey material and apply it to the path.

Move the Main Camera (Position: X=0, Y=10, Z=-1809; Rotation: X=20, Y=0, Z=0).

Place a capsule 3D object on the path (Position: X=0, Y=1.5, Z=-1800) and make the Main Camera as the child of the capsule object.

Add three random objects on the path: Cube (Position: X=-3, Y=1.5, Z=-800), Sphere (Position: X=-4, Y=1.5, Z=-1700) and Cylinder (Position: X=3, Y=1.5, Z=-1300)

Add a RigidBody component to the capsule (Check 'Use Gravity' and under 'Constraints > Freeze Rotation', check X, Y, Z).

Finally, add the following C# code to the capsule object.

 using UnityEngine;
 using System.Collections;
 
 public class PlayerBehaviour : MonoBehaviour
 {
     // Update is called once per frame
     void FixedUpdate()
     {
         transform.Translate(Vector3.forward * 0.75f);
         if (Input.GetKey(KeyCode.LeftArrow))
             transform.Translate(Vector3.left * 0.25f);
         if (Input.GetKey(KeyCode.RightArrow))
             transform.Translate(Vector3.right * 0.25f);
         if (Input.GetKey(KeyCode.UpArrow))
             transform.Translate(Vector3.up * 0.25f);
         if (transform.position.z > -700f)
         {
             transform.position = new Vector3(transform.position.x, transform.position.y, -2000f);
         }
     }
 }
Comment
Add comment · Show 1 · 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 viju · Aug 22, 2016 at 12:34 PM 0
Share

We can place a lot of random objects on the 'Ground' and 'Path' and Randomize the environment when transform.position.z > -700f to get a better infinite feel. No need to create new terrain in this case. Just randomize the environment.

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

19 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

Related Questions

Infinite terrain generation algorithm problems 1 Answer

2D Infinite Terrain Generation Performance Issues 0 Answers

How to give a Terrain a material at runtime? 1 Answer

How can I apply horizon curvature to infinite worlds? 2 Answers

Terrain Like minecraft 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