Coding Help :)

Okay so i have wrote a code out… and it work and all but its not how i wonted it to be
“This is the code”

function Update()
{
   if(Input.GetKey("w"))
      animation.CrossFade("Walk");
    else
      animation.CrossFade("idle");

}

i want to know how to add a jump, reload And run animation in to this im not a coder As you can proberly tell :stuck_out_tongue: if you could help me i would be most greatfull :slight_smile:

Thanks.

Meltdown is completely correct, no one will write code for you especially when all of the resources are around you to do what you want.
For Shooting and Reloading look at the old FPS Tutorial scripts.

As far as calling animations you have it all written sweet at the moment though with Reload animations etc what you want to do is call the animation and wait for it to end before you continue to shoot. Heres a few answers on ways to do it: How can I wait for an animation to complete? - Questions & Answers - Unity Discussions

To make a reload Inside a GetButtonDown, GetKey etc etc relative to shooting every time it is pressed or called a variable which is the capacity of ammo you have gets -= 1; and once that value reaches 0 the Reload function is called or if you press the reload key.

To make shooting the most common ways I have seen is to use Raycast and when it hits a rigidbody to send a message as to whether it takes damage or not and Instantiating a projectile which when collides with an enemy OnCollide etc the enemy loses heath.

Running is simple, its just another crossfade relative to when you press your set run key and then merely change the value of your walking speed. (Use GetKeyDown / GetKeyUp or GetButtonDown / GetButtonUp to change the value ) (Unsure if your using a CharacterController or not. Its all relative to that.

Jumping is the same as walking except turning the animation on can be relative to whether your grounded or not.

Setting all of them up is easy using syntax correctly and making sure you use else if so if run is down run, else if walk.
If you have problems setting it up after you have scripted everything we would be happy to help you. As Meltdown said “if you run into problems we are always happy to help”

Im unsure what your making but I hope you understand my talk. I’d assume you are making a shooting game or something similar.

function Update()
{
if (Input.GetKeyDown(KeyCode.W))
{
animation.CrossFade(“Walk”);
}
else if (Input.GetKeyDown(KeyCode.Space))
{
animation.CrossFade(“jump”);
}
else if (Input.GetKeyDown(KeyCode.Q))
{
animation.CrossFade(“reload”);
}
else if (Input.GetKeyDown(KeyCode.E))
{
animation.CrossFade(“run”);
}
else
{
animation.CrossFade(“idle”);
}
}

You still have to add the animation into the model yourself. This code will only play your animations to see if they work. You will have to find/write/get someone to write you a script to control a character