Jump to content

[Solved] Location of a Pick


Shard
 Share

Recommended Posts

I'm trying to find the object that the camera is looking at and then set another object at that position.

 

I figured I'd do this by doing a pick to see what is being looked at and then set the object there.

 

Unfortunately, the code below didn't work because it places the object (the gun body) at the points along which the pick function is run, so the body moves back and forth in a line.

Pick pick;
if(EntityPick(&pick,*camera,1000)) gun.body.SetPosition(pick.GetPosition());

 

 

And changing it to

Pick pick;
if(EntityPick(&pick,*camera,1000)) gun.body.SetPosition(EntityPosition(pick.entity);

 

Didn't move the body at all.

 

Any thoughts?

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

You need to hide the gun before the pick and then show it again after it.

 

 

Thanks that worked.

However the results aren't quite what I want them to be.

 

Is there another way that I can set the gun to be a constant distance away from the camera (at the center of the screen)?

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Is there another way that I can set the gun to be a constant distance away from the camera (at the center of the screen)?

When the gun is positioned correctly, parent it to the camera.

desktop: Quad core Q6600 + 4GB + ATI HD4890 + XP

laptop: Dual core T6400 + 4 GB + NVidia 9600M GT + Vista 32

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