mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-11-11 04:22:40 +00:00
hopefully this doesnt break stuff
This commit is contained in:
1 parent
2195ac327b
commit
8191d4e79e
14 files changed
+537
-46
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MeanBird : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public Movement controller;
|
||||
public Animator animator;
|
||||
[SerializeField] float runSpeed = 5.0f;
|
||||
// private Rigidbody2D m_Rigidbody2D;
|
||||
private bool attack;
|
||||
private Vector3 direction;
|
||||
Transform player;
|
||||
[SerializeField] float detectRange;
|
||||
|
||||
private float accelTime = 1f;
|
||||
private float elapsed = 0f;
|
||||
private float t;
|
||||
|
||||
//constructs an NPC using parameters
|
||||
|
||||
void Start()
|
||||
{
|
||||
player = GameObject.FindGameObjectWithTag("Player").transform;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
// if(Movement.pause) {
|
||||
// animator.SetFloat("Horizontal", 0);
|
||||
// }
|
||||
// if (animator != null && !Movement.pause) {
|
||||
// animator.SetFloat("Horizontal", (horizontalMove/Mathf.Abs(horizontalMove)));
|
||||
// animator.SetBool("Airborne", !controller.m_Grounded);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate() {
|
||||
if(!attack) {
|
||||
direction = player.position - transform.position;
|
||||
if(direction.magnitude < detectRange) {
|
||||
attack = true;
|
||||
Debug.Log("attack");
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(t < 1f) {
|
||||
t = elapsed / accelTime;
|
||||
t = t * t * (3f - 2f * t);
|
||||
}
|
||||
else {
|
||||
t = 1f;
|
||||
}
|
||||
GetComponent<Rigidbody2D>().MovePosition(transform.position + direction.normalized * runSpeed * t / 100f);
|
||||
elapsed += Time.fixedDeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user