Jump to content

Move camera with rotation


MexSource
 Share

Recommended Posts

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

 

Lua code is also accepted tongue.png

 

 

 

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 by MexSource

C++ :3

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