Created
August 25, 2019 17:48
-
-
Save kleberandrade/4e8ddd76e79bc640a0b27161490d8be6 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; | |
[RequireComponent(typeof(Rigidbody))] | |
public class BreakoutBall : MonoBehaviour | |
{ | |
// Força inicial da bola | |
public float m_Force = 1000.0f; | |
// Referência para o corpo rígido | |
private Rigidbody m_Body; | |
private void Start() | |
{ | |
m_Body = GetComponent<Rigidbody>(); | |
// Define a direção inicial em Z (0, 0, 1) | |
Vector3 direction = Vector3.forward; | |
// Sorteia o valor de X para criar um angulo para frente | |
direction.x = Random.Range(-0.8f, 0.8f); | |
// Adiciona a força na bola | |
m_Body.AddForce(direction * m_Force); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment