Game Development Community

Mouseclick Movement

by Hugo Queiriga · in Torque Game Builder · 07/18/2006 (10:39 pm) · 2 replies

Hi, i've just inplemented mouse movement on my ship, but i would like to make the ship move on the mouse click i.e. comand and conquer type

I was wondering if i did this it would do it, however the ship goes at first but then just jets off with a massive impulse.
This is the code used.

function sceneWindow2D::onMouseDown(%this, %mod, %worldPosition, %mouseClicks)
%this.mouseMoveShip(%mod, %worldPosition);

Does anyone, got tips how to fix this and make it better? I also was wondering, if i clicked in the game map, the i would like for the sprite of my ship to rotate in the direction of the click so it looked like it was turning! if anyone could help me with that it would be appreciated.

Thanks in advance,

Hugo

#1
07/19/2006 (3:37 am)
I would suggest that you check out this section of TDN. Specifically the object mouse event tutorial and any of the boat, tank, or car tutorials. The first one deals with mouse events and the others deal with basic 2D physics; all of the last three mentioned deal with "stearing" an object toward a target.
#2
07/19/2006 (8:11 am)
Thanks Thomas, i'll have a look at it i think the turret is exactly what i was looking for, very usefull resources!