so im using Unity 2017.2.0f3 since i got license for plus, but my quistion is if there is changes for the code in 2017 to get animator.SetTrigger? my fox does not jump when it collides with the stone. nor is it attacking when it colide with other objects
my stone got the collider2D, and Stone and Defender Script. fox got RigidBody2D, the scripts and collider2D
This is how my code looks:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent (typeof (Attacker))]
public class Fox : MonoBehaviour {
private Animator anim;
private Attacker attacker;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
attacker = GetComponent<Attacker>();
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D collider)
{
GameObject obj = collider.gameObject;
// Leave the method if not colliding with defender
if (!obj.GetComponent<Defender>())
{
return;
}
if (obj.GetComponent<Stone>())
{
anim.SetTrigger("Jump trigger");
} else
{
anim.SetBool("isAttacking", true);
attacker.Attack(obj);
}
Debug.Log("Fox collided with" + collider);
}
}