Created
August 25, 2019 18:04
-
-
Save kleberandrade/44da8470fb271913299835265144858f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class BreakoutPaddle : MonoBehaviour | |
{ | |
// Velocidade do movimento | |
public float m_Speed = 20.0f; | |
private Rigidbody m_Body; | |
private void Start() | |
{ | |
m_Body = GetComponent<Rigidbody>(); | |
} | |
private void FixedUpdate() | |
{ | |
// Recebe o entrada das setas direita e esquerda | |
float horizontal = Input.GetAxis("Horizontal"); | |
// Cria um vetor aplicando a entrada no eixo X | |
Vector3 movement = Vector3.zero; | |
movement.x = horizontal * m_Speed * Time.deltaTime; | |
// Move o corpo rigído com o vetor de entrada | |
m_Body.MovePosition(m_Body.transform.position + movement); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment