Skip to content

Commit 9835b1f

Browse files
authored
Merge pull request #7 from Milgalu/4-feat_몬스터-ai-추가
4 feat 몬스터 ai 추가
2 parents fdfa145 + 103a892 commit 9835b1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+28500
-10
lines changed

Assets/Monster.cs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class Monster : MonoBehaviour
6+
{
7+
public float Speed = 0.8f;
8+
float h, v;
9+
float _X = 0.0f;
10+
float _Y = 0.0f;
11+
static int cnt = 0;
12+
// Start is called before the first frame update
13+
void Start()
14+
{
15+
16+
}
17+
18+
// Update is called once per frame
19+
void Update()
20+
{
21+
if (cnt == 10)
22+
{
23+
Vector3 TF = transform.position;
24+
//MosterAI moster;
25+
26+
}
27+
Vector3 playerPosition = GetPlayerPosition();
28+
Debug.Log("플레이어 포지션: " + playerPosition);
29+
}
30+
void FixedUpdate()
31+
{
32+
if (cnt == 10)
33+
{
34+
_X = Random.Range(-0.5f, 0.5f);
35+
_Y = Random.Range(-0.5f, 0.5f);
36+
cnt = 0;
37+
}
38+
cnt++;
39+
// Point 1.
40+
h = _X; // 가로축
41+
v = _Y; // 세로축
42+
43+
// Point 2.
44+
transform.position += new Vector3(h, 0, v) * Speed * Time.deltaTime;
45+
}
46+
public Vector3 GetPlayerPosition()
47+
{
48+
// Player 오브젝트를 가져옵니다.
49+
GameObject player = GameObject.Find("Player");
50+
51+
// Player 오브젝트의 위치를 가져옵니다.
52+
Vector3 playerPosition = player.transform.position;
53+
54+
// Player의 위치를 반환합니다.
55+
return playerPosition;
56+
}
57+
void AI(Vector3 playerPosition, Vector3 mosterPosition)
58+
{
59+
60+
}
61+
}

Assets/Monster.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Player.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class Player : MonoBehaviour
6+
{
7+
public float Speed = 10.0f;
8+
public float h, v;
9+
// Start is called before the first frame update
10+
void Start()
11+
{
12+
13+
}
14+
15+
// Update is called once per frame
16+
void Update()
17+
{
18+
19+
}
20+
void FixedUpdate()
21+
{
22+
// Point 1.
23+
h = Input.GetAxis("Horizontal"); // °¡·ÎÃà
24+
v = Input.GetAxis("Vertical"); // ¼¼·ÎÃà
25+
26+
// Point 2.
27+
transform.position += new Vector3(h, 0, v) * Speed * Time.deltaTime;
28+
}
29+
30+
}

Assets/Player.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)