[0]RopeJoint代码动态创建 无法设置otherbody
动态生成预制体组件,要将预制体设置Laya.RopeJoint的otherbody属性,怎么设置怎么失败。
import UIcontrol from "./UIcontrol";
/**
*
* @ author:shiguanqing
* @ email:0110110110@qq.com
* @ data: 2022-04-09 15:53
*/
export default class fruit extends Laya.Script {
static Fru:fruit;
public rope:Laya.RopeJoint
constructor() {
super();
fruit.Fru=this;
}
onAwake() {
let rig:Laya.RigidBody=this.owner.getComponent(Laya.RigidBody);
var lala=UIcontrol.FUI.bg.getComponent(Laya.RigidBody);
this.rope=this.owner.getComponent(Laya.RopeJoint);
this.rope.otherBody=lala;
console.log(lala);
let collider:Laya.CircleCollider=this.owner.getComponent(Laya.CircleCollider);
this.rope.otherAnchor=["540","1060"];
this.rope.maxLength=286;
console.log(this.owner);
console.log(this.rope.otherBody);
}
onEnable() {
}
onTriggerEnter(other: any, self: any, contact: any): void {
//搜索黏贴在圆环上
}
onUpdate(): void {
}
onDisable(): void {
Laya.Pool.recover("friut",this.owner);
}
}
import UIcontrol from "./UIcontrol";
/**
*
* @ author:shiguanqing
* @ email:0110110110@qq.com
* @ data: 2022-04-09 15:53
*/
export default class fruit extends Laya.Script {
static Fru:fruit;
public rope:Laya.RopeJoint
constructor() {
super();
fruit.Fru=this;
}
onAwake() {
let rig:Laya.RigidBody=this.owner.getComponent(Laya.RigidBody);
var lala=UIcontrol.FUI.bg.getComponent(Laya.RigidBody);
this.rope=this.owner.getComponent(Laya.RopeJoint);
this.rope.otherBody=lala;
console.log(lala);
let collider:Laya.CircleCollider=this.owner.getComponent(Laya.CircleCollider);
this.rope.otherAnchor=["540","1060"];
this.rope.maxLength=286;
console.log(this.owner);
console.log(this.rope.otherBody);
}
onEnable() {
}
onTriggerEnter(other: any, self: any, contact: any): void {
//搜索黏贴在圆环上
}
onUpdate(): void {
}
onDisable(): void {
Laya.Pool.recover("friut",this.owner);
}
}
没有找到相关结果
已邀请:
要回复问题请先登录
0 个回复