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 knuckles209cp · Dec 15, 2013 at 01:11 AM · animationfreeaimsprint

Sprinting animation

I know i have asked this ALOT but everytime it works i change it up , and this ... will be the last time :)

So anyway basicly i have aim down sights script ( NOT mine ) i got it from the wiki , but if i use it then i cant play any animations OR i havr to wait till the animations are done, then it aims down sights , so when i hold up AND shift i want my sprint to play and then i want my gun to return to its original position im trying to look for a fresh script but until then i will lend you one to modify :)

Animation script :

 if(Input.GetKey(KeyCode.W))
     animation.Play("walkUMP");
 if(Input.GetKey(KeyCode.S))
     animation.Play("walkUMP");
 if(Input.GetKey(KeyCode.A))
     animation.Play("walkUMP");
 if(Input.GetKey(KeyCode.D))
     animation.Play("walkUMP");
 else if(!Input.anyKey)
     animation.Play("idleUMP");


Aim down sights script :

  var nextPos = -0.1597214;
  var nextField = 40.0;
  var nextPos2 = -0.2532201;
  var dampVelocity = 0.4;
  var dampVelocity2 = 0.4;
  var dampVelocity3 = 0.4;
  
  function Update () {
     var newPos = Mathf.SmoothDamp(gun.transform.localPosition.x, nextPos, dampVelocity, .3);
     var newField = Mathf.SmoothDamp(Camera.main.fieldOfView, nextField, dampVelocity2, .3);
     var newPos2 = Mathf.SmoothDamp(gun.transform.localPosition.y, nextPos2, dampVelocity3, .3);
  
     gun.transform.localPosition.x = newPos;
     gun.transform.localPosition.y = newPos2;
     Camera.main.fieldOfView = newField;
  
     if (Input.GetButton("Fire2")) {
 
         nextField = 40.0;
         nextPos = -0.2202;
         nextPos2 = -0.2410035;
  
 
         GetComponent("CharacterController").maxForwardSpeed = 3;
         GetComponent("MouseLook").sensitivityX = 2;
         camera.main.GetComponent("MouseLook").sensitivityX = 2;
         camera.main.GetComponent("MouseLook").sensitivityY = 2;
     } else {
 
         nextField = 60.0;
         nextPos = -0.1597214;
         nextPos2 = -0.2532201;
  
 
         GetComponent("CharacterController").maxForwardSpeed = 6;
         GetComponent("MouseLook").sensitivityX = 6;
         camera.main.GetComponent("MouseLook").sensitivityX = 6;
         camera.main.GetComponent("MouseLook").sensitivityY = 6;
     }
  }

Of course any help will be apprecitated no matter how small the info is :) Thank you for your time

Comment
Add comment · Show 4
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 RetepTrun · Dec 15, 2013 at 03:46 AM 0
Share

Dont really understand enough about the overall player setup to understand how this would conflict with animations.

For a shot in the dark: make it function LateUpdate so it will overide the animations.

avatar image knuckles209cp · Dec 15, 2013 at 04:03 AM 0
Share

what do you mean?

avatar image RetepTrun · Dec 15, 2013 at 04:12 AM 0
Share

-explain how you made the player -try replacing where it says "Update" with "LateUpdate"

avatar image knuckles209cp · Dec 15, 2013 at 04:39 AM 0
Share

ok i did that , nothing really happening , it just moves a bit further ... the player is just the basic FPS controller and i have my gun attached to my main camera - also attached to my fps controller

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RetepTrun · Dec 15, 2013 at 06:13 PM

No idea what is wrong with the scripts.

You could try a workaround.

  1. in blender or some other program make armature/skeleton with 3 disconected bones. named: Master, cam, gun.

  2. make some sort of mesh to attach to it just so you can adjust the object scale in unity when you import.

  3. create animations. look_down_sight, unlook_down_sight, reload(optional)

  4. import to unity

  5. adjust scale

  6. make the skeleton child of the thing that walks around

  7. re-arrange hierarchy of character. camera should be child of cam bone, master should have the mouse look script that the camera had. The skeleton should be looking around and therefore the camera looking around because it is a child.

  8. skeleton option "always animate" on

  9. animations mode "clamp". (or maybe it was clampforever I cant remember)

  10. now just play the animations when you want them to happen.

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

17 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

Related Questions

Play animation if 2 buttons are held down? 1 Answer

Animations interupting Aim-Script 0 Answers

Cannot get sprint animation to play when crouch works fine? 0 Answers

Aim 360 degrees in 2D game 0 Answers

what's wrong with this script? 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