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 /
This question was closed Sep 14, 2013 at 01:10 AM by gamerant for the following reason:

The problem was resolved by what is mentioned in the EDIT part of the question.

avatar image
0
Question by gamerant · Jul 07, 2013 at 05:45 PM · c#

How to alter a script from the forum?

Hi guys.I feel silly for asking this but i have tried to solve it my self for a week now and i haven't gotten anywhere. For my game I found a c# script by Jesse Anders here on the forums:http://forum.unity3d.com/threads/86174-Rotating-object-on-2-axis. It is for rotating a game object around 2 axis.

The first time I found this I managed to alter the script so that it works how i want it but after my laptop crashed and I lost all my work I've been trying to alter it again but without any success.

The problem is the script rotates the game object automatically by 90 degrees when the game just starts and I want the game object to rotate only if input has been detected.I know that the part responsible is in the start function but when i remove it from the start function I receive errors or the game only accepts one input and no more after that.

Should a part of the code go into the Update function or should the for loop be altered in any way?

Any help towards altering the script would be much appreciated as I feel I am constantly missing something simple which I got the first time i altered the script. Here is the sample of the code in the start function.

  void Start()    
     {    
             Quaternion[] rotations = new Quaternion[] 
             {
                 Quaternion.AngleAxis(-90, Vector3.up),
                 Quaternion.AngleAxis(90, Vector3.up),
                 Quaternion.AngleAxis(-90, Vector3.right),
                 Quaternion.AngleAxis(90, Vector3.right)
                 };
     
                 for (int i = 0; i < 24; ++i) 
                 {
                       for (int j = 0; j < 4; ++j) 
                       {
                           var currentOrientation = rotations[j] * orientations[i];
                           float maxDot = 0f;
                           int neighborIndex = 0;
     
                 for (int k = 0; k < 24; ++k) 
                 {
                 float dot=Mathf.Abs(Quaternion.Dot(currentOrientation,orientations[k]));
    
                         if (dot > maxDot) {    
                             maxDot = dot;    
                             neighborIndex = k;    
                         }   
                     }    
                     neighborIndices[i, j] = neighborIndex;    
                 }   
             }   
             transform.rotation = orientations[orientationIndex];
        }


EDITED: In the end I just used a different script that works just fine and required minimum tweaking.Thank you all.

Comment
Add comment · Show 2
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 Fattie · Jul 07, 2013 at 05:46 PM 0
Share

you are really best to ask on the forum. is there a chance you could edit your code here so it does not have unnecessary newlines? thx

avatar image gamerant · Jul 07, 2013 at 06:30 PM 0
Share

Just cleaned up the code.It pasted badly sorry for that. I did post a question on the thread several days ago but so far no reply and the thing is the thread is several years old,so I'm not sure if anyone who originally took part in the discussion still checks it.

0 Replies

  • Sort: 

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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Disabling a script in c# not working for some reason 1 Answer

Same GUI script showing up in different places 0 Answers

C# Movement Script 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