Game Development Community

Weapon scoping vector problem

by Toks · in Torque Game Engine · 12/14/2007 (11:49 am) · 2 replies

Hello everyone,

I've made some changes to my engine to add the ability to look over the iron sights like in most modern fps game (Call of Duty for example). I did this by adding a scopeStartNode and a scopeEndNode to my weapon model. and whenever im "scoping" i use the scopeStartNode as an eyeNode. (that wont work with multiple images mounted, no). then the scopeEndNode is placed on the point you use for aiming.

To get the aiming part right, i drew a vector through both nodes and used that as the muzzleVector:

void ShapeBase::getMuzzleVector(U32 imageSlot,VectorF* vec):

if(isScoped())
{
	// find a vector through both ends of the scope
	MatrixF zmat, mmat;
	MountedImage& image = mMountedImageList[imageSlot];
	getImageTransform(0,image.dataBlock->scopeStartNode,&zmat);
	getImageTransform(0,image.dataBlock->scopeEndNode,&mmat);

	// store and normalize.
	vec[0] = mmat.getPosition() - zmat.getPosition();
	vec->normalize();
}
else
{
	// the normal GG stuff here when not scoping

it works pretty good, and looks really cool (despite my poor weapon modeling).

the catch is that the vector seems to be calculated pretty much as if the weapon is pointing straight ahead, even when it isnt. (walking or breathing animations) what is causing this? could it be the animations are not played server-side?

#1
12/14/2007 (6:47 pm)
I'd recommend modifying and using the getCorrectedAimVector() method.
#2
12/16/2007 (5:43 am)
Yeah, well exactly what good will that do if it is in fact the animation problem? obviously the getMuzzleVector is called server side and if it is not animated synch with the client there is no obvious way to "correct" it since you dont know what to correct it to, right?