2
我有一个物体A和B.当我点击物体B时,A旋转到物体B(A面B)。 B不会面对A.我需要做的是: 当A面向B时,我需要A面对相反的方向。我有一个旋转的代码来看看B.如何旋转后面对相反的方向?旋转一个物体以面对相反的方向
Vector3 targetDirection = target - transform.position;
float step = speed * Time.deltaTime;
Vector3 newDirection = Vector3.RotateTowards (turretDome.transform.forward, targetDirection, step, 0.0F);
turretDome.transform.rotation = Quaternion.LookRotation (newDirection);