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 Chimera3D · Apr 24, 2012 at 03:05 AM · camerarotationphysicsdirectionsphere

Camera/Direction Rotation

I know this probably is real noobish but I have a game where you roll a ball around using physics and I've been trying for weeks for when I rotate the camera (using the mouseOrbit script) to rotate the ball's directions. For example whenever I rotate the camera the ball still moves in the same directions and it's hard to move about. I've already tried using AddRelativeTorque which threw off the directions completely. The camera should always be facing forward in relative to the forward direction. Remember I'm using physics (AddTorque in direction).

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 venkspower · Apr 24, 2012 at 04:54 AM 0
Share

Check if you have made the Ball object as the parent to the Camera object.

avatar image Chimera3D · Apr 24, 2012 at 05:17 AM 0
Share

If I do that the camera will rotate with it.

2 Replies

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

Answer by Chimera3D · Apr 26, 2012 at 12:12 AM

Answer:

 var torque = Vector3(Input.GetAxis("Vertical"), 0, -Input.GetAxis("Horizontal"));
  torque = Camera.main.transform.TransformDirection(torque);
  torque.y = 0;
  
  var torque2 = Vector3(-Input.GetAxis("Vertical"), Input.GetAxis("Horizontal"), 0);
  torque2 = Camera.main.transform.TransformDirection(torque2);
  torque2.y = 0;
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
avatar image
0

Answer by maroonrs2 · Apr 24, 2012 at 04:54 AM

 var xSensitivity : float;
 var ySensitivity : float;
 var maxHeight : float;
 var minHeight : float;
 private var xPos : float;
 private var yPos : float;
 var myTrans : Transform;
 var camTrans : Transform;
 
 function Update()
 {
     yPos = Mathf.Clamp(yPos - Input.GetAxis ("Mouse Y") * ySensitivity, minHeight, maxHeight);
     xPos = xPos + Input.GetAxis("Mouse X") * xSensitivity;
     myTrans.rotation = Quaternion.AngleAxis(xPos, Vector3.up);
     camTrans.localRotation = Quaternion.AngleAxis(yPos, Vector3.right);
 }

Put my Trans as your camera and the cam trans as the object you roll around. The camera should be in the ball too. Just drag and drop it in the place values and configure them. If this doesnt work then i have other worthy scripts. And the -75 was from people just -1'ing stuff. It's funny really.

Comment
Add comment · Show 1 · 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
avatar image Chimera3D · Apr 24, 2012 at 05:21 AM 0
Share

That didn't work and the ball lost it's ability to rotate. :/ I'm rotating according to physics directions. i.e. forward, -forward etc.

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

Simulating the graphics of a rolling 3D ball in a 2D game 2 Answers

How to move player in direction where the camera is aiming ? 1 Answer

How to always face player relative to player's rotation and how do I use TransformDirection to move a player regardless of Y-rotation? 0 Answers

Camera rotation around the sphere 0 Answers

Relative Movement Problem 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