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 Mattias-Wargren · Jan 07, 2011 at 09:40 AM · 3d2d-platformermodeldrawingground

Best way of creating curved ground for a 2d platformer

What is the best approach when creating ground (curves and slopes) for a 2d platform game? The game will have a lot of levels. Do I use 3d models or is it better to "draw" the levels in Unity? If it is better to draw it, is there a way of generating the level in code? That would make it easier editing the levels.

alt text

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by runevision · Jan 07, 2011 at 09:46 AM

Unity doesn't have built-in tools to create new geometry or meshes, so you can't "draw" your levels in Unity.

You have to create meshes in external applications like 3ds Max, Maya, or Blender and import them into Unity.

You can either create a whole level in the external program, or create many "building blocks" that you can then assemble into a level inside Unity. The latter approach of course gives you greater flexibility in Unity and also means that you may be able to cut down on the data size of your game since the same building blocks can be reused many times.

It would be possible to make editor scripts to create tools so you could draw your level inside Unity. However, this will be a major effort, and will require good scripting knowledge. Examples of similar things exist: 3rd party tools for Unity exist (look in the Asset Store) for creating curved roads and rivers directly inside Unity. It just takes work to create such tools.

Comment
Add comment · Show 2 · 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 Mattias-Wargren · Jan 07, 2011 at 02:18 PM 0
Share

Updated my question with an image. How would you create that ground?

avatar image runevision ♦♦ · Jan 07, 2011 at 05:33 PM 0
Share

Like I wrote, you'd have to create it in external applications like 3ds $$anonymous$$ax, $$anonymous$$aya, or Blender. Once you know how to use one of those programs, creating a ground like in the image should be no problem.

avatar image
0

Answer by milkplus22 · Dec 17, 2014 at 10:07 PM

you could scale and rotate some cubes like this (prefab is just a simple unit cube)

         float segmentSize = 0.1f;
         int numSegments = 20;
         Vector3 nextPosition = new Vector3 (0, 0, 0);
 
         for (int i=0; i<numSegments; ++i) {
             Vector3 p1 = nextPosition;
             Vector3 p2 = p1;
             p2.x += segmentSize;
 
             // modulate Y coordinate to follow a sine wave
             float r = 2f;
             float s = (Mathf.PI * 2f) * 0.05f;
             p1.y += Mathf.Sin (p1.x * s) * r;
             p2.y += Mathf.Sin (p2.x * s) * r;
             
             float angle = Mathf.Atan2 (p2.y - p1.y, p2.x - p1.x) * Mathf.Rad2Deg;
             Vector3 scale = new Vector3 ();
             scale.x = Vector3.Distance (p1, p2);
             scale.y = 0.1f;    // make the ground thin
             scale.z = 1f;
             
             Transform o = (Transform)Instantiate (prefab);
             o.localScale = scale;
             o.localPosition = p1;
             o.localRotation = Quaternion.identity;
             o.Rotate (0f, 0f, angle);
             
             nextPosition.x += segmentSize;
         }
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

1 Person is following this question.

avatar image

Related Questions

How do i Achieve mesh Extrusion? 2 Answers

Outline Shader not working correctly on blender models 0 Answers

3D Model problems 1 Answer

3D CITY MODELS??????? 4 Answers

Are Imported SketchUp files bad for optimization? 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