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 /
  • Help Room /
avatar image
0
Question by CascadiaLeijona · Sep 03, 2015 at 03:03 AM · matrixslicingbce0048

Rewriting Cellular Automata C# to JS

Hey all. If you've gotten this far, thanks for reading. I'm a new programmer and I already know a little bit of JavaScript so I intend to use that as my development language for now. I'm trying to work my way through Sebastian Lague's procedural generation tutorial and I'm having to rewrite the code as I go. I was doing fine until I ran into assigning values to the spaces in the matrices for the initial map roll. Here's my code:

 var height: int;
 var width: int;
 var fill: float;
 
 function mapGen(width, height) {
     var map = [width, height];
     mapFill(width, height);
 };
 
 function mapFill(width, height) {
     for (var x = 0; x <= width; x ++) {
         for (var y = 0; y <= height; y ++) {
             if (x == 0 || x == width - 1 || y == 0 || y == height - 1) {
                  map[x,y] = 1;
             };
             else {
                 map[x,y] = (Math.random() < fill);
             };
         };
     };
 };

Unity keeps throwing errors at the map[x,y] lines. The error is BCE0048: Type "function(object, function): System.Collections.IEnumerable" does not support slicing. This is really irksome to me because the function it seems to be complaining about is apparently invisible. The syntax it gives me does not point me to any errors elsewhere in my code.

I haven't worked it out past those errors. If you see anything else, feel free to point it out, but I don't think I'll have issues with anything else.

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 CascadiaLeijona · Sep 04, 2015 at 03:39 PM

It looks like my error was in the matrix generator code. I wrote out a nested array function and it seems to be working fine now.

 var matrix = [];
     for (x = 0; x < w; x++) {
         matrix[x] = new Array(h);
 };

Might need to fine-tune this but it got rid of the errors, so I'm happy.

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 Green_Ghost · Dec 22, 2015 at 03:26 PM 0
Share

I'm having quite a bit of trouble converting this as well. If you could show me some finished code that does the same thing that would be a great help. I'm trying to create an algorithm that combines Cellular Automata and BSP Tree, but I can't really get anywhere if I don't know how to write the code for Cellular Automata. Any help would be greatly appreciated.

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

28 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

Related Questions

Find border of Matrix (east, west, north, south) 0 Answers

I cant figure out why my array is causing the error 'System.Type' does not support slicing. 0 Answers

How do I optimize transforming vertices to screen space? 1 Answer

3d grid/matrix inside a mesh 1 Answer

Rotate gameObject by applying rotation matrix in unity3d 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