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 whitequill · Feb 08, 2012 at 02:01 PM · camerarotationcamera-movement

rotate around ball

I'm going to rephrase my question because this isn't working. I'm looking for a script for rotating around your character (the ball), when you press the input keys (up,down,left,right)

If your character moves forward (up), the camera goes behind you (does nothing). If character turns left, the camera rotates 90 degrees right to follow you and stay behind you. if you press "down" the camera will rotate 180 degrees and follow you.

the only difference is you are not moving the ball, you are tilting the game board to make the ball roll around a maze; and the camera follows the ball in 3rd person.

This is used in every 3rd person (over the shoulder) game; this can't be hard.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tingham · Feb 08, 2012 at 04:36 PM

Move the camera to a position relative to (ballGameObject.transform.forward -1f) and have the camera look at the ball. ballGameObject.transform.forward -10f would put the camera ten units behind the ball, transform.up would work similarly.

Comment
Add comment · Show 3 · 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 Loius · Feb 08, 2012 at 04:53 PM 0
Share

The problem with using the ball's .forward is that if the ball is rolling, the camera will spin with it. It's a very trippy experience, let me assure you. x)

avatar image tingham · Feb 08, 2012 at 04:59 PM 0
Share

Use the forward of the game object for your positioning but spin the interior transform of the mesh item itself. If you're using a Sphere primitive then you can implement an empty game object as @Vicenti suggests below; animating the rotation of the sphere inside of the empty game object over it's X, Z axis as the ball rolls but transfor$$anonymous$$g position via the containing game object.

avatar image whitequill · Feb 09, 2012 at 02:19 AM 0
Share

I'm already using a Smoothfollow script, provided with Unity, I just need to get the camera to rotate "behind" the ball when you are tilt the marble board (maze) in some direction.

The board is set to tilt forward first. +Z, but then you need to tilt it -X, to go Left. and I want the camera to follow the ball, as such. the camera will go to +X so it is behind the ball.

avatar image
0

Answer by Loius · Feb 08, 2012 at 04:52 PM

Create an empty object, and give it:

 var ball : GameObject;
 function LateUpdate() { 
  transform.position = ball.transform.position; 
  transform.LookAt( transform.position + *insert ball velocity here* );
 }

Make your camera a child of that object. The object will face the direction the ball is moving (you may need to make a special case for zero movement), and the camera should spin around with it.

Comment
Add comment · Show 2 · 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 tingham · Feb 08, 2012 at 04:57 PM 0
Share

You won't want to parent like this if you plan on doing any easing with your camera (which seems likely.)

avatar image whitequill · Feb 09, 2012 at 02:37 AM 0
Share

I was thinking more like

if(Input.Get$$anonymous$$ey("left"))
{
rotate camera 90 degrees to +X location
}
kind of idea then if you do
if(input.Get$$anonymous$$ey("Up"))
{
rotate camera to 0 or -Z (initial start point).
}
I know what I want, I'm not perfectly sure how its written. Since I already have the, Smooth Follow script, I was thinking of making this secondary. and of couse
if(input = cameraAngle) { don't do anything. }
I'm a bit new to Unity, so I'm still learning.

avatar image
0

Answer by apollo25 · Oct 28, 2014 at 11:26 AM

i have a solution. create another new gameoject and make it child of the character at centre of character(0,0,0). then make camera new gameobject's child and keep it at a desirable dist. which will be the radius at which the camera will rotate.camera should point at character in scene. now you can rotate the new gameobject using transform.rotate

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[JS] Custom camera rotation resets on Var change? 0 Answers

Rotating the camera over a period of time 1 Answer

Forward and back movements with a camera emulating an isometric view 1 Answer

How do I get my camera to rotate around the y=0 coordinate it's looking at? 0 Answers

Rotating a camera and his object like an airplane simulator 2 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