Q: How to move object (player) with mouse, like a cursor?
by Feral · in Torque Game Engine · 03/09/2005 (2:49 am) · 5 replies
Q: How to move object (player) with mouse, like a cursor?
Hello, thank you for reading.
This is for a Top-Down style '2d ish' little action game. The player controls a reticule and tries to save the space station in the middle of the screen from all the space junk being attracted to it. In essence this is a remake of 'Space Zap' (early coin-op)of old, with a few twists of course.
I am trying to make my player object function as a cursor/reticule and as such am trying (and being perplexed) to move it (Xaxis and Yaxis only) via mouse movement.
I have found various mostly helpful threads on the subject but am still at a loss.
Jared Schnelle's post in http://www.garagegames.com/mg/forums/result.thread.php?qt=10796 makes it almost work but the mouse input is not getting to my FlyingVehicle::updateMove() with regularity, so I am tending to wonder if I am on the right track at all.
Really all I want the player object to do is move about and select what the space station should blast, so I am using a flying vehicle for now if that is of relevance.
Any relevant advice/comments welcome, thank you (=
Hello, thank you for reading.
This is for a Top-Down style '2d ish' little action game. The player controls a reticule and tries to save the space station in the middle of the screen from all the space junk being attracted to it. In essence this is a remake of 'Space Zap' (early coin-op)of old, with a few twists of course.
I am trying to make my player object function as a cursor/reticule and as such am trying (and being perplexed) to move it (Xaxis and Yaxis only) via mouse movement.
I have found various mostly helpful threads on the subject but am still at a loss.
Jared Schnelle's post in http://www.garagegames.com/mg/forums/result.thread.php?qt=10796 makes it almost work but the mouse input is not getting to my FlyingVehicle::updateMove() with regularity, so I am tending to wonder if I am on the right track at all.
Really all I want the player object to do is move about and select what the space station should blast, so I am using a flying vehicle for now if that is of relevance.
Any relevant advice/comments welcome, thank you (=
#2
Click n Pick
Mouse Controlled Player Movement
03/10/2005 (8:30 am)
Search the resources as well as the forums. I often forget to use the dropdown box and think "where the hell did all those resources go!" then I realize I was searching "games" or something.Click n Pick
Mouse Controlled Player Movement
#3
animate a dts hand and have it hover over the terrain controlled by the mouse... hmmm
03/10/2005 (5:25 pm)
This kinda reminds me of the hand in black and white... that seems like it would be hella easy to make..animate a dts hand and have it hover over the terrain controlled by the mouse... hmmm
#4
@Ed
One would think that (=
@David
Very good point about searching forums and resources and thank you for the two links.
@Juan
We can hope!
03/11/2005 (4:47 am)
*crosses fingers* Hopefully tomorrow something will make sense (=@Ed
One would think that (=
@David
Very good point about searching forums and resources and thank you for the two links.
@Juan
We can hope!
#5
In fact, it seems 99% is already in the engine.
Start out with FlyingVehicle.
File: ...\TORQUE-SDK\engine\game\vehicles\flyingVehicle.cc
If you do not want the mouse to adjust pitch/yaw of the flying vechicle, rem/remove:
In "void FlyingVehicle::updateForces(F32 /* dt */ )"
That would seem to be the proper place/way to remove yaw/pitch manipulation by mouse.
In "void FlyingVehicle::updateMove(const Move* move)"
Replace:
That will allow for both mouse and keyboard movement of the 'flyingvehicle'.
Move->x/y are the x/y keyboard movement, while move->pitch/yaw is the mouse movement.
Presuming I've not left out something I think this is all that needs to be done. I, however, really don't know what I am doing yet! (=
03/11/2005 (7:38 pm)
Presuming I've done what I think I have done it is in fact quite easy to move the player object via mouse movement.In fact, it seems 99% is already in the engine.
Start out with FlyingVehicle.
File: ...\TORQUE-SDK\engine\game\vehicles\flyingVehicle.cc
If you do not want the mouse to adjust pitch/yaw of the flying vechicle, rem/remove:
In "void FlyingVehicle::updateForces(F32 /* dt */ )"
// Steering Point2F steering; steering.x = mSteering.x / mDataBlock->maxSteeringAngle; steering.x *= mFabs(steering.x); steering.y = mSteering.y / mDataBlock->maxSteeringAngle; steering.y *= mFabs(steering.y); torque -= xv * steering.y * mDataBlock->steeringForce; torque -= zv * steering.x * mDataBlock->steeringForce; // Roll torque += yv * steering.x * mDataBlock->steeringRollForce; F32 ar = mDataBlock->autoAngularForce * mDot(xv,Point3F(0,0,1)); ar -= mDataBlock->rollForce * mDot(xv, mRigid.linVelocity); torque += yv * ar;
That would seem to be the proper place/way to remove yaw/pitch manipulation by mouse.
In "void FlyingVehicle::updateMove(const Move* move)"
Replace:
mThrust.x = move->x; mThrust.y = move->y;With:
// NOTE 1,-1 values should probably come from a datablock. mThrust.x = mClampF( (move->x + move->pitch),-1, 1); mThrust.y = mClampF( (move->y + move->yaw),-1, 1);
That will allow for both mouse and keyboard movement of the 'flyingvehicle'.
Move->x/y are the x/y keyboard movement, while move->pitch/yaw is the mouse movement.
Presuming I've not left out something I think this is all that needs to be done. I, however, really don't know what I am doing yet! (=
Torque Owner Corin
Call for help !!