Game Development Community

How could I do this?

by David Boyd · in Torque Game Engine · 06/14/2002 (3:12 pm) · 1 replies

I have an object (player) that I want to be able to shoot in 360 degrees (not up or down, say a flat 2d plane).

Basically I want to be able to shoot at a particular direction depending on a angle input by the user.

Diagram below may help :)


communities.msn.com/_Secure/0KQAAACwOzSEo8AAyIK6RPSh33EmyCD2IvpNcgYGefTePlsTa7jL2fVKvbfU5UVU*t96enelGmys/circle.gif

#1
06/15/2002 (8:20 am)
Depends on how you want your game set up and what kind of input you want. I would guess you are maybe wanting an overhead view, and plan on using the mouse cursor to aim. I am not experienced enough with torque to tell you the coding details, but I can tell you the general technique used to do this. I've done it many times on a few different engines. You basically take your player's position and convert it to screen coordinates, and I believe there is a function in torque that does just that, so it shouldn't be so hard. Then all you have to do is get the angle between your mouse cursor and the projected player point, and rotate the player model to that angle.


Sorry I can't help you with the coding specifics, due to a full time job I've only put about 6 hours into learning torque. Maybe a guru will come in here and give you a hand.