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
-1
Question by MC HALO · May 14, 2011 at 03:15 PM · mouselook

Help with My C Sharp Script ????

Hi all, i was wondering if someone could help me, basically is created a Mouse look script in unity using both C# and Jave script, both work fine and run perfectly. But i created a new project and made a new C# script and created a new mouse look script identical to the other. but this time my mouse move script is not even responding it wont me along the x axis at all. this is strange i was wondering if some one spot anything wrong with it cheers

here is my script:

using UnityEngine; using System.Collections;

public class FpsMouseLookC: MonoBehaviour {

 public enum RotationAxis {MouseX =1}

   public RotationAxis rotX = RotationAxis.MouseX;

       public float  SensitivityX = 15F;

       public float  MaximumX = 360F;

          public float MinimumX = -360F;

             float RotationX = 0f;

                 Quaternion OriginalRotatioin;



     void Start(){

     if(rigidbody)
         rigidbody.freezeRotation = true;
         OriginalRotatioin = transform.localRotation;

 }


 void Update () {

       if(rotX == RotationAxis.MouseX){

         RotationX += Input.GetAxis("Mouse X") * SensitivityX * Time.deltaTime;

         RotationX = ClampAngle (RotationX , MinimumX , MaximumX);

            Quaternion XQuaternion = Quaternion.AngleAxis(RotationX, Vector3.up);

                             transform.localRotation = OriginalRotatioin * XQuaternion;

     }


 }


static float ClampAngle (float Angle, float Max, float Min){

  if (Angle <-360F)

         Angle += 360F;

     if(Angle > 360F)

         Angle -= 360F;

     return Mathf.Clamp (Angle, Min , Max);
 }


}

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 Jessy · May 14, 2011 at 05:24 PM 0
Share

C# sharp eh? Sounds pointy!

avatar image MC HALO · May 14, 2011 at 07:08 PM 0
Share

hahahah thats so true lol

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MC HALO · May 14, 2011 at 04:56 PM

I Solved the problem :) it was within the Following line:

 RotationX = ClampAngle (RotationX , MinimumX , MaximumX);

i was clamping them in the wrong order. Here is my correct code:

    RotationX = ClampAngle (RotationX , MaximumX, MinimumX);

that was my problem :)

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

No one has followed this question yet.

Related Questions

disabling a script (MouseLook) 5 Answers

MouseLook Problem 1 Answer

Freeze Mouse Look on Pause 4 Answers

Animate Character whilst applying "mouselook" script to a child 1 Answer

Why does the character controller work in Unity but not in the web player? 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