Game Development Community

Select objects in game by clicking on the screen

by Keith Killilea · in Torque Game Engine · 09/07/2004 (5:48 am) · 2 replies

I'm working at the moment from the starter.fps but I'm looking for a way to have the cursor move freely around the screen in game, and that when you click on the screen, the ID of the objects in the direction where you click is returned to you, whether by having a new function entirely, or by getting the vector of the direction the cursor is in and hence doing a RayCast. I know something like this exists since it's in the level editor, but I couldn't figure out how it was implemented by looking at the script files.
Any help would be greatly appreciated.

About the author

Torque Games -: Camelot Galway, Spike Dash, 14 Tribes, Illumina, & Terra: Formations. -: CEO of Riverplay Games. -: CEO of Wiccle Limited - Open Source / Open Core CMS Developer & Publisher.


#1
09/07/2004 (5:54 am)
Your right, that sort of functionality is available in the world editor.

Its not possible I dont think to do this entirely in script.

I took the world editor gui control, stripped out multi-object selection, added some callback script calls so that script handles what happens when you click. Took about 2 hours tops.

I'd suggest doing that.
#2
09/08/2004 (7:07 am)
It's okay, I got it working, I just modified the first part of the object selection resource: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2173 (didn't need any of the complex stuff, just something that would return a vector) and mixed that in with my existing interact function which was derived from that switch tutorial in the docs.
Also, apparently there's a simpler more basic resource that uses patches to modify your code, it's located here: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4146

Well anyway, thanks for your help, glad I got it working in the end.