How to change the direction of shells ejected from "rifle"?
by Jarrod Roberson · in Torque Game Engine · 06/23/2002 (7:02 pm) · 12 replies
Pretty simple, where is the code that defines the direction that the "shells" are ejected from the rifle?
I have not been able to find where the direction, speed, etc. Is, I can effect the shells, spin, bounce, etc. themselves but not what ever is producing them.
They always drop out to the right, where would I look to change this?
I have not been able to find where the direction, speed, etc. Is, I can effect the shells, spin, bounce, etc. themselves but not what ever is producing them.
They always drop out to the right, where would I look to change this?
About the author
#2
This will get the property projectileSpread from the weapon image's datablock and then alter the muzzlevector accordingly.
Hope that helps
06/24/2002 (12:39 am)
Here is a sample script for you to use that will do what you want.This will get the property projectileSpread from the weapon image's datablock and then alter the muzzlevector accordingly.
function ShapeBaseImageData::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;
%spread = %this.projectileSpread;
%spread = %spread $= "" ? 0.001 : %spread;
%finalspread = %spread <= 0 ? 0.001 : %spread;
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 2 * 3.1415926 * %finalspread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %finalspread;
%z = (getRandom() - 0.5) * 2 * 3.1415926 * %finalspread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
};
MissionCleanup.add(%p);
return %p;
}Hope that helps
#3
06/24/2002 (1:05 am)
Pssst... Wizard......the shells eject direction, not the bullet ;p
#4
(/me burys head in sand)
I think I misread the question :/
Sorry, dont know the answer to that one :(
06/24/2002 (1:54 pm)
oops :P(/me burys head in sand)
I think I misread the question :/
Sorry, dont know the answer to that one :(
#5
06/24/2002 (2:03 pm)
It's nice to see you're human after all Daniel! :)
#7
this line shellExitDir.set( 1.0, 0.0, 1.0 );
This value is also set in the editor for the object
addField("shellExitDir", TypePoint3F, Offset(shellExitDir, ShapeBaseImageData));
later on in the function ejectShellCasing(...)
it gets assigned to:
Point3F ejectDir = imageData->shellExitDir;
so for a quick change you can modify
the shellExitDir.set( 1.0, 0.0, 1.0 );
to something else.
You can also change it in(for example fps)
sever rifle.cs in the section that starts with
datablock ShapeBaseImageData(RifleImage)
{ ... }
In there you can add the shellExitDir field and the values you want. :)
06/25/2002 (3:02 pm)
k, in game\shapeImage.cc around line 166 there isthis line shellExitDir.set( 1.0, 0.0, 1.0 );
This value is also set in the editor for the object
addField("shellExitDir", TypePoint3F, Offset(shellExitDir, ShapeBaseImageData));
later on in the function ejectShellCasing(...)
it gets assigned to:
Point3F ejectDir = imageData->shellExitDir;
so for a quick change you can modify
the shellExitDir.set( 1.0, 0.0, 1.0 );
to something else.
You can also change it in(for example fps)
sever rifle.cs in the section that starts with
datablock ShapeBaseImageData(RifleImage)
{ ... }
In there you can add the shellExitDir field and the values you want. :)
#8
Now ensues a patented Over-analyzed by Zear(TM) session:
In my limited experience, I understood that the shell is usually the part that flies toward the enemy. The casing is the part that drops out the side, rolls under your feet, and causes you to fall - spraying shells every which way and causing your teammates to desperately run for cover from your inadvertent friendly fire... at least that's the way I learned it.
... not that anyone lets me near a gun anymore. You should see me shooting a shotgun. Even the rocks run for cover...
Turns out I was somewhat misinformed. A shell is the (likely explosive) projectile when it is shot from a large weapon (like the gun on a battleship), but is the tube that holds the bullet (and powder, etc) in small arms...
shell - a : a projectile for cannon containing an explosive bursting charge b : a metal or paper case which holds the charge of powder and shot or bullet used with breech-loading small arms
casing (or case) - a tube into which the components of a round of ammunition are loaded
bullet - a round or elongated missile (as of lead) to be fired from a firearm; broadly : CARTRIDGE 1a
Definitions courtesy of Merriam Webster Collegiate Dictionary.
So there is a bit of wiggle room to claim you were right all along Wiz - just depends on the weapon. We were talking about a fully automatic mortar rifle, right? ;)
06/25/2002 (3:59 pm)
Don't feel bad Wiz... I read it wrong at first as well.Now ensues a patented Over-analyzed by Zear(TM) session:
In my limited experience, I understood that the shell is usually the part that flies toward the enemy. The casing is the part that drops out the side, rolls under your feet, and causes you to fall - spraying shells every which way and causing your teammates to desperately run for cover from your inadvertent friendly fire... at least that's the way I learned it.
... not that anyone lets me near a gun anymore. You should see me shooting a shotgun. Even the rocks run for cover...
Turns out I was somewhat misinformed. A shell is the (likely explosive) projectile when it is shot from a large weapon (like the gun on a battleship), but is the tube that holds the bullet (and powder, etc) in small arms...
shell - a : a projectile for cannon containing an explosive bursting charge b : a metal or paper case which holds the charge of powder and shot or bullet used with breech-loading small arms
casing (or case) - a tube into which the components of a round of ammunition are loaded
bullet - a round or elongated missile (as of lead) to be fired from a firearm; broadly : CARTRIDGE 1a
Definitions courtesy of Merriam Webster Collegiate Dictionary.
So there is a bit of wiggle room to claim you were right all along Wiz - just depends on the weapon. We were talking about a fully automatic mortar rifle, right? ;)
#9
he is referring to the spent shell casing after a bullet is fired, that part that falls to the ground and rolls down the hill. My previous post tells you how to modifiy it.
as for shell, casing, etc its all about context :P
06/26/2002 (7:23 am)
Since he mentions the "shell" keep dropping to the righthe is referring to the spent shell casing after a bullet is fired, that part that falls to the ground and rolls down the hill. My previous post tells you how to modifiy it.
as for shell, casing, etc its all about context :P
#10
yeah, shell casing, or "shell" in context, I was tired, sue me :) Working 3 projects for a total of 120+ hours the last two weeks is crazy. One ends tommorrow and another goes into a lull tommorrow, so I might just have time to TGE some in July.
Thanks for all the help, attempts at help and everything else everyone.
For fun.
I did some checking around, in most military and weapons circles the semantics are pretty cut and dry.
shell is used when refering to artillery.
bullet is used when refereing to firearms.
casing is used for anything that holds a shell/bullet/power
round is an aggregate of bullet/power/casing.
gun is used to refer to artillery.
firearm is used to refer to non-artillery.
Man those artillery people get really uptight when people refer to firearms as "guns", just like how the don't like it when people refer to an aircraft carrier as a "boat".
06/27/2002 (6:41 pm)
Thanks I will try some of the code above, when I get back to TGE programming.yeah, shell casing, or "shell" in context, I was tired, sue me :) Working 3 projects for a total of 120+ hours the last two weeks is crazy. One ends tommorrow and another goes into a lull tommorrow, so I might just have time to TGE some in July.
Thanks for all the help, attempts at help and everything else everyone.
For fun.
I did some checking around, in most military and weapons circles the semantics are pretty cut and dry.
shell is used when refering to artillery.
bullet is used when refereing to firearms.
casing is used for anything that holds a shell/bullet/power
round is an aggregate of bullet/power/casing.
gun is used to refer to artillery.
firearm is used to refer to non-artillery.
Man those artillery people get really uptight when people refer to firearms as "guns", just like how the don't like it when people refer to an aircraft carrier as a "boat".
#12
;-)
10/29/2007 (11:12 am)
So a machinegun is a rapid firing cannon? and a sub-machinegun is a rapid firing cannon specially designed to do maximum damage on submarines?;-)
Associate James Lupiani
Sickhead Games