Stick_movement.cs 913 Bytes
Newer Older
jang dong hyeok's avatar
.    
jang dong hyeok committed
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Stick_movement : MonoBehaviour
{
    public float speed = 0.0001f;
    // Start is called before the first frame update
    void Start()
    {
        position = GetComponent<Stick>
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Space))
        {
            this.transform.Translate(0, speed * Time.deltaTime, 0);
        }
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
        {
            this.transform.Translate(speed * Time.deltaTime, 0, 0);
        }
        if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
        {   
            if(this.transform() < this.transform(100,100,-1))
            {
                this.transform.Translate(0, 0, -speed * Time.deltaTime);
            }
            
        }

    }
}