addComponent(BoxCollider2D)添加失败,请大佬指教

本版3.2以上;
image
在属性面板添加之后image 有效果;

通过代码方式添加没效果
let a =this.node.addComponent(BoxCollider2D);

    a.size.width = 100;

    a.size.height = 100;

    a.offset=v2(0,0)

    a.tag=1;

image

:cry:
–>

用的是box2d

怎么没效果,是添加组件没生效还是你的组件设置没生效,不过你最好调用一下碰撞体得apply方法

1赞

你是不是没有代码添加刚体组件… :sweat_smile:

1赞

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。