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 vipvex · May 01, 2012 at 04:21 AM · meshproceduralcreate

Adding and removing specific triangles ?

I'm trying to create procedural terrain made out of cubes. I have and array of cubes and i'm trying make each cube check if there's air next to it, if there is this script will create a side as needed, but it doesn't work for some reason. Am I doing something wrong ? I need to add a face to an already existing mesh. Here's my script bellow.

public function UpdateChunkBlocks(){ var vertices : Vector3[]; var uvs : Vector2[]; var newMesh : Mesh; newMesh = transform.GetComponent(MeshFilter).mesh; //newMesh = newMesh.mesh; newMesh = new Mesh(); var p1 : Vector3 = new Vector3(.5 + transform.position.x, .5 + transform.position.y, .5 + transform.position.z); var p2 : Vector3 = new Vector3(.5 + transform.position.x, .5 + transform.position.y, -.5 + transform.position.z); var p3 : Vector3 = new Vector3(-.5 + transform.position.x, .5 + transform.position.y, -.5 + transform.position.z); var p4 : Vector3 = new Vector3(-.5 + transform.position.x, .5 + transform.position.y, .5 + transform.position.z); var p5 : Vector3 = new Vector3(.5 + transform.position.x, -.5 + transform.position.y, .5 + transform.position.z); var p6 : Vector3 = new Vector3(.5 + transform.position.x, -.5 + transform.position.y, -.5 + transform.position.z); var p7 : Vector3 = new Vector3(-.5 + transform.position.x, -.5 + transform.position.y, -.5 + transform.position.z); var p8 : Vector3 = new Vector3(-.5 + transform.position.x, -.5 + transform.position.y, .5 + transform.position.z); for (var c = 0; c <= 4096; c++) { for (var b = 0; b <= 4096; b++){ var cBlock; cBlock = c; //every block in the array var bBlock;//every block that is being checked bBlock = b; if(bBlock.Position == cBlock.Position + Vector3(0, 1, 0) && bBlock.Type == "air"){ vertices[0] = p1; vertices[1] = p2; vertices[2] = p3; vertices[3] = p3; uvs[0] = new Vector2(0, .5); uvs[1] = new Vector2(.5, .5); uvs[2] = new Vector2(.5,0); uvs[3] = new Vector2(0, 0); newMesh.triangles += [0, 1, 2, 0, 2, 3]; newMesh.vertices += vertices; newMesh.triangles += [0, 1, 2, 0, 2, 3]; newMesh.uv += uvs; } } } newMesh.RecalculateNormals(); newMesh.RecalculateBounds(); } I get this error message every time. MissingFieldException: Field 'System.Int32.Position' not found. Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates) Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos) Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter () Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name) Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name) Boo.Lang.Runtime.RuntimeServices+c_AnonStorey14.<>m_9 () Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name) UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)

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 Paulius-Liekis · May 02, 2012 at 08:47 AM

cBlock and bBlock are type int in your case. type int has no method Position.

My recommendation: use C# and you will get error like that during compile time. Or add "pragma strict" (or something like that) to your JS files.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Can unity handle this city (it's multiple meshes)? 1 Answer

creating a mesh procedurally 4 Answers

Easy way to convert a bunch of vertices to triangles or uv's? 1 Answer

minimize vertex artifacting for procedural mesh manipulations - vertex collision same object? 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