using UnityEngine;
using System.Collections;
public class ball : MonoBehaviour {
int sum = Random.Range(0, 2);
private Rigidbody2D rig2d;
void Start ()
{
rig2d = GetComponent<Rigidbody2D>();
if (sum==0)
{
rig2d.AddForce(new Vector2(60, 0));
}
else
{
rig2d.AddForce(new Vector2(-60, 0));
}
}
void date(Collision2D col)
{
print("s");
if (col.collider.tag == "Player")
{
Vector2 velocit = GetComponent<Rigidbody2D>().velocity;
velocit.y = velocit.y / 2f + col.rigidbody.velocity.y / 2;
GetComponent<Rigidbody2D>().velocity = velocit;
}
}
}
using System.Collections;
头文件是灰色的