-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPaddlePlayer2.cs
72 lines (64 loc) · 1.82 KB
/
PaddlePlayer2.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using UnityEngine;
using System.Collections;
public class PaddlePlayer2 : MonoBehaviour {
public int speed = 50;
private Vector3 movement;
private bool limitleft = false, limitright = false;
private GameObject wall_left, wall_right;
// Use this for initialization
void Start () {
}
// void OnCollisionEnter(Collision collision) {
// Debug.LogError("Entra en la derecha");
// if (collision.gameObject.CompareTag("RWall")){
// Debug.LogError("Entra en la derecha");
// }
// else if (collision.gameObject.CompareTag("LWall")){
// Debug.LogError("Entra en la izquierda");
// }
//
// }
// void OnCollisionEnter(Collision collision) {
// if (collision.gameObject.CompareTag("Wall1")){
// limitright = true;
// }
// else if (collision.gameObject.CompareTag("Wall2" )) {
// limitleft = true;
// }
// }
//
// void OnCollisionExit(Collision collision) {
// if (collision.gameObject.CompareTag("Wall1")){
// limitright = false;
// }
// else if (collision.gameObject.CompareTag("Wall2" )) {
// limitleft = false;
// }
//
// }
// void OnCollisionExit(Collision collision) {
// Debug.LogError("Sale de la derecha");
// if (collision.gameObject.CompareTag("RWall")){
// Debug.LogError("Sale de la derecha");
// }
// else if (collision.gameObject.CompareTag("LWall")){
// Debug.LogError("Sale de la izquierda");
// }
//
// }
// Update is called once per frame
void Update () {
if (Input.GetKey("right")){
if (this.transform.localPosition.x > -0.386f){
movement = Vector3.left;
this.transform.Translate(movement * 500 * Time.deltaTime);
}
}
if (Input.GetKey("left")){
if (this.transform.localPosition.x < 0.386f){
movement = Vector3.right;
this.transform.Translate(movement * 500 * Time.deltaTime);
}
}
}
}