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 MC HALO · Jan 07, 2012 at 11:37 AM · mouselook

Object Fallow Y axis !

hey guys i was wondering if you could please help me. Basically i have two cubes one that contains my Mouselook script and one that has nothing. Now what i want to do is if the player looks up and down on the Y axis i want the other cube to fallow the up and down directions can someone please help me thank you :) I would really appreciate it.

Here is my mouse look script:

     public enum RotationAxis {MouseX = 0, MouseY = 1}
          
          var RotationAxisRotationXY = RotationAxis.MouseX | RotationAxis.MouseY;
          
          //We are defining the variables needed for our X axis motion. This will include 
          //Sensitivity and the minimum and maximum of the x axis rotation 
          
          var sensitivityX : float = 400f;
          
          var minimumX : float = -360f;
          
          var maximumX : float = 360f;
          
          var RotationX : float = 0f;
          
          var OriginalRotation : Quaternion;
          
        var Game : Transform;
         
          // Now lets set the variables for the y axis so the player can then look up and down
          // using the mouse.
          
          var RotationY : float = 0f;
          
          var minimumY : float = -25f;
          
          var maximumY : float = 25;
          
          var sensitivityY : float = 400f;
 
     
 function Update () {
 
    
 
       if(RotationAxisRotationXY == RotationAxis.MouseX){
        
           RotationX += Input.GetAxis("Mouse X") * sensitivityX * Time.deltaTime;
           
               
               
               RotationX = ClampAngle (RotationX, minimumX, maximumX);
               
               OriginalRotation = XQuaternion = Quaternion.AngleAxis (RotationX , Vector3.up);    
              
              transform.localRotation = OriginalRotation * XQuaternion;
              
 
             }
             if(RotationAxisRotationXY == RotationAxis.MouseY){
             
             RotationY -= Input.GetAxis ("Mouse Y") * sensitivityY * Time.deltaTime;
             
             RotationY = ClampAngle (RotationY, minimumY, maximumY);
             
             OriginalRotation = YQuaternion = Quaternion.AngleAxis (RotationY, Vector3.right);
             
             transform.localRotation = OriginalRotation * YQuaternion;
             
         
             
             }
         
            
 
     
          
 }
 
         
                 
     
     
     static function ClampAngle (Angle, min, max): float {
     
     
         if(Angle < -360){
         Angle += 360;
         
         }
         if(Angle > 360){
         
         Angle -= 360;
         }
         
         return Mathf.Clamp (Angle, min,max);
     }


The variable var Game : Transform; is a reference to the cube that is meant to fallow the other cubes Y axis :) Thank you in advance :)

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

Answer by Anxo · Jan 07, 2012 at 04:40 PM

If you rotate Cube A up on the Y axis, you want Cube B to move up on the Y?

Place Cube B insid of Cube A, Restrict its X and Z motions and freeze its rotation.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Disable MouseLook for dialogues 2 Answers

Disabling a script in runtime 2 Answers

Disabling a child script within the parent. 0 Answers

How to get collisions working on a flying controller? 1 Answer

Screen go Gray and only Cursor active OnTriggerEnter 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