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 Kourosh · Oct 07, 2010 at 11:21 AM · terrainarraytile

How to Instantiate into a terrain array?

My code creates tiles of terrains on start, I wanna use SetNeighbors to connect each Instantiated terrain to its neighbors. here is my code:

var terrainMember:Transform; var terrainRow:int=20; var terrainCol:int=20; private var terrainTile:Terrain[] = new Terrain[400]; function Start () {

 for (var row=1;row<terrainRow;row++){
 var newRow = 100*(row-1);
     for(var col=1;col<terrainCol;col++){
         var arrayPosition = col-1+(terrainRow*(row-1));
         var newCol=100*(col-1);
         terrainTile[arrayPosition] = Instantiate(terrainMember,Vector3(newRow,0,newCol),Quaternion.identity);

 }
 }
 }

The problem is on start it only creates one terrain and gives me an error: "Cannot cast from source type to destination type."

I need to have this array so that i can easily assign each terrain its neighbors. Otherwise I tried doing the same thing using a transform array and it just works fine. Any clue? thanks,

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 Abquhazar · Sep 17, 2014 at 11:33 PM 0
Share

Did anybody have a good solution for this? I'm interested in knowing as well.

2 Replies

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

Answer by Slem · Oct 07, 2010 at 12:27 PM

Thats because the terrainTile array expects a "Terrain", but gets an "object". Just cast the Instantiated oject to Terrain like this: (Terrain)Instantiate(terrainMember....

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 Houndie · Dec 07, 2010 at 02:51 AM

Getting the same issue even with casting the instantiated as terrain.

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

best tile size for terrain? 2 Answers

Tiled terrains - where to put, when to load? 0 Answers

Tile generation problem 1 Answer

How to combine all meshes in an array (JAVASCRIPT) 0 Answers

Is it possible to make a texture tile unevenly? 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