Search Unity

Animator Object?

Discussion in 'Animation' started by Benzaboy2003, Jul 21, 2017.

  1. Benzaboy2003

    Benzaboy2003

    Joined:
    Jul 17, 2017
    Posts:
    25
    hi, im trying to make an animation for an axe to chop down trees. ive got the .anim file and the controller file but dont know how to place them onto an object for a script to read. can anyone help me on creating the object?

    Also will i need to edit this script for it to play the animation if im to run it from a different piece of code?
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Axe : MonoBehaviour {
    6.  
    7.     public Animation anim;
    8.    
    9.     public void Swing()
    10.     {
    11.         anim.Play();
    12.     }
    13. }
    14.  
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,535
    You should probably start with some basic Unity tutorials like Survival Shooter.

    The tutorial covers how to do basic stuff like you're asking about.
     
  3. Benzaboy2003

    Benzaboy2003

    Joined:
    Jul 17, 2017
    Posts:
    25
    this is using unity 4, so it changes the code a little. plus they changed the code alot for what i need because theyre animating the movement ect.
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,535
    The reason I suggested the tutorial is because the principles are the same and it doesn't sound like you are aware of what role Animations and Animator Controllers play in the character structure. Rather than explain how all of that works, it's easier for you to just review the basic tutorials about animation to get a firm understanding of how to do what you want.