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 Jrc4055 · Apr 03, 2013 at 01:16 PM · animationmousecontrolchild objectimported

Cannot control gameobject and play animation simultaneously

Hey there! I've been trying to fix this problem for a little under a week now, and have no idea what i'm doing wrong:

I have this turret that you control with the mouse. I want it to play a recoil animation on the nozzles the same time it fires a projectile. However, I can't get this to work. Here are some things that happen.

  1. If I had the turret rotated, it would jerk back to the position it was animated in once I fired. And I can't control the turret while firing.

alt text alt text

  1. when I tried to make a new animation in Unity, It transported the entire turret to 0,0,0. And it didn't animate the nozzle, it animated the entire turret gameobject.

Here is the animation script:

 #pragma strict
 
 var projectile : GameObject;//ignore
 internal var nextFire :float;
 
 var fireRate : float = 0.5;
 
 var clip1 : AnimationClip;
 var clip2 : AnimationClip;
 
 
 function Start () {
 
 
 
 }
 
 function Update () {
    if (Input.GetButton ("Fire1")&& Time.time > nextFire) {
    
       animation.Play(clip1.name);
       animation.Play(clip2.name);
       
       nextFire = Time.time + fireRate;
       
      
       
    }
 }

And the control script(sorry about the mess):

 //#pragma strict
 
 /*var forwardSpeed : float = 3;//ignore
 var roll : float = 2;//ignore
 var lift : float = 25; */
 var yAxis : float = 2;
 var xAxis : float = 2;
 /*var deadZoneXPlus : float = 5;  
 var deadZoneXMinus : float = -5;
 var deadZoneYPlus : float = 5;
 var deadZoneYMinus : float = -5;
 var bullet : GameObject;
 var speed : float; */
 
 function Start() {
 
   
 }
 
 
 function Update () 
 {
   
       //forward speed
   //var forward = Input.GetAxis("Mouse Y")*forwardSpeed;
 
  
    //turn roll
  // var rolly = Input.GetAxis("Mouse X")*roll;
  
     //rotate Buggy
  
    //var lifty = Input.GetAxis("Jump")*lift;
    //Lift dropship
  
     var y = Input.GetAxis("Mouse Y")*yAxis;
   
    
    
      //yaw
     var x = Input.GetAxis("Mouse X")*xAxis;
  
   //roll
   //transform.Rotate(0,rolly, 0);
    //if ( Input.GetAxis ("Mouse X") > deadZoneXPlus || Input.GetAxis("Mouse X") < deadZoneXMinus) 
   //{
   
   //pitch
   transform.Rotate(0,y,0);
   //}
   
   //if (Input.GetAxis ("Mouse Y") > deadZoneYPlus || Input.GetAxis ("Mouse Y") < deadZoneYMinus) {
   //yaw
   transform.Rotate(x,0,0);
   //}
   
   //move forward
   //rigidbody.AddRelativeForce(0,forward,0);
   
   //lift
   //rigidbody.AddRelativeForce(0,0,lifty);
   
   
   /*if (Input.GetButton("fire1")){
   
   var clone : GameObject = Instantiate(bullet, transform.position, transform.rotation);
   
   clone.transform.TransformDirection(Vector3(speed,0,0));
   */
   
     
   
   }
   
 
 }



prb2.jpg (184.2 kB)
prb1.jpg (175.9 kB)
Comment
Add comment · Show 2
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 · Apr 04, 2013 at 12:44 AM 1
Share

Your animation probably animates position and rotation of the same objects you are transfor$$anonymous$$g. Therefore overwriting your transformations. If you want to negate this, put positioning in LateUpdate, which is after animations have been appied

avatar image Loius · Apr 04, 2013 at 01:36 AM 0
Share

That's not a comment :p

0 Replies

· Add your reply
  • Sort: 

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

12 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

Related Questions

How to make camera position relative to a specific target. 1 Answer

Controlling animation with mouse 0 Answers

Can I make animations snap to a frame? 1 Answer

Zoom in/out with right button of mouse 1 Answer

Space Flying Script Using Mouse 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