Game Development Community

Camera / Aiming

by Ash "Slayeh" Berlin · in Torque Game Engine · 01/13/2004 (6:37 am) · 8 replies

We are creating a Light Gun game in Torque, similar to 'House of the Dead' and 'Time Crisis'. Basically this means the player's movement will be 'on rails' dictated by a path, while still being able to shoot. The shooting will be done with a mouse cursor which can be moved around the screen without changing the viewing angle.

We've been trying for some time to implement the aiming using information from tutorials such as the Click n Pick, Mouse controlled player movement (RPG Cam) and Turret & AITurret classes.

We think that we need to replace some of the firing code so that the projectile follows a vector from a casted ray (at the point on the screen where the mouse is clicked), rather from the centre of the screen (because the viewpoint won't be controlled by the mouse). Can this be done, either in engine or scripting, and how would we go about this?

For pathing the player, we have managed to use the AIPlayer class so that the player will follow a path. However, as far as we can tell, the player will only follow the path when you do not have control. For example, if you move to Fly mode (Alt-c), the player will follow the path, but when you take control again, he stops. Is it possible to take away the control of the player with the keyboard, but still be able to fire, and still look through the player's eyes? Are we going about it the correct way using the AIPlayer, or can a normal Player still follow a path?

This is how i've used AIPlayer at the moment:

%player = new AIPlayer() {
      dataBlock = PlayerBody;
      //dataBlock = DemoPlayer;
      client = %this;
   };

Many thanks, any help will be greatly appreciated.

#1
01/13/2004 (12:35 pm)
For anyone else trying to implement a gui with cursorOn.
You have to delete new GuiShapeNameHud from PlayGui.gui because it stops gameTSCtrl from catching the click. onMouseDown etc can then be implemented. Stupid thing wasted 1 month of my time :<

On problem I have found with this approach is that it is a bit slow. I don't seem to be able to click quickly in this mode and it isn't that responsive.

From GameTSCtrl.cc
void GameTSCtrl::onMouseDown(const GuiEvent &event)
{
   Con::executef(this, 1, "onMouseDown");
}

From playGui.cs
function PlayGui::onMouseDown(%this)
{
  mouseFire();
}

Has anyone got any ideas for improving this?
Thanks in advance.
#2
08/29/2004 (12:17 pm)
Hey Ash

Ever got this working? I'll very soon need to code something similar, and any hints and help is greatly appreciated!
#3
12/12/2005 (10:53 am)
Any more word on this?
#4
12/12/2005 (10:54 am)
Any more word on this?
#5
04/06/2006 (1:17 am)
This is almost exactly the same problem I'm facing, so if anyone have any input on how to solve it, it would be super.

Been fideling around with the exact same resources as Ash did, and I bump into the same problems. My problem is to calculate the vector from the weapon muzzlepoint to the point where my mouse cursor is pointing at. A 2D to 3D convertion of the coordinates is needed (from screenspace to worldspace).

I tried a few of the resources, and one came close ( http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335 ) but the problem here is that it seems to not be working on steep hills, or on some areas of the screen (might depend on the LOS from the character to the point or something, I'm not sure).

What I'm tryng to do, is to have a weapon mounte don a vehicle with a fixed 3rd person viewport, and have the vehicle controlled with the keys (this was no problem), then have the mounted weapon to aim at the mouse location (here I'm stuck).

(edit: typos, typos, typos.. :P)
#6
07/28/2006 (4:35 am)
I'm not sure i fully understand what you're attempting here, but these 2 methods might help you:

function PlayGui::onMouseDown(%this){

// mouseVec = vector from camera point to 3d mouse coords (normalized)
%mouseVec = %this.getMouse3DVec();

// cameraPoint = the world position of the camera
%cameraPoint = %this.getMouse3DPos();

}
#7
10/06/2006 (5:53 am)
Pardon me but could you tell me how you got Torque to do cell shading, is there a tutorial anywhere or places you found similar code. I want to create a cell shading effect but I don't know where to start