1
Support / Re: 2D toolkit incrasing performance
« on: April 17, 2014, 10:18:03 pm »
Sweet! what if i set a prefab inside one of the tiles in the Data tab of the tilemap? do those also get culled?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
tk2dSpriteAnimator animator;
private Transform groundCheck; // A position marking where to check if the player is grounded.
private bool grounded = false; //Whether or not the player is grounded.
// Use this for initialization
void Start ()
{
animator = GetComponent<tk2dSpriteAnimator> ();
groundCheck = transform.Find("groundCheck");
Invoke ("PlayInABit", 5f);
}
// Update is called once per frame
void Update ()
{
grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Layer 0"));
if(animator.IsPlaying("Walk") && animator.CurrentFrame >= 1)
{
transform.Translate (1.5f * Time.deltaTime, 0, 0);
}
if(grounded)
{
Debug.Log (grounded.ToString());
animator.Play ("Walk");
}
else
{
Debug.Log (grounded.ToString());
animator.Play ("Jump");
}
}
void PlayInABit()
{
animator.Play ("Walk");
}