Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Years of Service
User Offline
Joined: 20th Feb 2012
Posted: 27th Feb 2012 03:00
i need to add a bullet for my game but i always run into a problem.i dont now how to move a object from the mouse position and straight forward from the camera's angle?
BN2 Productions
Years of Service
User Offline
Joined: 22nd Jan 2004
Posted: 27th Feb 2012 18:54
Can you be a little more specific about what you are looking for? It sounds like you are doing an FPS, but in that case would it just have the bullet go from the camera location?

How does the mouse position interact with where you want the bullet to go in your program?

Great Quote:
"Time...LINE??? Time isn't made out of is made out of circles. That is why clocks are round!" -Caboose
Years of Service
User Offline
Joined: 23rd Jul 2006
Posted: 27th Feb 2012 21:18 Edited at: 27th Feb 2012 21:38
There is (was) a DBE Maths library that had all sorts of useful 2d to 3d vector operations including picking 3d objects with the mouse, line of sight collision detection, polygon collision and plane picking detection, among other things. The only link I know of to it has a version in Russian. It can be translated using Google Translate if need be - I was able to translate the DarEdit (the dbc library itself) file using the Opera Browser and setting the encoding to Cyrillic, copying the resulting text into google translate...

Here's the link:


There has been a lot of discussion on the forums about this kind of thing. Search for posts like "pick object", "2d to 3d", "3d to 2d", "3d mouse" "mouse pick" .

The basic premise of projecting from the mouse is:

1. Finding a distance from the camera into 3d space where 1 screen pixel is equal to 1 3d unit. This distance is constant if the field of view and/or the camera window size doesn't change so usually only has to be calculated once.

2. Using that distance as a ratio to determine what 3d value the mouses 2d position is relative to

3. Offseting the mouse 3d calculation based on the camera rotation and the camera position.

4. Multiplying the adjusted mouse position by a desired forward projection distance.

Enjoy your day.
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 13th Mar 2012 19:48
Hi TallonB.
For a bullet system I suggest to not use an Object!
Creating a sphere/box or whatever , and moving it through your game, can result in the sphere skipping objects, thus not colliding!

I've been on the same line as you!
A few days ago I've found out there's a very good Collision check and Distance Checker in SPARKYS Collision DLL.
It's based on RayCasting.

If you're smart go raycasting with sparkys dll. It's hard to learn at first but the frustration level is much lower, and it works like a charm.

Login to post a reply

Server time is: 2020-08-15 12:37:52
Your offset time is: 2020-08-15 12:37:52