MexSource Posted April 30, 2014 Share Posted April 30, 2014 (edited) Hey, Is it possible to move a camera in a direction defined in a Vec3 (a rotation)? Because camera->Pick doesn't work for me i would like to try now world->Pick Tried it like this: if (wd->KeyHit(Key::E)){ Vec3 oldCamPos = cam->GetPosition(); cam->SetInput(cam->GetRotation().y, 5); if (wrd->Pick(oldCamPos, cam->GetPosition(), pickinfo)){ if (pickinfo.entity->GetKeyValue("tag") == "dbutton"){ //pickinfo.entity->SetKeyValue("tag", ""); System::Print("Entity picked, distance: " + String(pickinfo.distance)); //pickinfo.entity->SetPosition(pickinfo.entity->GetPosition().x, pickinfo.entity->GetPosition().y - 2, pickinfo.entity->GetPosition().z); } } cam->SetPosition(oldCamPos); } I think now of the problems with my code is that SetInput uses physics, so my camera object won't go through objects, right? Anyway i have no good idea at the moment, hope anybody can help Lua code is also accepted Btw this is exactly what i want: Ok here some more information: I try to create a game where you need to press a button, i wanted to do this with a raycast This is the pick code, it's from my MainPlayer.cpp "update" function that set up in my App::Loop function: Ignore this (old example) on the map load i set the tag "dbutton" for every object that has "dbutton" in it's name. Later when I did the raycast i would remove the tag so the button is "pressed" (outcommented for testing). It should then print the distance from camera to object. And then the button should be set invisible, so you can see it's pressed. And here are my problems: The line that should output the distance only says -1 everytime and it only works if you are so close to the object, that you are nearly touching it. Edited April 30, 2014 by MexSource Quote C++ :3 Link to comment Share on other sites More sharing options...
Recommended Posts
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.