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 Harvelon · Jun 12, 2020 at 10:00 AM · bugtilemapgolf

Tilemap wont update at random certain things;

I have recently been working on a random 2d golf course game inspired by the sx pectrum golf game and now i hvae come across a problem where many of my playtesters get to a point on the course and they then find they cant move in a certain direction anymore. This problem seems to hvae no pattern and i cant find a fix. I am using tilemaps to build the course then a second tilemap that changes the location of the ball based on user input in a text box. My code is below:

void powerSet() { inputField.ActivateInputField(); if (done2 != true) { if(backTilemap.GetTile(ball) == greenTile) { inputField.placeholder.GetComponent ().text = "Input power 1-3 (putting)"; lastBall = ball; } else { inputField.placeholder.GetComponent ().text = "Input power 1-8"; lastBall = ball; }

         }
         if (done2 == true)
         {
             directSet();
             return;
         }
         if (Input.GetKeyDown("return"))
         {
             powerS = inputField.text;
             inputField.text = "";
         }
         if (powerS == "1")
         {
             power = 1;
             powerS = "";
         }
         if (powerS == "2")
         {
             power = 2;
             powerS = "";
         }
         if (powerS == "3")
         {
             power = 3;
             powerS = "";
         }
         if (powerS == "4" && backTilemap.GetTile(ball) != greenTile)
         {
             power = 4;
             powerS = "";
         }
         if (powerS == "5" && backTilemap.GetTile(ball) != greenTile)
         {
             power = 5;
             powerS = "";
         }
         if (powerS == "6" && backTilemap.GetTile(ball) != greenTile)
         {
             power = 6;
             powerS = "";
         }
         if (powerS == "7" && backTilemap.GetTile(ball) != greenTile)
         {
             power = 7;
             powerS = "";
         }
         if (powerS == "8" && backTilemap.GetTile(ball) != greenTile)
         {
             power = 8;
             powerS = "";
         }
         if (power != 0)
         {
             done2 = true;
             
         }
     }
 
     void directSet()
     {
         if (done3 != true)
         {
             inputField.placeholder.GetComponent<Text>().text = "Input compass direction";
             lastBall = ball;
         }
         if (done3 == true)
         {
             StartCoroutine (Move());
             return;
         }
         if (Input.GetKeyDown("return"))
         {
             direct = inputField.text;
             if (backTilemap.GetTile(ball) == treeTile && UnityEngine.Random.Range(1,11) <= 6)
             {
                 statusText.text = "You  rebound  off  a  tree";
                 power = 0;
                 reboundTree = true;
             }
             if (backTilemap.GetTile(ball) == sandTile)
             {
                 power = power - UnityEngine.Random.Range(2, 5);
                 if (power < 1)
                 {
                     power = 1;
                 }
             }
             if (backTilemap.GetTile(ball) == roughTile)
             {
                 power = power - UnityEngine.Random.Range(1, 4);
                 if (power < 1)
                 {
                     power = 1;
                 }
             }
             inputField.text = "";
 
         }
         if (UnityEngine.Random.Range(1, 8) == 7)
         {
             sidePower = UnityEngine.Random.Range(-1, 2);
         }
         if (direct == "E" || direct == "e")
         {
             ball.x = ball.x + power;
             ball.y = ball.y + sidePower;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "W" || direct == "w")
         {
             ball.x = ball.x - power;
             ball.y = ball.y + sidePower;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "N" || direct == "n")
         {
             ball.y = ball.y + power;
             ball.x = ball.x + sidePower;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "S" || direct == "s")
         {
             ball.y = ball.y - power;
             ball.x = ball.x + sidePower;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "SE" || direct == "se")
         {
             ball.y = ball.y - power;
             ball.x = ball.x + power;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "SW" || direct == "sw")
         {
             ball.y = ball.y - power;
             ball.x = ball.x - power;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "NE" || direct == "ne")
         {
             ball.y = ball.y + power;
             ball.x = ball.x + power;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
         if (direct == "NW" || direct == "nw")
         {
             ball.y = ball.y + power;
             ball.x = ball.x - power;
             tilemap.ClearAllTiles();
             tilemap.SetTile(ball, tile);
             direct = "";
             done3 = true;
         }
     }
 
     IEnumerator Move()
     {
         score += 1;
         done2 = false;
         done3 = false;
         power = 0;
         if (reboundTree == true)
         {
             yield return new WaitForSeconds(3);
         }
         if (backTilemap.GetTile(ball) == holeTile)
         {
             backing1.SetActive(true);
             statusText.text = "You  holed  out  in  " + score;
             yield return new WaitForSeconds(0.5f);
             ballSheet = GetComponent<TilemapRenderer>();
             ballSheet.enabled = false;
             yield return new WaitForSeconds(2);
             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
         }
         if (backTilemap.GetTile(ball) == waterTile)
         {
             statusText.text = "In  the  water";
             tilemap.ClearAllTiles();
             tilemap.SetTile(lastBall, tile);
         }
         if (ball.y >= 12 || ball.x <= -17 || ball.y <= -10 || ball.x >= 16)
         {
             statusText.text = "Out  of  bounds";
             tilemap.ClearAllTiles();
             tilemap.SetTile(lastBall, tile);
             ball = lastBall;
         }
         if (backTilemap.GetTile(ball) == sandTile)
         {
             statusText.text = "In  the  bunker";
         }
         if (backTilemap.GetTile(ball) == roughTile)
         {
             statusText.text = "In  the  rough";
         }
         if (backTilemap.GetTile(ball) == treeTile)
         {
             statusText.text = "In  the  trees";
         }
         if (backTilemap.GetTile(ball) == fairTile)
         {
             statusText.text = "On  the  fairway";
         }
         if (backTilemap.GetTile(ball) == teeTile)
         {
             statusText.text = "On  the  tee";
         }
         if (backTilemap.GetTile(ball) == greenTile)
         {
             statusText.text = "On  the  green  (max  power  3)";
         }
         backing.SetActive(false);
         reboundTree = false;

Hope you can help

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

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.

Follow this Question

Answers Answers and Comments

150 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

Related Questions

Problem with floor generator. 2 Answers

Line Renderer moves for no apperent reason 0 Answers

Does anyone know how to fix this tilemap render issue? 0 Answers

Weird blue lines in scene and game view. 0 Answers

Why are tilemaps so bad ? 2 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