import { _decorator, Component, Node ,TextureCube, Vec3, find} from 'cc';
const { ccclass, property } = _decorator;
@ccclass('CubeCliber_transport')
export class CubeCliber_transport extends Component {
count: number;
currentComponent: Component;
currentNode: Node;
start() {
this.count = 0;
this.currentNode = find("CubePlayer");
}
update(deltaTime: number) {
if (this.count > 20) {
this.currentNode.position = new Vec3(this.currentNode.position.x + 1, this.currentNode.position.y, this.currentNode.position.z);
console.log(this.currentNode.position);
//this.node.position = new Vec3(this.node.position.x + 1, this.node.position.y, this.node.position.z);
this.count = 0;
}
this.count++;
}
}
使用find函数可以用来查找整个场景下的组件,