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 Joevis · Apr 06, 2012 at 05:58 PM · animationtransformaddmixing

Add Mixing Transform Doesn't Work!!

Hi

I've made this work on a character currently in my scene, but I just can't get it to work on the newest character I have added.

Here is the scripting I have been using

function Start () {
animation["machineGunShoot"].layer = 14; animation["laserShoot"].layer = 14;

 var mixShootLaserGun : Transform = transform.Find("waistM/back1M/back2M/RclavicleM/RshoulderM/RelbowM/RwristM/Rcannon1M");
 
 animation["laserShoot"].AddMixingTransform(mixShootLaserGun);

 var mixMachineGun : Transform = transform.Find("waist/back1/back2/Lclavicle/Lshoulder");
 
 animation["machineGunShoot"].AddMixingTransform(mixMachineGun);
 

}

function Update () {
if (Input.GetAxis("R_Trigger") > 0.1 && animation.IsPlaying("idle"))

     animation.Play("laserShoot");

}

Can anyone see any problems with what I have done? Or help me understand why it isn't working?

Thanks

Comment
Add comment · Show 5
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 Owen-Reynolds · Apr 07, 2012 at 04:18 PM 0
Share

What's wrong? Are you playing an idle/walk on a lower layer, which should "show through" but isn't (body is just frozen?) That would mean the mixAnim didn't take. Otherwise, maybe it is working, but something else is bad. Can you have Start just play shoot and idle, to check?

Can you check whether mixShootLaserGun is null (path spelled wrong)? UnityScript sometimes won't complain -- just won't do anything.

avatar image Joevis · Apr 07, 2012 at 04:22 PM 0
Share

yeh I'm playing an idle animation on a lower layer.

When the script runs I get an error:

NullReferenceException UnityEngine.AnimationState.Add$$anonymous$$ixingTransform (UnityEngine.Transform mix) mechGun.Start () (at Assets/$$anonymous$$ech Scripts/mechGun.js:9)

avatar image Owen-Reynolds · Apr 08, 2012 at 06:39 AM 0
Share

A null reference means it couldn't find something -- probably a bad path. Try printing mix$$anonymous$$achineGun and checking each part: Debug.Log(transform.Find("waist"); and so on, until it says it can't find it.

avatar image Joevis · Apr 08, 2012 at 07:55 PM 0
Share

Ok, how do I go about getting it to print something if it finds "waist"?

Sorry if it's a stupid question but I'm very new to coding :)

avatar image Joevis · Apr 08, 2012 at 08:47 PM 0
Share

It's ok now :) I managed to sort it! It was an error with the path, I had missed out a bone! Duuh!

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by garner · Apr 07, 2012 at 09:13 AM

The code you're using before the Update function never gets used because you're just playing your standard lasershoot animation. add Debug.Log("Laser Shooting"); before the animation.play("laserShoot"); to see if the if statement is executed.

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

Answer by Joevis · Apr 07, 2012 at 03:30 PM

I just tried that, and the animation is playing. It just isn't isolating the bones I want to play the animation on :/

It should work, because I used the same code for a character in the same game (obviously defining different bones) I just don't understand why it will work for one character and not for another!

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 Owen-Reynolds · Apr 07, 2012 at 04:19 PM 0
Share

These can be easier to read if you put short replies to someone as a comment on theirs.

avatar image
0

Answer by DJSwiti · Apr 08, 2012 at 10:48 PM

I think you missed some ( and ).

Try with that :

 function Update () { if ((Input.GetAxis("R_Trigger") > 0.1) && (animation.IsPlaying("idle")))
 
     animation.Play("laserShoot");
 }
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
avatar image
0

Answer by Moj · May 12, 2012 at 06:37 PM

Not sure if this is related, but whenever I set AnimationState.layer to anything other than the default (0), I get a null reference exception.

Try removing the part where you change the 'animation["animName"].layer' at the start and see if the exception goes away.

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

10 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

Related Questions

Mixing Animations 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Which transform properties can be set in a scripted animation? 1 Answer

Rotating An Object On Its Axis Once 3 Answers

problem with addmixing transform 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