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 BigDakaFa7 · Jun 30, 2013 at 08:42 AM · pathfindingy axisz axisx axis

I am trying to change rows and column to x and z

Ok so my friend gave me some code to debug and it has to do with rows and columns. Basically he wants me to make it layout on the x and z coordinates instead of x and y. I am at a loss and it does'nt change even with the code i currently have right now heres the code. It builds 6 rows and 6 columns and the rows are on the y axis and i want it to be on the z axis please and thankyou for the help

for (int i = 0; i < _numRows; i++) { _tmpList = new List<Transform>(); _nodeStatesList = new List<NodeState>(); // CREATE ROW PARENT just for BEAUTY STRUCTURE of GameObjects GameObject parentGO = new GameObject("ROW_"+i.ToString()); parentGO.transform.parent = _parentTransform; _parentTransforms.Insert(i, parentGO.transform); for (int j = 0; j < _numCols; j++) { GameObject go = GameObject.Instantiate(nodePrefab) as GameObject; go.transform.name = go.transform.name.Replace( "(Clone)", "["+i.ToString()+", "+j.ToString()+"]" ); go.transform.parent = _parentTransforms[i]; go.transform.position = new Vector3( j * go.transform.localScale.x * 1.25f, -i * go.transform.localScale.z * 1.25f, go.transform.position.x ); _tmpList.Insert(j, go.transform); _nodeStatesList.Insert(j, go.GetComponent<NodeState>()); } _gridTransforms.Insert(i, _tmpList); _nodeStatesGrid.Insert(i, _nodeStatesList); } _parentTransform.Translate(new Vector3( (-1) * (_numCols - 1) * 0.5f * nodePrefab.transform.localScale.z * 1.25f, (_numRows - 1) * 0.5f * nodePrefab.transform.localScale.x * 1.25f, 0 ));

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
Best Answer

Answer by Seregon · Jun 30, 2013 at 01:05 PM

The issue is in lines 12-16 of the code you gave, which should be changed from

 go.transform.position = new Vector3(
   j * go.transform.localScale.x * 1.25f,
   -i * go.transform.localScale.z * 1.25f,
   go.transform.position.x
   );

to

 go.position = new Vector3(
   j * go.transform.localScale.x * 1.25f,
   go.position.y,
   -i * go.transform.localScale.z * 1.25f
   );

Hope this helps.

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

16 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

Related Questions

Only Lerp 2 coordinates 0 Answers

Locking object (or animation) to X or Y axis 1 Answer

Move Character Through Z and X Axis Simultaneously 0 Answers

Mose look no limits 1 Answer

Alternative to transform.Translate? 3 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