Example #1
0
	protected void Update()
	{
		if(player == null || weapon == null)
		{
			player = EntityUtils.GetEntityWithTag("Player");

			if(player == null)
			{
				return;
			}

			weapon = player.GetComponentInChildren<Weapon>().transform.parent;
			eyes = player.transform.Find("Eyes");

			delay = new Vector3(0f, 0f, 0f);
			previous = new Vector2(eyes.rotation.eulerAngles.x, player.transform.rotation.eulerAngles.y);
			target = previous;
			normalAnim.localPosition = baseNormal;
			adsAnim.localPosition = baseAds;
		}

		previous = target;
		target = new Vector2(eyes.rotation.eulerAngles.x, player.transform.rotation.eulerAngles.y);
		if(previous.x > 270f && target.x < 90f) { previous.x -= 360f; }
		else if(previous.x < 90f && target.x > 270f) { previous.x += 360f; }
		if(previous.y > 270f && target.y < 90f) { previous.y -= 360f; }
		else if(previous.y < 90f && target.y > 270f) { previous.y += 360f; }
		delay = Vector3.Slerp (delay, new Vector3 (previous.x - target.x, previous.y - target.y, 0f), 0.1f);

		walking = player.GetComponent<CharacterController> ().velocity != Vector3.zero;
	}
 void setHighlightColor(Entity entity)
 {
     if (currentCharacterSelected != null)
     {
         currentCharacterSelected.GetComponentInChildren<SpriteRenderer>().color = Color.white;
     }
     entity.GetComponentInChildren<SpriteRenderer>().color = highlightColor;
 }