using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Archer : MonoBehaviour {
public KeyCode shotKey;
public GameObject arrowObj;
public Transform shootPosTf;
private int frame = 0;
public GameObject testObj;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
////키를 누르면 화살을 쏜다
if(Input.GetKeyDown(shotKey)){
Instantiate(arrowObj).transform.position = shootPosTf.position;
}
if(Input.GetKeyDown(KeyCode.RightArrow)){
testObj.SetActive(false);
}
if (Input.GetKeyDown(KeyCode.RightArrow)) testObj.SetActive(false);
if (Input.GetKeyDown(KeyCode.LeftArrow)) testObj.SetActive(true);
////키를 점프
if (Input.GetKeyDown(KeyCode.Space)){
GetComponent<Rigidbody2D>().AddForce(Vector3.up * 300f);
}
frame++;
if(frame%100 == 0){
Instantiate(arrowObj).transform.position = shootPosTf.position;
}
}
}
|