• 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
Question by Anykey · Jul 26, 2011 at 10:20 PM · rotationjavascriptslowlimitpuzzle

puzzle with rotating statues

Hello everyone , I'm working on a Unity game and I'm seeking help , i've begun a game with Unity3D which you can try here http://ns14.freeheberg.com/~anykey2/Test1/WebPlayer/WebPlayer.html

I'd like to include some puzzles , I've begun with a puzzle that seems easy to do , but it's actually very hard for me (I'm a weak programmer) I'd like to put some kind of statues that you must rotate with buttons on the ground until they are all at y=0 (they face the camera all in the same direction) so it opens a gate. Here is what my script looks like , but it really doesn't work a little precision , i'd like to use Rotate , not rotation to have slow and realistic rotations.

 var Statue : GameObject;
 var Porte : GameObject;
 var RotationLimit =0;
 static var StatuePoint = 0;
 function Update () {
 if (Statue.transform.rotation.y > 360){
 Statue.transform.rotation.y = 0;
 }
 if (RotationLimit == 4){
 RotationLimit = 0;
 }
 if (Statue.transform.rotation.y == 90){
 RotationLimit = 1;
 }
 if (Statue.transform.rotation.y == 180){
 RotationLimit = 2;
 }
 if (Statue.transform.rotation.y == 270){
 RotationLimit = 3;
 }
 if (Statue.transform.rotation.y == 0){
 RotationLimit = 0;
 }
 if (RotationLimit == 0){
 ++ StatuePoint;
 }
 print(RotationLimit);
 }
 
 function OnTriggerStay (other : Collider) {
 if (other.gameObject.tag == "Boite" && RotationLimit == 0 && Statue.transform.rotation.y <= 90 && Statue.transform.rotation.y >= 0){
 Statue.transform.Rotate(0,5,0);
 }
 if (other.gameObject.tag == "Boite" && RotationLimit == 1 && Statue.transform.rotation.y <= 180 && Statue.transform.rotation.y >= 90){
 Statue.transform.Rotate(0,5,0);
 }
 if (other.gameObject.tag == "Boite" && RotationLimit == 2 && Statue.transform.rotation.y <= 270 && Statue.transform.rotation.y >= 180){
 Statue.transform.Rotate(0,5,0);
 }
 if (other.gameObject.tag == "Boite" && RotationLimit == 3 && Statue.transform.rotation.y <= 360.1 && Statue.transform.rotation.y >= 270){
 Statue.transform.Rotate(0,5,0);
 }
 }
 function OnTriggerExit (other : Collider) {
 RotationLimit = RotationLimit +1 ;
 }
 

Comment

People who like this

0 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 Waz · Jul 26, 2011 at 10:35 PM 0
Share

What problems are you having, specifically?

avatar image Anykey · Jul 26, 2011 at 11:37 PM 0
Share

My problem is , the statue turns , but it doesn't stop at 90° and after at 180° and after at 270° , but it does stop at 4° after making a full rotation , I'd like my statue to stop at 90° , 180 ° ... and give it a value for each quarter of full rotation and for the 0° position , the good value , if the 4 statues have the good value , it opens the door , actually StatuePoint was a test to open the door , every statue increases the statue point when the statue is at 0° and when the 4 are at 0° (StatuePoint =4) , the gameObject door open , but the script doesn't work from the beginning , so it is actually useless right now Thanks for trying to help , I appreciate , especially it was my birthday yesterday

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Waz · Jul 26, 2011 at 10:34 PM

Your logic is basically correct, except that you increase StatuePoint ever frame and never decrease it. I assume that's supposed to be a counter of how many are correctly positioned.

Comment
Anykey

People who like this

1 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 Anykey · Jul 26, 2011 at 11:49 PM 0
Share

Yeah that's right, I've mistaken this var , but the whole script doesn't work well actually =/

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Need help with limiting rotation. 1 Answer

Smooth rotation in 90° increments 0 Answers

Euler angle problems with rotation limit script 3 Answers

How can I set a limit to my object rotation???(Here's the code) 2 Answers

Character Rotation - Script not functioning correctly 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