• 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 Miner717 · Feb 20, 2015 at 05:29 PM · c#recoil

How to make the camera rotate up to act as recoil?

I am trying to make my first game in unity, being a FPS. I have all of the controls and am working on animations, but I cannot get recoil working. I am currently running the following script if the player is holding left mouse button down: Camera.main.transform.Rotate( recoil * Time.deltaTime, 0, 0 ) ; recoil is currently set using float recoil = 10.0f;. But all this code is doing is jolting the screen slightly, not making the camera slowly travel up. I gave up building this FPS for some time, but after coming back to try and do more work I still cannot get this recoil working. Any help would be greatly appreciated.

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 da_st · Mar 01, 2015 at 09:54 PM 1
Share

Hey maybe you could make a animation where you move the camera, and then just start the animation in the code when the player clicks? :P

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by 0V3RR1D3 · May 20, 2015 at 08:33 AM

Set the local x rotation on the camera when the player shoots to say +10 then lerp it back to 0. So it will jump up and smoothly go back to its original angle, :P

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 PZ4_Bailey · Jan 15, 2018 at 03:44 PM 0
Share

Can you please give an example of this??

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Initialising List array for use in a custom Editor 1 Answer

Weapon recoil recoils in world space 1 Answer

C# How to make a gameobject move a max distence at a certain speed 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges