Shooting straight in 3d person not with mouse agnle
by Tom Timothy · in Torque Game Engine Advanced · 07/17/2010 (4:17 am) · 3 replies
I need players to shoot straight not with pitch of the mouse. Im using a overhead camera, this game is multi-player so advanced camera is not a option. Ive been using the search option for few hours but Im finding blanks and people asking over and over how to get into third person. If anyone knows of a post get guns stop using mouse pitch please point me in the right area. Thanks for your time.
#2
07/17/2010 (5:57 am)
Hum I tried both code changes both stop my weapon from fireing in stock tgea1.8.2. I get sound and particle effect of cartrige but the projectile never comes out. Any other changes you might have done twisted oh by the way love the AI kit I got from you best thing I have gotten for TGE or tgea ever
#3
07/17/2010 (6:02 am)
never mind must been tired i commented out part of projectile object some how works great
Torque 3D Owner Twisted Jenius
function CrossbowImage::onFire(%this, %obj, %slot) { %projectile = %this.projectile; // Decrement inventory ammo. The image's ammo state is update // automatically by the ammo inventory hooks. %obj.decInventory(%this.ammo,1); // Determine initial projectile velocity based on the // gun's muzzle point and the object's current velocity %muzzleVector = %obj.getMuzzleVector(%slot); %objectVelocity = %obj.getVelocity(); %muzzleVelocity = VectorAdd( VectorScale(%muzzleVector, %projectile.muzzleVelocity), VectorScale(%objectVelocity, %projectile.velInheritFactor)); // Create the projectile object %p = new (%this.projectileType)() { dataBlock = %projectile; initialVelocity = %muzzleVelocity; initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; sourceSlot = %slot; client = %obj.client; }; MissionCleanup.add(%p); return %p; }After:
Add:
The above should make your weapon always shoot level with the ground. That's good for an overhead view, but for a 3rd person view you might want something more like:
if (getWord(%muzzleVector, 2) <= 0.2 && getWord(%muzzleVector, 2) >= -0.2) %muzzleVector = setWord(%muzzleVector, 2, (0));Which is the code I'm using to help constrain the player's aim a bit, unless they are deliberately aiming extremely high or low; in which case it will aim as normal.