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 andracer108 · Mar 25, 2017 at 01:06 PM · camerarotationcamera-movementaxismouseorbit

MouseOrbitImproved slanted orbit

Hello everyone!

I am currently encountering a bit of a problem regarding the MouseOrbitImproved script for Unity (which can be found here).

Summary

In my game, the player can be sent sideways to a wall and gravity would change towards the wall. I would want the player to still have full control over the camera, just that the camera would flip sideways (this can be omitted from the requirements) and the camera controls would be different (for example, when I move the mouse up, the camera would rotate around the player since the Y is the new "X" when on the wall).

Problem

I will admit that I haven't fully understood how this script exactly works (however, I did understand some basics) so I was expecting to run into problems... just not this tedious. I modified the script in such a way that it uses other variables from other scripts to know when the gravity changed. The most occurring problem that I had was this. Whenever I did the condition to check if the gravity was against a wall, I inverted the X and Y values (since those are the only ones I needed to change from what I know). So, instead of this:

 // for normal gravity (or ceiling gravity too)
 
 x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
 y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
 
 y = ClampAngle(y, yMinLimit, yMaxLimit);

It becomes this:

 // for wall gravity
 
 y += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
 x -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;

 x = ClampAngle(x, yMinLimit, yMaxLimit);

However, it doesn't appear that simple. Whenever I invert the X and Y, whenever I try to rotate in the new "horizontal" axis (which is Y) at the maximum value of the new "vertical" axis (which is X), the orbit is slanted. However, when the new "vertical" axis is at the minimum value, it works fine. Here are 2 images below to further explain what I mean.

What I want as a result: orbit want

Actual result I have currently: orbit actual

The red cube represents the player and the circle outline represents the camera orbit and the plane represents the wall.

I hope this is enough information! If you have any questions or would like me to improve this question, feel free to tell me! Thank you all for the help! :)

P.S. Kindly know, if you are going to send me sample code, send it in C# since that is what I am using to code the game. Thank you!

orbit-want.png (20.0 kB)
orbit-actual.png (19.0 kB)
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

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

132 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 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 turn camera 90 degrees smoothly? 1 Answer

Hard coded rotation of child results in weird arc rotation when parent is rotated? 0 Answers

Problems with rotating the player on the Y axis C# 0 Answers

Rotation on the Z axis not happening 1 Answer

Rotate Object Axis On Swipe Cam Rotation - Android 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