Jump to content

Camera picking


Rick
 Share

Recommended Posts

Below is an idea of how I'm doing my main menu. I zoomed out to get a better idea of what it is I'm looking at. The menu will be in 3D. Normally all you'd see is that scene with tree's on it close up to the camera as the background and the white play button is actually a Model:Box() I make in code. When doing camera:Pick() I'm only caring about the box I made in code. I get it a key name "id" a value of "btnNewGame". However, picking the CSG background model is coming back as the btnNewGame box was picked. I can't figure out why this would be.

 

box creation


self.buttonMaterial = Material:Load("UI/play_button.mat")
--self.buttonMaterial:SetBlendMode(1)
self.button = Model:Box()
self.button:SetScale(1, 1, .5)
self.button:SetPosition(0, -20, 2)
self.button:SetMaterial(self.buttonMaterial)
self.button:SetKeyValue("id", "btnNewGame")

 

picking code


function App:MainMenu_Update()
  if self:IsMobile() == true then
     result = self.window:TouchHit(0)
  else
     result = self.window:MouseHit(1)
  end

  local pickinfo = PickInfo()
  local p = self.window:GetMousePosition() 
  local id = ""

  if result == true then

     if self.camera:Pick(p.x, p.y, pickinfo, .5, true) == true then

        id = pickinfo.entity:GetKeyValue("id")

        if id == "btnNewGame" then

           self:Gameplay_Enter()
           self.gameState = "gameplay"
        end
     end
  end
end

 

 

 

picking.png

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...