Jump to content

Entitykey and Camerapick doesn't work


ParaToxic
 Share

Recommended Posts

Hei I have a problem in my code.I'm programming a 3D menu and have some components like Buttons,Sliders...

Now I wan't to use Raycasting to get the button be selected from the mouse and soone.

I load my button with LoadMesh ( not a model!) and set the Key to "MENU" with a value "BUTTON"

 

In my Update function I have the following code:

 

CameraPick(&_raycast,IEngineSystem::Inst()->GetCamera(),Vec3(MouseX(),MouseY(),200));
if(_raycast.entity)
{
 if(GetEntityKey(_raycast.entity,"MENU") == "BUTTON" )
 {
  IMenuComponent* temp = (IMenuComponent*)GetEntityUserData(_raycast.entity);
  temp->_state = B_SELECTED;
  IConsole::inst()->Debug("HI");
 }
}

 

But I never get the BUTTON value of the key.I get allways a null-string.....

Can you help me with that ??

Thanks

Link to comment
Share on other sites

You can't compare C strings with == operator. You can do:

!strcmp("BUTTON",GetEntityKey(...))

or

"BUTTON"==string(GetEntityKey(...))

.

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 ■

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