let position = this.node.getPosition()
tween(this.node).to(0.1,{position:new Vec3(position.x+1, position.y, 0)}).to(0.1,{position:new Vec3(position.x-1, position.y, 0)}).to(0.1,{position}).start()
这样缓动以后 刚体也跟着移动了 只是想做个 被攻击后身体晃动一下的效果
let position = this.node.getPosition()
tween(this.node).to(0.1,{position:new Vec3(position.x+1, position.y, 0)}).to(0.1,{position:new Vec3(position.x-1, position.y, 0)}).to(0.1,{position}).start()
这样缓动以后 刚体也跟着移动了 只是想做个 被攻击后身体晃动一下的效果
你把刚体单独放在一个节点,是不是能处理你的需求
node作为角色根节点,刚体跟node绑定,身体渲染节点作为node的子节点,做晃动效果针对渲染节点就行了
tween(this.node.getComponent(UITransform)).to(0.1,{anchorX:0.4,anchorY:0.5}).to(0.1,{anchorX:0.6,anchorY:0.5}).to(0.1,{anchorX:0.5,anchorY:0.5}).start()
解决了 移动节点的锚点就可以了