버튼 누르면 도끼생성 후 돌면서 날아가고 몬스터 있는 곳까지 감
멈추는거 다시 설정하고 맞추면 도끼 사라지는거 해야함!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
public class App : MonoBehaviour
{
public Hero hero;
public Axe axe;
public Button btn;
private GameObject axeGo;
// Start is called before the first frame update
void Start()
{
this.axeGo = this.axe.gameObject;
this.btn.onClick.AddListener(() =>
{
this.axeGo.SetActive(true);
this.axe.Move();
});
}
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Axe : MonoBehaviour
{
public GameObject axe;
public Transform axePoint;
public float rotateSpeed;
public Transform target;
public float speed;
private bool isMove;
// Start is called before the first frame update
void Start()
{
}
public void Move()
{
this.isMove = true;
}
public void Stop()
{
this.isMove = false;
}
// Update is called once per frame
void Update()
{
if (this.isMove)
{
this.axe.transform.Rotate(this.axe.transform.right * this.rotateSpeed * Time.deltaTime);
this.axePoint.Translate(this.target.position * this.speed * Time.deltaTime);
Vector3 dis = this.target.position - this.axePoint.position;
if (dis.z <= 0.02f)
{
this.Stop();
}
}
}
}
|
cs |
'c# > 과제' 카테고리의 다른 글
2020.05.01 2048 이차열 배열 사용해서 만들기 (0) | 2020.05.01 |
---|---|
2020.05.01 (0) | 2020.05.01 |
과제 (3) | 2020.04.22 |
2020.04.10 과제 Character Class (0) | 2020.04.12 |
2020.04.08 과제 enum 캐릭터 생성 (0) | 2020.04.08 |