Search Unity

Setting an animation with the mouse wheel

Discussion in 'Scripting' started by Teaufou, Sep 17, 2014.

  1. Teaufou

    Teaufou

    Joined:
    Jun 30, 2014
    Posts:
    3
    Hello!

    I'm trying to make a script that set an animation forward or backward on her timeline with the mouse wheel.
    The scrip in question is on the character, and the animation on a parent gameobject.

    For the moment, I have this but, of course, it does not work.

    using UnityEngine;
    using System.Collections;

    public class AnimationControl : MonoBehaviour {
    // Use this for initialization
    void Start () {
    }

    // Update is called once per frame

    void Update () {
    if(Input.GetAxis("Mouse ScrollWheel") > 0) { animation["AnimationJourNuit"].time ++; }

    else if(Input.GetAxis("Mouse ScrollWheel") < 0) { animation["AnimationJourNuit"].time --; }
    animation["AnimationJourNuit"].speed = 0.0;
    animation.Play(AnimationJourNuit);
    }
    }

    I'm novice in code, and I don't know if I'm far or near the solution.
    Please tell me where I'm wrong and what should I do to correct the issue.
     
    Last edited: Sep 17, 2014