Skip to content

Instantly share code, notes, and snippets.

View denforlatte's full-sized avatar

Danny Wilkins denforlatte

View GitHub Profile
void OnCollisionEnter2D (Collision2D collision) {
Vector2 xtweak = new Vector2 (Random.Range (-ballKick,ballKick),0f);
Vector2 ytweak = new Vector2 (0f,Random.Range (2f,ballKick));
if (hasStarted) {
if(GetComponent<Rigidbody2D>().velocity.x >= -bounceTolerance && GetComponent<Rigidbody2D>().velocity.x <= bounceTolerance){
print ("Engage X kick!");
GetComponent<Rigidbody2D>().velocity += xtweak;
} else if (GetComponent<Rigidbody2D>().velocity.y >= 0 && GetComponent<Rigidbody2D>().velocity.y <= bounceTolerance){
print ("Engage Y kick!");