Jump to content

Recommended Posts

Posted

Doesn't the pick object have an x, y, z value in Lua?

 

pick = CameraPick(camera, Vec3(MouseX(), MouseY(), 1000), 0, 0)
	if pick~=nil then
		if pick.entity~=nil then
			Notify("x="..pick.x.." z="..pick.z)         -- this errors out saying it's not valid
               end
end

Posted

The pick class should be the first parameter to CameraPick, because CameraPick returns an int saying if anything was picked or not.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

The fps script that comes with Leadwerks has

 

pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)

 

Adding pick to the first param gives me access violation and kills the editor.

 

Note this is in the Lua forum

Posted

The pick class in Lua has 5 subclasses (entity, surface, triangle, position, normal), so you need to use pick.position.x.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

Any idea why I have to left click twice in the editor to get this code to run? Even that Notify("Inside click") won't run unless I click twice.

 

if MouseHit(1)==1 then
               Notify("Inside click")
	pick = CameraPick(camera, Vec3(MouseX(), MouseY(), 1000), 0, 0)
	if pick~=nil then
		if pick.entity~=nil then
			Notify("x="..pick.position.x.." z="..pick.position.z)
		end
	end
end

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.

×
×
  • Create New...