直接上代码通过使用Vector3.Reflect方法实现游戏物体的反射
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ball : MonoBehaviour
{
private Vector3 dir = new Vector3(-1,1,0).normalized;
void Start () {
}
// Update is called once per frame
void Update ()
{
transform.Translate(dir * Time.deltaTime * 2);
}
void OnCollisionEnter(Collision other)
{