Created
April 2, 2017 00:08
-
-
Save kazumalab/62428c7d50efa54ce233baebffa321f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Target : MonoBehaviour { | |
private float RotateSpeed = 100f; | |
private float Radian = 0f; | |
private float HeadPoint = 1.2f; | |
private SpriteRenderer AttentionSprite; | |
private Enemy parentEnemy; | |
public Sprite Attention; | |
public Sprite UnAttention; | |
// Use this for initialization | |
void Start () { | |
AttentionSprite = GetComponent<SpriteRenderer> (); | |
AttentionSprite.sprite = UnAttention; | |
parentEnemy = transform.parent.GetComponent<Enemy> (); | |
} | |
// Update is called once per frame | |
void Update () { | |
Radian += Time.deltaTime; | |
transform.Rotate (Vector3.up * Time.deltaTime * RotateSpeed); | |
transform.localPosition = Vector3.up * HeadPoint + Vector3.up * (Mathf.Sin(Radian) / 10f); | |
print (Mathf.Sin (Radian)); | |
if (parentEnemy.isDrawingAttention) { | |
AttentionSprite.sprite = Attention; | |
} else { | |
AttentionSprite.sprite = UnAttention; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment