-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlash.cs
35 lines (28 loc) · 917 Bytes
/
Flash.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Importe essa biblioteca
using UnityStandardAssets.CrossPlatformInput;
public class Flash : MonoBehaviour {
Rigidbody2D rb;
public float velX, velY;
void Start () {
rb = GetComponent<Rigidbody2D>();
}
void Update () {
//pega o movimento na horizontal
velX = CrossPlatformInputManager.GetAxis("Horizontal");
//pega o movimento na vertival
velY = CrossPlatformInputManager.GetAxis("Vertical");
if (velX < 0)
{
transform.localScale = new Vector2(-0.210174f, 0.3999445f);
}
else
{
transform.localScale = new Vector2(0.210174f, 0.3999445f);
}
//movimenta o player de acordo com os toques nos botões
rb.velocity = new Vector2(velX * 50f, velY * 50f);
}
}