I have had a lot of trouble getting this easy thing to work. Can someone tell me what i am doing wrong since i have absolutely no clue.
I want my animation to change speed when i hit the 2D collider called: “Ground [UNREACHABLE]”
I am pretty new to coding so if you now to answer, try to explain it to me very carefully!
The script i am using (c#):
using UnityEngine;
using System.Collections;
public class Screen_Fade : MonoBehaviour
{
public Animation anim;
void Start()
{
anim = GetComponent<Animation>();
foreach (AnimationState state in anim)
{
state.speed = 0.05f;
}
}
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name.Equals("Ground [UNREACHABLE]"))
{
state.speed = 1f;
}
}
}