• 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 Supershandy · Apr 24, 2012 at 08:13 PM · javarotatingnumberlinear

Rotating a linear number - How?

I am currently writing code to construct a game for android devices, however part of my code requires rotating numbers to create random choices, missions, stars etc. However I am fairly new to coding and although I understand quite a bit of it, this has me completely stumped.

I am writing this in Javascript/Unityscript

Currently my code is as follows, at least where I am stuck that is...

 var coordx_2;
 var coordy_2;
 var sysNum;
 var dest;
 var strcpy;
 var strcat;
 
 
     coordx_2 += sysNum;
     coordy_2 += coordx_2;
     coordx_2 = rotate_some(coordx_2, 3);
     coordx_2 += coordy_2;
     coordy_2 = rotate_some(coordy_2, 5);
     coordy_2 += coordx_2;
     coordy_2 = rotate_some(coordy_2, 4);
     coordx_2 = rotate_some(coordx_2, sysNum);
     coordx_2 += coordy_2;
     
     strcpy (dest, namePart[(coordx_2>>2) & 31]);
     coordx = (coordx_2) 5; //This is the part that needs rotating, also says that ';' is expected
     strcat (dest, namePart[(coordx_2>>2) & 31]);
     coordx = (coordx_2) 5; //This is the part that needs rotating, also says that ';' is expected
     strcat (dest, namePart[(coordx_2>>2) &31]);
     dest[0] ^= 0x20;

I should also mention that I do not want to use the Rand keyword as that will create too many random elements, this is meant to be a controlled reaction, Think of it as rotating an object by so many degrees, but each time you do it, it changes shape slightly.

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 GuyTidhar · Apr 24, 2012 at 08:18 PM 0
Share

I am missing the random part here - what makes your result random?

You can control what random gives you. You could random between how many elements you'd like. Even 1 for that matter (which would practically result in nothing random of course).

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Trouble with video 0 Answers

Get the angle from one object to another. 0 Answers

Making an animation play when you press down 2 keys 1 Answer

Android plugin breaks when using receiver. 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