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 alexander11 · Aug 20, 2016 at 09:59 PM · c#unity 53dverticesduplicate

How do i create multiple vertices from an object?

Hello, this is rather a simple question but i cant really understand on how to do it, i am trying to achieve something like this in Pic1, but the results i am getting are in Pic2. Does anyone know how to do this?

NOTE: there is a post on about this at this site

-Pic1. alt text -Pic2. alt text Here is what my code so you know what i have done.

 using UnityEngine;
 using System.Collections;
 
 public class Extruder : MonoBehaviour {
 
     public Mesh prefab;
     public int length;
     private Mesh mesh;
 
     private Vector3[] vertices;

     void Start()
     {
 
         vertices = prefab.vertices;
         Generate();
     }
     // Update is called once per frame
     void Generate () {
 
         vertices = new Vector3[(length)];
         for (int i = 0, x = 0; x <= length; i++, x++)
         {
             vertices[i] = new Vector3(0, 0, x);
         }
         mesh.vertices = vertices;
     }
     private void OnDrawGizmos()
     {
         Gizmos.color = Color.black;
         for (int i = 0; i < vertices.Length; i++)
         {
             Gizmos.DrawSphere(vertices[i], 0.1f);
         }
     }
 }
 

@Bunny83 @Fattie

capture26.png (51.6 kB)
capture27.png (93.8 kB)
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 Fattie · Aug 20, 2016 at 11:37 PM

um - your problem is X and Y are always the same, in fact zero.

 vertices[i] = new Vector3(0, 0, x);

you are setting them to zero every time.

you want to weave FOUR points. something like this ...

you have this:

 vertices[i] = new Vector3(0, 0, x);

you should have this:

 vertices[i] = new Vector3(-1, -1, x);
 vertices[i] = new Vector3(-1,1, x);
 vertices[i] = new Vector3(1, 1, x);
 vertices[i] = new Vector3(1, -1, x);

it is very common when you are weaving mesh that you have code like that: for each trip through the loop you may be making say 6, 8 or whatever points.

try to travel around anticlockwise if possible, just as a matter of style. note you will absolutely need to become expert at using gizmo balls during development if you are not using them already

(1) I would just point out that "generating mesh" is pretty difficult; you probably still have a ways to go and many other problems to solve

(2) this site answers.unity3d just works really poorly these days. for example I am never logged in, it seems to constantly log me out, and the site barely works and has many bugs. StackOverflow is incredibly lame and uncool, but there are nowadays huge numbers of Unity questions on there. I would probably encourage you to ask on there.

There are many superb essays by people both intelligent and witty on there, often sober too :) example pls go here http://stackoverflow.com/a/35891919/294884 and vote it up. see you there

Comment
Add comment · Show 4 · 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 alexander11 · Aug 21, 2016 at 12:36 AM 0
Share

Thanks but ins$$anonymous$$d of creating the points individually, how will i make it where i can just add a mesh and gather its vertices then multiply them across an axis?

I have registered to stackoverflow as TheRapidSloth i'll be checking out that site.

avatar image Fattie alexander11 · Aug 21, 2016 at 10:36 AM 0
Share

If you mean you want to take a shape and "extrude" it. Realistically you would just get an asset from the asset store to do that. It takes some six man-months of work to write extrusion software. Just look on the software for mega-shapes, ProSplines and so on. Cheers.

avatar image alexander11 Fattie · Aug 21, 2016 at 10:44 PM 0
Share

Thanks, but i would like to know how to code it, and not to go to the asset store and purchase an asset, would you know any tutorials or sites i could learn this from?

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

230 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 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 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

Getting errors with extrusion script. 0 Answers

How can I generate a up facing quad mesh with adjustable res? 0 Answers

Procedurally generated mesh acting weird. 0 Answers

How do i Extrude a 2D mesh(or Model) from one point to another? 1 Answer

How do i create lines in scene view?? 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