Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash of UE4 when trying to call GetAllActorsOfClass #139

Closed
danielkcz opened this issue Jan 22, 2017 · 6 comments
Closed

Crash of UE4 when trying to call GetAllActorsOfClass #139

danielkcz opened this issue Jan 22, 2017 · 6 comments

Comments

@danielkcz
Copy link

I am not sure if I am not simply doing something wrong. I am fiddling with UE4 for last 2 months only, so I might be missing something obvious here. Either way I have official release of UE 4.14.3 with Unreal.JS plugin from marketplace. I am on Windows 10 x64.

I start UE4, open javascript console and just type in World.GetAllActorsOfClass(Actor) and execute it which makes UE4 crash immediately. Not sure if there are some logs available that could help. I also tried somewhat simpler command like World.GetGameInstance(), but with a same result.

Any advice please ?

@nakosung
Copy link
Collaborator

World? Not a GWorld? I think you tried to call non static function as a static function. It definitely seems like a bug. :)

Please try with GWorld (for play in editor) or Root.GetEngine().GetEditorWorld() (for editor) instead.

@danielkcz
Copy link
Author

danielkcz commented Jan 23, 2017

Hmm, strange. I was seeing the GWorld variable in some examples, but when I try to type it in the Javascript console, it's not offered at all and it doesn't really exists. I did not really found any meaning of that variable anywhere :( How can I get that variable please?

Either way in my opinion executing something invalid in javascript console shouldn't cause a crash of UE. Do you consider that a good behavior ? :)

In fact it did crash when I called a same thing through Javascript Component and script file which is even more strange since I had the try...catch block as many examples have.

@nakosung
Copy link
Collaborator

@FredyC In editor environment there is no GWorld. You can access GWorld in PIE context. As I mentioned earlier, it should not crash under any circumstances so I open a new issue "Crash while calling non static function as static function."

@danielkcz
Copy link
Author

danielkcz commented Jan 25, 2017

So GWorld is a global variable assigned when script is running in PIE or standalone? Is there some list of variables like that? Might be useful :)

Thanks for opening an issue :)

@nakosung
Copy link
Collaborator

You can grab list by _ = require('lodash'); _.filter(_.keys(this),x => this[x] instanceof UObject), which gives you Context, Root under editor env and Context, Root, GWorld under PIE.

I investigated the problem you reported but it actually turned out the crash was caused within internal unreal engine code, so I think that this issue should be reported to unreal engine. :)

@LanslotChung
Copy link

let asset = StaticMesh.Load('/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube')

class MyBox extends StaticMeshActor {
ctor() {
this.StaticMeshComponent.SetStaticMesh(asset)
this.StaticMeshComponent.SetMobility('Movable')
}
ReceiveActorBeginCursorOver() {
super.ReceiveActorBeginCursorOver() // not necessary
let pos = this.GetActorLocation()
pos.Z += 10
this.SetActorLocation(pos)
}
}

function test() {
console.log("TEST");
let MyBox_C = require('uclass')()(global,MyBox)
let box = new MyBox_C(GWorld)
let PC = Root.GetEngine.GetEditorWorld.GetAllActorsOfClass(PlayerController).OutActors[0]
PC.bEnableMouseOverEvents = true
PC.bShowMouseCursor = true
return function () {
box.DestroyActor()
}
}

test();

Error: file:///e:/Unreal/Project/MyProject/Content/Scripts/test.js:20: TypeError: Cannot read property 'GetEditorWorld' of undefined
Error: TypeError: Cannot read property 'GetEditorWorld' of undefined
Error: at test (file:///e:/Unreal/Project/MyProject/Content/Scripts/test.js:20:26)
Error: at file:///e:/Unreal/Project/MyProject/Content/Scripts/test.js:28:1
Error: at file:///e:/Unreal/Project/MyProject/Content/Scripts/test.js:29:3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants