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 / Crosshair hovering detection

Author
Message
Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Dec 2011 23:43
Hi,
I am using a sprite for a crosshair, but i need a way of detecting when that crosshair is hovering over an object. So i want to be able to walk up to an npc and when i look at him, i can talk to him... i was thinking of making an invisible plane, but i dont think i could get the positioning or the angles right...

any ideas?

matt
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2011 01:45
Maybe change the sprite? Or increase its size...

I am not sure I fully understood your question though...

Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 3rd Dec 2011 11:50
no i mean how can i detect if a sprite is on op of a 3d object?
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2011 15:15
I knew I misunderstood...

couldnt you just say that?

Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 3rd Dec 2011 15:47
lol soz i was tired
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2011 15:57
No worries buddy... that is a sign of dedication to your projects

Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 3rd Dec 2011 16:45
lol
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 4th Dec 2011 00:39 Edited at: 4th Dec 2011 00:41
One way of doing this is to use Sparky's collision to ray cast out from the camera in the direction the camera is pointing.

The position of the camera will be one end of the ray cast and then use a marker object to get the second point of the ray cast.

1) Position the marker object on the camera.
2) Orientate the marker object with the camera, so the marker object is pointing in the same direction as the camera.
3) Move the marker object forward by the required distance.
4) Get the position of the marker object.

Whatever the raycast insects with, the player can interact with.

[edit] I should have mentioned that this only works if the cross hair is in the middle of the screen.
Game Master1330
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 4th Dec 2011 01:44
Thanks I will try this tomorrow
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th Dec 2011 08:54
You can also have a look at the PICK OBJECT() function in the help files.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-11-23 23:36:27
Your offset time is: 2024-11-23 23:36:27