Unreal.js
Unreal.js copied to clipboard
error when composing actor and components
when composing component for an Actor
class MyActor extends Actor{
ctor(){
var sp = SphereComponent.CreateDefaultSubobject("sphere");
this.SetRootComponent(sp);
var cam = CameraComponent.CreateDefaultSubobject("Cam");
cam.AttachTo(this.RootComponent);
var mesh = StaticMeshComponent.CreateDefaultSubobject("mesh");
mesh.AttachTo(cam);
}
}
javascript console will throw this error:
Error: TypeError: cam.AttachTo is not a function
Error: TypeError: cam.AttachTo is not a function
it will tell you about the first component that tries to attach to root (Cam), twice, but seems to work for the rest of the components the structure looks like this
- RootComponent(Inherited)
- Cam(Inherited)
- mesh
- Cam(Inherited)
which all seems to work, except root component does not retain the name
any help suppressing or fixing this?
I used
cam.AttachParent = this.RootComponent