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.

Newcomers DBPro Corner / Attaching a 3D object to the mouse cursor location.

Author
Message
Scarlek
21
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 19th May 2004 14:54
I'm getting wierd effects in trying this.

Basically I'm trying to link an invisible cube to the screen location of my mouse cursor. If any one knows of a simple say of doing this, let me know. I've tried:

position object 2, mousex(), mousey(), 0 and various combinations of this but (even with the cube visible) it's not linking to the cursor.

any clues welcome. (I'd appreciate it if someone would even just tell me if position object is the right way to go. )

- Creating Games even I would play -
Scarlek
21
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 19th May 2004 14:56
k... I just re-thought this...

telling the object to position at mousex(), mousey() will of course move it in 3d space.... that's why it moves all over the place lol!

How would I attach it to the screen co-ordinates?

- Creating Games even I would play -
GameKit
21
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 19th May 2004 21:52
That would be difficult in DBClassic and would require ALOT of math... DBPro has various commands such as "Pick Object" that would make it reletivly simple.

What you would need to do would be to position the mouse at the object's screen position... Try something like...



Put this code near the end of your loop... I'm not sure if this will work or not, (I Just thought it up off the top of my head ). Adjust the movement speeds to change the distance away from the camera and the Mouse sensetivity...

Well... I hope I helped... Ummm... Again...

Previously known as "Game_Creator".
The question is, why am I talking to myself? ...... And more importantly, why am I waiting for a reply?
Scarlek
21
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 20th May 2004 13:38
Well, I had a little success last night but unfortunately it only worked if I set the z distance to about 500 from the camera. If it's going to require a lot of math then I'd better re-think my approach as I don't want something so simple to eat up processing time.

I'll try mouse/mesh selection instead maybe that's a little simpler. (My thinking behind attaching an object to the mouse was that I could 'shoot' a collision box from the mouse and anything it hits would return it's object number hence allowing me to select one of my three units in the game, then the box resets to the mouse again.)

- Creating Games even I would play -
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 20th May 2004 16:06
If you are using DBPro, see my snippet on how to use PICK SCREEN here:

http://www.thegamecreators.com/?m=forum_view&t=15701&b=7

Boo!
GameKit
21
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 20th May 2004 17:30
If all you are trying to do is select objects by clicking on the screen you could try...



...or something like that... This would make it so if the user clicks within 10 pixels of the center of one of the three objects then "selected" would equal that object number...

Well...I hope I helped... [I should just make this my signiture]

Previously known as "Game_Creator".
The question is, why am I talking to myself? ...... And more importantly, why am I waiting for a reply?
WhizzRich
21
Years of Service
User Offline
Joined: 30th Nov 2002
Location:
Posted: 20th May 2004 21:11
Check the CodeBase, there's several examples in there, I should know, I made one!

WhizzRich ---

Login to post a reply

Server time is: 2024-11-26 18:47:21
Your offset time is: 2024-11-26 18:47:21