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.

AppGameKit Classic Chat / getting 3d gun of a tank towards pointerPressed

Author
Message
haliop
User Banned
Posted: 20th Jul 2014 13:44
so i have a tank
it is built using 2 objects
one for the main body and the other for the head and turret

the game is in 3d environment so im looking for a way
so when i touch the screen the head of the tank will point toward that location , can someone help out ?


thank you for your time
Nadav.

george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 20th Jul 2014 22:41 Edited at: 20th Jul 2014 22:41
You will need to translate a 2D point to 3D point. If you know the depth from the gun of the tank (with the direction from you toward to screen) then the rest is very simple...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2014 12:23 Edited at: 21st Jul 2014 12:25
Or you can use the 3D collision commands. Create a plane at the level of your tanks, do a raycast from the camera position + the screenTo3D vector commands and get a real 3D point from the raycast to point at. Simple.

Here's a function you could easily edit:


Used like this:
haliop
User Banned
Posted: 22nd Jul 2014 14:24

Login to post a reply

Server time is: 2024-04-19 10:39:09
Your offset time is: 2024-04-19 10:39:09