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 edoz78 · Jan 18, 2013 at 07:34 PM · texturegridmatrix

Draw Texture in a grid like Trainyard

Hello to everyone!!! Is there someone that knows a way to draw texture on a grid with continuous rails like game Trainyard??

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 Flynn · Jan 18, 2013 at 07:46 PM 0
Share

That depends! Are you using OnGUI for your drawing, or something else?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by robertbu · Jan 18, 2013 at 10:00 PM

I can think of few different ways, but here is a starting point for one way. Create a Tile class. The Tile class would have an array of textures. Each texture would represent one of the possible track runs. The Tile Class would detect when a finger move entered and exited the game object on which the Tile class was a component. Based on the finger move, a specific texture/state would be selected. For example if the finger move came in on the left and and exited at the bottom, a texture that started on the left and curved down would be selected from the array and dispalyed.

The board would consist of an array of game objects with the Tile class as a component. To run the train after the track has been constructed, you could start at the beginning and walk from tile to tile looking at the state of each tile to build a path for the train.

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 edoz78 · Jan 19, 2013 at 11:39 AM

Ok, i understand your way with tile map! Can you give me a code or a pseudo-code that implements this way? Thanks a lot!

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 robertbu · Jan 19, 2013 at 04:31 PM 0
Share

For the textures, create a public array of texture. In C#:

 public Texture[] artex;

In the inspector, drop in your textures.

To switch textures you can do something like:

 renderer.material.texture = artex[4];

For the movement code you likely want to solve these problems:

  1. What tile am I over? - Likely this will be handled by Raycasting.

  2. How to I get access to the script for this tile? - Likely handled by GetComponent().

  3. Who has the focus? - Will need to build some focus tracking mechanism.

  4. What side am I near in a particular tile? - Will need to figure out out to transform the world coordinates into something local to the tile.

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

11 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

Related Questions

Paint Grid Texture 1 Answer

Assigning UV Map to model at runtime 0 Answers

How to make a grid plan as 3dsmax 0 Answers

[c#] Create visible appearence of a grid using texture or models 1 Answer

How to add a grid to an image? 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