Player.cs
1.48 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent (typeof(PlayerController))]
public class Player : MonoBehaviour {
public float moveSpeed = 300f;
PlayerController controller;
public float horizontalController;
public float verticalController;
public Vector3 startPosition;
bool grounded;
// Use this for initialization
private void Awake()
{
startPosition = gameObject.transform.position;
Debug.Log("Start Position: " + startPosition);
}
void Start () {
controller = GetComponent<PlayerController>();
}
// Update is called once per frame
void Update ()
{
float hInput = GravityBall.Instance.GetInputAxis("Horizontal");
float vInput = GravityBall.Instance.GetInputAxis("Vertical");
horizontalController = hInput;
verticalController = vInput;
Vector3 moveInput = new Vector3(horizontalController + Input.GetAxisRaw("Horizontal"), 0, verticalController + Input.GetAxisRaw("Vertical"));
moveInput = moveInput.normalized;
Vector3 moveVelocity = moveInput * moveSpeed;
controller.Move(moveVelocity);
}
public void Revive()
{
gameObject.transform.position = startPosition; //시작 위치로 이동
gameObject.SetActive(true); //다시 재생성
}
public void Die()
{
Debug.Log(gameObject.name + "sss");
gameObject.SetActive(false);
}
}