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 /
avatar image
0
Question by mrsev · Nov 26, 2016 at 11:51 AM · camerarotationscript errorrotatearoundrotating

Player making a 360° looping, camera not following

Hi people!

I'm in trouble again, I made a level where the player is constantly accelerating to its local forward, and we guide him like a missile through obstacles (a little like in Rayman 3 if you remember).

Problem is, I want to make more than 90° loops, and that's where the camera doesn't follow.

Actually past 90°, camera AND player rotate 180° around the forward axis of the player, so its "head up and feet down". But I want the player to keep going "feet up and head down", because its a looping.

I think it's in the Cam Script in the Update. Made several changes but can't find the fix.

Here's the Camera script :

 {    
     public Transform lookAt;
     public Transform camTransform;
 
     private Camera cam;
 
     public float distance = 8.0f;
     public float currentX = -160.0f;   //starting position
     public float currentY = 10.0f;   //starting position
     public float sensitivityX = 4.0f;
     public float sensitivityY = 1.0f;
 
     private void Start()
     {
         camTransform = transform;
         cam = Camera.main;
         transform.forward = Camera.main.transform.forward;
     }

 
  I GUESS THE PROBLEM COMES FROM HERE - Update !
     private void Update()
     {
         currentX += Input.GetAxis("Mouse X");
         currentY -= Input.GetAxis("Mouse Y");
     }
 
     public float heighT = 6;
 
     private void LateUpdate()
     {
         Vector3 height = new Vector3(0, heighT, 0);
         Vector3 dir = new Vector3(0, 0, -distance);
         Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
         camTransform.position = lookAt.position + rotation * dir;
         camTransform.LookAt(lookAt.position + height);
     }
 }

The controls script :

 {
     public float speed = 10.0f;
     public Rigidbody rb;
     public float Forw = 1F;
     public float Cam = 50F;
     public Camera mainCamera;
 
     void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void Update()
     {
         transform.forward = Camera.main.transform.forward;
         if (Forw <= 80) Forw += 0.01F;    // to accelerate the player see further.
         mainCamera.GetComponent<Camera>().fieldOfView = Cam;
         if (Cam<=90) Cam += 0.01F;    // modifying the field of view.
     }
 
     void FixedUpdate()
     {
         rb.velocity = transform.forward * Forw;
     }
 }


That kind of level setting

alt text

180.jpg (57.7 kB)
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 mrsev · Nov 26, 2016 at 11:59 AM 0
Share

Because when I look up it's 90° value and if I turn further

 currentY -= Input.GetAxis("$$anonymous$$ouse Y");

is messed up probably.

Or it's the LateUpdate...

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

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

TPS Rotation Camera (similar to WoW or any other mmo) 0 Answers

easing camera rotation after mouse up? 0 Answers

Rotate objects face to camera 1 Answer

Rotate within range 1 Answer

Mouse control rotate around 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