Skip to content

Instantly share code, notes, and snippets.

@kazumalab
Created April 2, 2017 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazumalab/62428c7d50efa54ce233baebffa321f6 to your computer and use it in GitHub Desktop.
Save kazumalab/62428c7d50efa54ce233baebffa321f6 to your computer and use it in GitHub Desktop.
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