Laser shooting - Converting screen coordinates to shooting direction
by Kien T Nguyen · in Torque 3D Beginner · 02/10/2014 (6:09 pm) · 3 replies
Hello erveryone,
I am doing a laser shooting app. I hoped it would be the same as normal shooting with a mouse button.
But I have had a problem in converting screen coordinates to the shooting direction.
I have traced codes of mouse shooting but I could not find out how to get camera transform externally to unproject the screen point to world (referred to the function GameTSCtrl::onMouseMove, GameTSCtrl::onMouseDown).
Thanks in advance,
I am doing a laser shooting app. I hoped it would be the same as normal shooting with a mouse button.
But I have had a problem in converting screen coordinates to the shooting direction.
I have traced codes of mouse shooting but I could not find out how to get camera transform externally to unproject the screen point to world (referred to the function GameTSCtrl::onMouseMove, GameTSCtrl::onMouseDown).
Thanks in advance,
About the author
#2
I have tried to followed the tutorial but found no way to use script for my purpose.
Given a screen coordinate (x, y). How can I write a global function, laser_shooting(x, y), with the purpose of onMouseDown() used in shooting?
02/12/2014 (7:50 pm)
Thank you for your reply. In fact, I wanted to implement by C++ code.I have tried to followed the tutorial but found no way to use script for my purpose.
Given a screen coordinate (x, y). How can I write a global function, laser_shooting(x, y), with the purpose of onMouseDown() used in shooting?
#3
02/12/2014 (8:49 pm)
Oh, I'm not sure how to do this in C++! In my opinion it's best done in script because you can use the PlayGui::onMouseDown callback which makes it nice and easy.
Torque Owner Daniel Buckmaster
T3D Steering Committee