using UnityEngine;
using System.Collections;
public class Lift : MonoBehaviour {
public bool OnPlatform;
public bool Level1;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
if (OnPlatform == false){
OnPlatform = true;
StartCoroutine(LiftWorking(5.0f));
}
}
}
IEnumerator LiftWorking(float wait)
{
yield return new WaitForSeconds (5.0f);
LiftUp();
yield return new WaitForSeconds (5.5f);
LiftDown();
yield return new WaitForSeconds (1.5f);
StartCoroutine(LiftWorking(5.0f));
yield return true;
}
void LiftUp()
{
GetComponent<Animation>().Play("Liftup"); //<----- i want to be able to put in a public animation in here if possible like (public animation Anim1/2/3/4)
}
void LiftDown()
{
GetComponent<Animation>().Play("Liftdown"); //<----- i want to be able to put in a public animation in here if possible like (public animation Anim1/2/3/4)
}
}
Yes.
public class Player : MonoBehaviour {
[SerializeField] Animation animation; // Drag an animation in the editor.
void Start()
{
animation.Play ();
}
}
can you play a certain element in the animation module or do you have to just write it between (“???”)? cause i use it to start a lift but i dont want to have like 20 lifts and for each write another line for up or down or left or right

Do you mean bone masking? I’m not as familiar. I understand you can do it if you use a human avatar.
Start here: https://unity3d.com/learn/tutorials/modules/beginner/animation/avatar-masks
no i mean i have element 0/1 and i want to be able to just say activate element0
well, you could either put the names of all of your clips into a list, and then call the index, or just build the namestring:
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
[SerializeField] Animation anim;
//Something like this.
public void Lift(Vector2 direction)
{
string animation_name = "Lift";
animation_name += direction.y > 0f ? "-Up" : "-Down";
anim.Play (animation_name); //so Vector2(2.5f,1f) would play 'Lift-Up'
}
}