• 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 LearningWhileScrewing · May 17, 2017 at 08:30 PM · scripting problem

Is this script old o.0?

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class TetrisObject : MonoBehaviour {

 float lastFall = 0f;

 void Start () {
     
 }

 void Update () {

     if (Input.GetKeyDown (KeyCode.LeftArrow)) {
         transform.position += new Vector3 (-1, 0, 0);

         if (IsValidGridPosition ()) {
             UpdateMatrixGrid ();
         } else {
             transform.position += new Vector3 (1, 0, 0);
         }

     } else if (Input.GetKeyDown (KeyCode.RightArrow)) {
         transform.position += new Vector3 (1, 0, 0);

         if (IsValidGridPosition ()) {
             UpdateMatrixGrid ();
         } else {
             transform.position += new Vector3 (-1, 0, 0);
         }

     } else if (Input.GetKeyDown (KeyCode.UpArrow)) {
         transform.Rotate += new Vector3 (0, 0, -90);

         if (IsValidGridPosition ()) {
             UpdateMatrixGrid ();
         } else {
             transform.Rotate += new Vector3 (0, 0, 90);
         }
     } else if (Input.GetKeyDown (KeyCode.DownArrow) || Time.time - lastFall >= 1) {
         transform.position += new Vector3 (0, -1, 0);

         if (IsValidGridPosition ()) {
             UpdateMatrixGrid ();
         } else {
             transform.position += new Vector3 (0, 1, 0);
                 
             MatrixGrid.DeleteWholeRows ();
             FindObjectOfType<Spawner> ().SpawnRandom;
             enabled = false;
         }
         lastFall = Time.time;
     }
 }

 bool IsValidGridPosition() {
     foreach (Transform child in Transform) {
         Vector2 v = MatrixGrid.RoundVector (child.position);

         if (!MatrixGrid.IsInsideBorder (v))
             return false;

         if(!MatrixGrid.grid[(int)v.x, (int)v.y] != null && MatrixGrid.grid[(int)v.x, (int)v,y].parent != transform)


         } // this point is says TetrisObject.cs(67,3): error CS1525: Unexpected symbol `}'
     return true;

 }

 void UpdateMatrixGrid() {
     for (int y = 0; y < MatrixGrid.column; ++y) {
         for (int x = 0; x < MatrixGrid.row; ++x) {
             if(MatrixGrid.grid [x, y] != null) {
                 if (MatrixGrid.grid [x, y].parent == transform) {
                     MatrixGrid.grid [x, y] = null;
                 }
             }
         }
     }

     foreach (Transform child in transform) {
         Vector2 v = MatrixGrid.RoundVector(child.position);
         MatrixGrid.grid [(int)v.x, (int)x.y] = child;
     }
 }

} // TetrisObject

Comment
Add comment · Show 3
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 jdean300 · May 17, 2017 at 09:27 PM 1
Share

Likely syntax error. IsValidGridPosition should probably be:

 bool IsValidGridPosition() 
 {
     foreach (Transform child in Transform) 
     {
         Vector2 v = $$anonymous$$atrixGrid.RoundVector (child.position);
         if (!$$anonymous$$atrixGrid.IsInsideBorder (v))
             return false;
         
         if (!$$anonymous$$atrixGrid.grid[(int)v.x, (int)v.y] != null 
         && $$anonymous$$atrixGrid.grid[(int)v.x, (int)v,y].parent != transform) 
         {
             return true;
         }
     }
     return true;
 }
avatar image LearningWhileScrewing · May 18, 2017 at 10:40 AM 0
Share

u pretty much didn't do anything xD

avatar image jdean300 LearningWhileScrewing · May 18, 2017 at 07:46 PM 0
Share

I fixed the syntax error your code had, as indicated by the line // this point is says TetrisObject.cs(67,3): error CS1525: Unexpected symbol '}'

If that is not the issue, then edit your question to make it clear what you are asking. Asking "Is This Script Old?" doesn't make any sense - the only thing related to Unity's API in this script is the Input calls, and those have not changed and would work just fine. Otherwise, this is all your own code or code that we would know nothing about - we can't tell you if your own code is old...

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

139 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

Related Questions

Unity Analytics - Does data come from "editor runs" or does it only come from complete builds or from apps downloaded from mobile web stores? 0 Answers

Why does this C# doesnt Work? it seems to be right. 0 Answers

Event not being invoked 2 Answers

Simple prefab script behaviour erratic 0 Answers

Mario kart controller physics 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