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 Dazin09 · Jan 24, 2014 at 04:27 PM · animation editorstop animations

Need Help With Animations! In C#

So I A Complete Newbie At Unity, But I have this problem, I have my rifle, and a couple Animations On It: Aiming down Sights Shooting Without Aiming Down Sights Shooting With Aiming Down Sights

Shooting With Aiming Down Sights Is Just The last key frame from The Aiming Down Sights Animation, But With A recoil Effect, But when i detect input and Play the Aiming Down Sights Shooting Animation While i'm aiming down the sights of course, It does this weird pull down thing, This Is My Code, Basically what i want to accomplish is a smooth recoil effect from my previous animation public class AnimPlays : MonoBehaviour {

 public bool isSighted = false;

 void Update ()
 {


     if(Input.GetButtonDown("Fire1") && isSighted == false)
     {
         animation.Play("m1shoots");
         Debug.Log("fired_shot");
     }else if (Input.GetButtonDown ("Fire1") && isSighted == true)
     {
         animation.Stop();
         animation.Play("m1shootssighted");
         Debug.Log("fire_shot");
     }



     if(Input.GetButton("Fire2"))
     {    
         isSighted = true;
     }else
     {
         isSighted = false;
     }


     if(isSighted == true)
     {
         animation.Play("m1s");
     }

     if(isSighted == false)
     {
         animation.CrossFade("idlem1");
     }


 }


Much Apreciated, Cheers!

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

2 Replies

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

Answer by kewur · Jan 24, 2014 at 07:18 PM

Normally what you want to do when shooting a rifle like object, you want the animation to be on the humanoid character (if that's what you have) and mount the rifle to it's hand bone. If you are new to Unity and game programming I would suggest doing it that way because unity handles smooth transitioning between animations for you. You should consider using Mecanim animations.

For example, if you want a recoil effect on your character you would have 2 animations with maximum recoil effect and zero recoil effect and blend them by using Mecanim's Blend tree. You can than give a value to each weapon in your game called "Recoil" between values 0 and 1 and feed it to Mecanim.

But if you insist on using legacy animations, you are going to have to develop your own Blending. Which is not trivial but there are some tutorials out there about the subject on 3Dbuzz.

Hope this helps.

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 Dazin09 · Jan 25, 2014 at 07:40 AM 0
Share

If I Used The Arms To Simulate Recoil, Would I Do That In Unity Or An External Animation Program Like Blender?

avatar image
0

Answer by IndieScapeGames · Jan 24, 2014 at 04:54 PM

I find it better to use AnimationClips than Animations.

Make several public AnimationClip parameters, and assign the animations to each one.

Then when you call animation.CrossFade(animationParamater.name)

The '.name' is important because it references the string value bane of the animation instead of hardcoding the animation names.

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

20 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Smoothing Animation Curve when looping 0 Answers

Generic 2D Animators 1 Answer

Why cant I see looping curves in Animation Window in Unity5? 0 Answers

Procedurally generate AnimationClip at runtime 3 Answers

How to make mecanim animation stay at player's position 3 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