How is convertToWorldSpaceAR used?

Create the following class, create an empty node, attach it and run it

import { _decorator, Component, log, Node, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NewComponent')
export class NewComponent extends Component {
  update(deltaTime: number) {
    log(this.node.name);
    const worldPosition = this.node.convertToWorldSpaceAR(Vec3.ZERO);
    log(worldPosition);
  }
}

It runs fine until “log(this.node.name);”,
but in the next line I get the following error

 [PreviewInEditor] this.node.convertToWorldSpaceAR is not a function

For example, the same error occurs when attaching to a 2D node or a 3D node instead of an empty node.
I can’t find the cause in the documentation.

What is wrong?
My version of CocosCreater is 3.8.2

bump!!

The link in the doc say it in UITransform component, so you should get it first

this.node.getComponent(UITransform).convertToWorldSpaceAR(Vec3.ZERO);
1 Like

Thank you very much.

The sample code worked.
The documentation may need to be modified.