How do weapon recoil in T3d1.2?
by Szzg007 · in Torque 3D Professional · 12/12/2011 (7:52 pm) · 9 replies
I has mage this coed to T3d1.2... Can't work.....SO How do?
// ----------------------------------------------------------------------------
// Do some weapon recoil -- should really be implemented in C++ ...something
// ----------------------------------------------------------------------------
function clientCmdDoRecoil(%type)
{
switch$ (%type)
{
case "Extreme":
%Pitch = getrandom(-1, -2)/10;
%Yaw = getrandom(-4, 4)/100;
ToggleRecoil( %Pitch, %Yaw );
schedule(250, 0, "ToggleRecoil", -%Pitch, -%Yaw);
}
}
function ToggleRecoil(%Pitch, %Yaw)
{
$mvPitch += %Pitch;
$mvYaw += %Yaw;
}
function testR()
{
$Pitch += 0.01;
ToggleRecoil( 0.01, 0 );
Techo($Pitch);
if($Pitch!=0)
schedule(10, 0, "testR");
}About the author
http://www.szzg007.com http://www.951gl.com/kits/index_store.html
#3
12/13/2011 (9:13 am)
Hehe, I see that trick is still floating around :)
#4
12/13/2011 (11:17 pm)
Cool stuff...if you only use the first person camera. ;)
#5
12/13/2011 (11:30 pm)
Actually it looks even better from an over-the-shoulder view, doesnt look bad from third-person either.
#6
12/15/2011 (11:27 pm)
Maybe I implemented it incorrectly. I'm seeing camera shake instead of weapon recoil when I do third-person view.
#7
12/15/2011 (11:36 pm)
@Joe: that's why I said "that trick". All it does is randomly twitch the pitch and yaw of the player's (client) camera, it's not an actual recoil feedback system that moves the weapon image or player's arm.
#8
12/16/2011 (3:12 am)
Truthfully this works best in conjuction with the weapon cameraShake feature, since cameraShake is not neworked it doesnt looks as appealing yet still produces a good effect if used correctly.
#9
12/16/2011 (11:05 pm)
Thanks for the clarification Michael. =)
Torque Owner CSMP
MP Studios
// Do some recoil if this weapon has the required field: recoilType if(%obj.getClassName() $= "Player") { if (%this.recoilType !$= "") CommandToClient(%obj.client, 'DoRecoil', %this.recoilType); }Then add this into your "Weapon"Image Datablock