gpt4 book ai didi

Error when defining const for CollisionGroups in bevy(在bevy中为CollisionGroups定义const时出错)

转载 作者:bug小助手 更新时间:2023-10-28 10:23:32 26 4
gpt4 key购买 nike



I have an error when I try to define this const in a character.rs file:

当我尝试在character.ars文件中定义此常量时,出现错误:


const COLLISION_GROUPS_DEFAULT: CollisionGroups = CollisionGroups::new(
Group::GROUP_2,
Group::ALL - Group::GROUP_3
);

The error is:

错误是:


error[E0277]: cannot subtract `bevy_rapier2d::geometry::Group` from `bevy_rapier2d::geometry::Group` in const contexts

更多回答
优秀答案推荐

Instead of the - operator, you can use difference, which is const:

您可以使用Difference代替-运算符,Difference为const:


const COLLISION_GROUPS_DEFAULT: CollisionGroups = CollisionGroups::new(
Group::GROUP_2,
Group::ALL.difference(Group::GROUP_3),
);

更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com