Files
M-Gameton-06/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterControl.cs
Mingu Kim 7e81853eed Monstercontrol 코드 수정
데이터테이블 기반 기본 값 추가, 애니메이션 수정
2025-02-03 23:59:23 +09:00

53 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;
namespace TON
{
public class MonsterControl : MonoBehaviour
{
public int id; // 적 고유 ID
public string name; // 적 이름
public int hp; // HP
public int damage; // 공격력
public int defense; // 방어력
public int speed = 2; // 이동속도
public string aiType; // AI 패턴?
public int dropItems; // 드롭 아이템 ID
public int eXperiencePoint; // 경험치?
public Animator animator;
GameObject target;
// Start is called before the first frame update
void Start()
{
target = GameObject.FindGameObjectWithTag("Player");
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
private void FixedUpdate()
{
// 타겟의 위치에서 내 현제 위치를 뺌
UnityEngine.Vector2 direction = target.transform.position - transform.position;
// 방향 * 속도 * 시간간격
transform.Translate(direction.normalized * speed * Time.deltaTime);
// animator.SetBool("Iidle", true);
animator.SetBool("Walk", true ); // 걷기 애니메이션
}
}
}