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 HKDuskraven · Apr 01, 2017 at 08:11 AM · c#cameraplayervehicle

Input Controls Camera on a Predetermined Path.

Hi, I'm still relatively new to Unity, and this is my first question, so I'll try to get it across clearly.

The game I'm working on has the player in a vehicle, looking from a first person perspective. I'm trying to allow the player to lean out of the window so that they can look to their sides or behind them. I first achieved this simply allowing the player to rotate the camera with their mouse whilst a "Free Look" button was held, but didn't get quite the right effect.

THIS is more what I'm trying to achieve. So I was wondering if anyone could suggest a way to sort of attach the camera to a rail, which mouse input can move it along.

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

1 Reply

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

Answer by Bunny83 · Apr 01, 2017 at 11:26 AM

Well, it's hard to tell from the video, but it looks like the whole camera movement as well as rotation is predefined in a "one dimensional slide". The easiest way to implement that in Unity is to use a simple AnimationClip. That way you can simply create an animation that moves from the left most "position" over to the right most "position". Including the rotation.

An animation clip can have multiple curves for several different things. So you can define a seperate curve for the location of the camera as well as the rotation.

You don't simply "play" the animation but instead you set the current "time" of the animation and sample the animation manually. That time value is what you put under control of the user. As normalized time it's just a value between 0 and 1.

Of course it would also be possible to only animate the movement and rotation around "y" and let the user still control the "up-down axis" (local x). So for example the mouse x delta would drive the animation position and the mouse y delta would rotate the camera up down.

edit

I made a quick WebGL Demo. You have to click once to lock the mouse cursor. I've exported the project files as package.

Note that the AnimationClip need to be a legacy clip in order to use it in the Animation component. To turn an AnimationClip into a legacy clip you have to temporarily switch the inspector into debug mode. While in debug mode you will see the legacy checkbox. Once changed you can switch the inspector back to normal mode.

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 HKDuskraven · Apr 04, 2017 at 03:58 PM 0
Share

Brilliant thanks!

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

How to rotate camera diagonally over players shoulder while still facing towards players direction 0 Answers

Why are my player controls wierd. 1 Answer

C# - Offset In-Air Camera from Current Object Position 1 Answer

I need help to make the player go towards where the camera is facing. 1 Answer

How can i make my player moving towards the direction where my main camera is facing? 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