public class ChangeRotationSystem : ReactiveSystem<GameEntity>
{
public ChangeRotationSystem(Contexts context) : base(context.game)
{
}
protected override void Execute(List<GameEntity> entities)
{
foreach (GameEntity entity in entities)
{
Transform trans = entity.interactionDemoView.transform;
var angle = entity.interactionDemoMoveDirection.direction;
trans.rotation = Quaternion.AngleAxis(angle-90, Vector3.forward);// 问题行
}
}
protected override bool Filter(GameEntity entity)
{
return entity.hasInteractionDemoView &&
entity.hasInteractionDemoMoveDirection;
}
protected override ICollector<GameEntity> GetTrigger(IContext<GameEntity> context)
{
return context.CreateCollector(GameMatcher.InteractionDemoMoveDirection);
}
}
代码块中的问题行trans.rotation = Quaternion.AngleAxis(angle-90, Vector3.forward),为什么这里angle要减去90?我在课中得知angle计算出来就是应该飞机应该旋转的正确角度,自己试验不减90的话,飞机头确实不会朝向目标坐标,但是减去90又不知道为什么,麻烦老师解答,感谢