Jump to content

Camera Pick and GetKeyValue doesnt work


Slastraf
 Share

Recommended Posts

if window:MouseHit(1) then
local pickinfo= PickInfo()
local p1 = Window:GetCurrent():GetMousePosition()
--local box = Model:Box()
if (self.camera:Pick(p1.x,p1.y,pickinfo,0.5,true)) then
if pickinfo.entity then
if pickinfo.entity:GetKeyValue("Button")~="" then
--box:SetScale(0.2,0.2,0.2)
--box:SetPosition(pickinfo.entity:GetPosition(true),true)
System:Print(tostring(pickinfo.entity:GetKeyValue("Button")))
end
end
end
end

 

the above is the camera pick , I cant find anything .

The camera pick should Print the Key value of the box in the script below.

However, it prints nothing and I dont know why.

 

Script.localKeyValue = -1--string " Key Value Integer"

 

function Script:Start()

self.entity:SetKeyValue("Button",self.localKeyValue)

end

Link to comment
Share on other sites

Works ok for me. Prints out -1. Granted I wouldn't use a pick with a radius as its not a precise pick, but it works in my test of the scripts. Keep in mind, you are setting the pick radius to be 0.5 meters. My suggestion would be to use System:Print()'s in your multiple if-statements to find where it is failing to get to the Print you want to see and to not use spherical picks, especially on small objects.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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...