Jump to content

In LUA Entity:GetDistance causes silent crash


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

No error windows or in consoles, just app closing when GetDistance called. Need this working for tutorial

local displays = GetDisplays();

--Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR)

--Create a framebuffer
local framebuffer = CreateFramebuffer(window)

--Create a world
local world = CreateWorld()

--Create a camera
local camera = CreateCamera(world)

local distanceToTarget = camera:GetDistance(Vec3(1,1,1))
Print(distanceToTarget)

--Main loop
while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do

    world:Update()
    world:Render(framebuffer)
end

 

Link to comment
Share on other sites

  • 2 weeks later...

I am perplexed. There seems to be nothing odd about the way the method is declared...

				"GetDistance", sol::overload(
					[](Entity& e, shared_ptr<Entity> b) { return e.GetDistance(b); },
					[](Entity& e, Vec3 b) { return e.GetDistance(b); },
					[](Entity& e, float x, float y, float z) { return e.GetDistance(x, y, z); }
				),

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Solution

Okay, when I declared the entity overload as a pointer it is able to find the right method.

				"GetDistance", sol::overload(
					[](Entity& e, Entity* b) {
						std::shared_ptr<Entity> ee;
						if (b) ee = b->As<Entity>();
						if (not ee) return 0.0f;
						return e.GetDistance(ee);
					},
					[](Entity& e, Vec3 b) { return e.GetDistance(b); },
					[](Entity& e, float x, float y, float z) { return e.GetDistance(x, y, z); }
				),

This will not be in the first update tomorrow, because that update is already uploaded and ready to go.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...