Search Unity

Disable neck controller when animation occurs

Discussion in 'Scripting' started by Maker26, Nov 22, 2017.

  1. Maker26

    Maker26

    Joined:
    Nov 10, 2017
    Posts:
    23
    How can I disable the neck control when an animation occurs. Cause everytime I press a number that does an idle animation, the neck is still controllable even if I animated the neck.

    The neck is being controlled by mouse. I just want this controller to be disabled when I press those numbers.
    Here's the script:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class NeckController : MonoBehaviour
    5. {
    6.  
    7.     public float speedH = 2.0f;
    8.     public float speedV = 2.0f;
    9.  
    10.     private float yaw = 0.0f;
    11.     private float pitch = 0.0f;
    12.  
    13.     void Update()
    14.     {
    15.         yaw += speedH * Input.GetAxis("Mouse X");
    16.         pitch -= speedV * Input.GetAxis("Mouse Y");
    17.         pitch = Mathf.Clamp(pitch, -54, 55);
    18.  
    19.         transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
    20.     }
    21. }
    Do I have to add a code that disables this script while the animation is playing? If so, then what code it's needed?
     
  2. Maker26

    Maker26

    Joined:
    Nov 10, 2017
    Posts:
    23
    Is it even possible though?
     
  3. Maker26

    Maker26

    Joined:
    Nov 10, 2017
    Posts:
    23
    Did I forgot to mention that I'm a new beginner and I'm using Unity 5.6.4f?
     
  4. Maker26

    Maker26

    Joined:
    Nov 10, 2017
    Posts:
    23
    Well, this is a proof that the members of unity cannot help that many new users for some project. No need for help anymore, I already removed the project and gonna start from the simplest to the hardest.

    Topic is closed.