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
-1
Question by PaceKeeper · May 22, 2013 at 01:12 AM · rotateresethorizontalrecoilrecovery

I need horizontal Recoil to reset back to original position after player stops shooting

If anyone has played planetside 2, they will see that when the recoil resets, it will reset about exactly at the position the gun was at if you don't move your mouse when you did the shot. I'm trying to make my the player rotate back to the original rotation. This was easy with vertical recoil because you are only rotating the camera up, but the recoil for the horizontal plane requires rotating the player in both the left and right directions. I don't know how I can reset my player back to the original rotation for the horizontal plane and I've tried very hard to make this work. Any help would be much appreciated.

Basically when you shoot, a random range of my recoil is used for the horizontal axis. When I stop shooting, I want the player's rotation to lerp or interpolate between the rotation the player is at when they just stopped shooting, to the original rotation the player had before they started rotating from the recoil. I want it to move back based on the net difference between the original rotation and the one that the player has right now.

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 Benproductions1 · May 22, 2013 at 01:15 AM 0
Share

Answer given the current Information: USING $$anonymous$$ATH!!! Please give more detail for a proper answer :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by PaceKeeper · May 30, 2013 at 08:39 PM

I found out how to do it. Since it is a random value between negative and positive, it makes dealing with the horizontal recoil very difficult. The problem is that I am trying to get the horizontal recoil return back to it's original position where it was fired and I've only been successful with the vertical recoil. So what you can do instead is use the rule of finding equal ratios instead.

Here is the ratio problem.

         ???             horizontalRecoilSubtraction
 -------------------- = -----------------------------
 verticalRecoilTotal        horizontalRecoilTotal

The ??? is the verticalRecoilSubtraction value that I need in order to have a steady subtraction to it's original position. So if we do some simple mathematics, the formula to finding out the verticalRecoilSubtraction value should look like this.

???(verticalRecoilSubtraction) = (horizontalRecoilSubtraction * verticalRecoilTotal) / horizontalRecoilTotal

I have it written like this, but it still works the same.

 recoil.decreasedRecoilPerSecond = (recoil.amount/kickBack.totalAmount) * kickBack.recoveryPerSecond;

I suggest placing this in the Update function so that it will know the value before subtracting.

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

14 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

Related Questions

How to Reset Quaternion/Rotation On 3D Object After Dragging Mouse? 2 Answers

Help with Recoil for guns 3 Answers

How limit the rotation of an object Or if there is other way to rotate 1 Answer

Rotate object horizontal with local position and localrotation 0 Answers

horizontal recoil reset with slerp 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