// Sets the position to be somewhere inside a circle
// with radius 5 and the center at zero. Note that
// assigning a Vector2 to a Vector3 is fine - it will
// just set the X and Y values.
transform.position = Random.insideUnitCircle * 5;
void CameraShake(){
if(timer>0){Vector2 targetPos = Random.insideUnitCircle * 5;
transfrom.position=new vector2(transform.position.x+targetPos.x,transform.position.x+targetPos.y,transform.position.z)
timer-=Time.deltatime;
}
}
//其中,Random.insideUnitCircle的意思是:返回一个随机的点在半径为1的圆圈内。
打赏
扫一扫,请博主喝杯咖啡~