Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Predator3000

Weapon Change with animation

Question

this is my script to change weapons how i can do it with animation?

 

var Primary : GameObject;
var Secondary : GameObject;
var Melee : GameObject;
 
var Primarykey : String;
var Secondarykey : String;
var Meleekey : String;
 
function Update ()
{
if(Input.GetButtonDown("1"))
{
Primary.SetActiveRecursively(true);
        Secondary.SetActiveRecursively(false);
Melee.SetActiveRecursively(false);
}
 
if(Input.GetButtonDown("2"))
{
Primary.SetActiveRecursively(false);
        Secondary.SetActiveRecursively(true);
Melee.SetActiveRecursively(false);
}
 
if(Input.GetButtonDown("3"))
{
Primary.SetActiveRecursively(false);
        Secondary.SetActiveRecursively(false);
Melee.SetActiveRecursively(true);
}
}

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0

I assume that you use a legacy system for these animations. You need to integrate component, define all aniamtions and call it :

Please login or register to see this link.

Please login or register to see this code.

Share this post


Link to post
Share on other sites

  • 0

Lol
You must integrate the component in your script which is required so as to play an animation.

Then, by using GetComponent, you can play it, modify animation speed, stop, etc.

I didn't see any component in your previous script.

Если ты не можешь решить ту проблему, объясню тебе все. Но сейчас я не могу. Я занят и без компьютера ++

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

=)) dont tell him his stuff is bad, hes learning so get away with your negative comments and help someone instead....

Share this post


Link to post
Share on other sites
  • 0

OK. I am at home. See this picture which I did so as to show you this required component.

Into this component you find all animations. In example, for my MP project I use the BootCampSoldier model.

In my script I declare this component and (as I said previously) I play each of these animations by using a GetComponent giving a name parameter.

 

811256anim.jpg
 

Please login or register to see this code.

So in order to animate your weapon, you can develop some script which could be similar with this example :

Please login or register to see this code.

For me all is clear. If you cannot understand this example I think that you must study a tutorial about legacy system. I hope that it helps you ++

Share this post


Link to post
Share on other sites
  • 0
My self-discovery : very simple :d
 
you create a animation, eg called : " Idle " on weapon then and put it on the card Animation like in the picture ! And and choose to " PlayAutomatically "
 
lVMywvT.jpg

 

 

and now every time you change weapons it will perform animation "Idle" once !

You can create a weapon each animation at switch !

 

 

Sorry if confusing, because I used Google translated :d

Edited by SonEvil

Share this post


Link to post
Share on other sites
  • 0

Why everyone hates mecanim. It manages tons of animations and blends them together nicely. Plus you can manage them in realtime.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...