Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Ram555 · Oct 23, 2016 at 02:20 AM · camera rotatefixfirst person shooter

First Person Shooter Problem with the Scrip

I m making a FPS game in unity 3D but i have a problem with the scrip (First person view) is a only mistake but really give a big headache, i try to fix the mistake but the more I try gives me more mistakes, someone could headache a hand in the scrip and tell me that I did wrong ?, I know that the error is on the line 41 but when I try to fix, I added an error in the 45, to if I have error in the 41 and 45, please, I thank the help of whoever.

The Scrip is here:

pragma strict

public enum RotAxis {X = 0, Y = 1}

var RotAxisRotationXY = RotAxis.X || RotAxis.Y; var SensivityX : float = 25.0f; var SensivityY : float = 2.0f; var RotationX : float = 0.0f; var MinimumX : float = -360.0f; var MaximumX: float = 360.0f; var RotationY : float = 0.0f; var MinimumY : float = -45.0f; var MaximumY: float = 45.0f; var XQuat : Quaternion; var YQuat : Quaternion; var OrigRotation : Quaternion; var bobSpeed : float = 1; var stepCounter ; float; var bobAmountX; float = 1; var bobAmountY; float = 1; var lastPosition : Vector3; var heightRatio : float = 0.9; var aimingTrue : float = 1; var cameraDefault : float = 60; var targetCamera : float = 60; var cameraZoom : float = -1; var cameraZoomV : float; var cameraZoomSpeed : float = 0.1;

function Awake () { lastPosition = transform.parent.position; }

function Update () { if(aimingTrue == 1); { cameraZoom = Mathf.SmoothDamp(cameraZoom, 1, cameraZoomV, cameraZoomSpeed); } else { cameraZoom = Mathf.SmoothDamp(cameraZoom, 0, cameraZoomV, cameraZoomSpeed); } } { if(RotAxisRotationXY == RotAxisRotationXY.X) { camera.fieldOfView = Mathf.Lerp (targetCamera, cameraDefault, cameraZoom); if(transform.parent.GetComponent(Movement).grounded) { stepCountier += Vector3.Distance(lastPosition, transform.parent.position) bobSpeed; } transform.localPosition.x = Mathf.Sin(stepCounter) bobAmountX; transform.localPosition.y = (Mathf.Sin(stepCounter) bobAmountY -1) + (transform.parent.localScale.y * heightRatio) - (transform.parent.localScale.y/2);

             lastPosition = transform.parent.position;

             RotationX += Input.GetAxis("Mouse X") * SensivityX * Time.deltaTime;
             RotationX = ClampAngle(RotationX, MinimumX, MaximumX);
             OrigRotation = XQuat = Quaternion.AngleAxis(RotationX, Vector3.up);
             transform.localRotation = OrigRotation * XQuat;
         }

         if(RotAxisRotationXY == RotAxisRotationXY.Y)
         {
             RotationY -= Input.GetAxis("Mouse Y") * SensivityY * Time.deltaTime;
             RotationY = ClampAngle(RotationY, MinimumY, MaximumY);
             OrigRotation = YQuat = Quaternion.AngleAxis(RotationY, Vector3.right);
             transform.localRotation = OrigRotation * YQuat;
         }
     }

static function ClampAngle(Angle : float, Min : float, Max : float) : float { if(Angle < -360.0f) Angle += 360.0f; if(Angle > 360.0f) Angle -= 360.0f; return Mathf.Clamp(Angle, Min, Max); }

For who not can find the line 41 and the 45, it's in "else" and "}"

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 Namey5 · Oct 23, 2016 at 05:52 AM 0
Share

Please place all of the code in the correct format. Without proper formatting, it is impossible to answer the question.

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.

Follow this Question

Answers Answers and Comments

76 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 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 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 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 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

How to fix "no overload for method get component takes 1 arguments" 1 Answer

Objects in game turn blue,Why in game objects turn blue? 0 Answers

STUCK! Firing a simple sphere from below the camera at crosshair in the centre of the screen, with or without raycast. 0 Answers

C# Smooth Follow Space Ship 1 Answer

Need help limiting the x rotation of my camera and internet didn't helped me :( 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