Animation Problems

Updated on August 20, 2017 in [A] Animation
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on August 20, 2017

I made a script that enables/disables the Polygon Collider 2D component when the ”g” key is pressed. This script is attached to a GameObject called Indingo(The Player). So when the “g” key is pressed the script enables or disables the Polygon Collider 2D and plays the animation. 

  • What I want: I want the Polygon Collider 2D to be disabled at the beginning. Meaning I want the Polygon Collider 2D to be disabled at the start of the game, and for the Polygon Collider 2D to be enabled when the animation starts and be disabled when the animation ends all when the ”g” key is pressed.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Indingo_Lava_Burst_Activator_Deactivator : MonoBehaviour

private PolygonCollider2D myPolygonCollider2D;
private Animator myAnimator;

// Use this for initialization
void Start()
myPolygonCollider2D = GetComponent<PolygonCollider2D>();
myAnimator = GetComponent<Animator>();

// Update is called once per frame
void Update()
if (Input.GetKeyUp(KeyCode.G))
myPolygonCollider2D.enabled = !myPolygonCollider2D.enabled;
myAnimator.SetBool(“attack”, true);
myAnimator.SetBool(“attack”, false);

  • Liked by