I'm working on this tank rig for school and we have to, by way of expression limit the movement in logical ways. For instance when it moves sideways there should not be any movement. Which I'm kind of stumbling on at the moment there is just a simple Y angle analysis of the tank controller and that controls which way the tracks move.
I was wondering if it would be possible to do a vector analysis if the movement is 90d to the way the tank is facing then it would not move for instance. And it might be possible then to adapt that vector analysis to other situations to replace the rudimentary y angle check.
float $LbigWheelDia = 2.707961;
float $LbackWheelDia = 2.010008;
float $LfrontWheelDia = 1.545769;
float $trackLength = 18.3076935232;
global float $oldX = 0.0;
global float $oldY = 0.0;
global float $oldZ = 0.0;
float $changeX = tankRoot.translateX - $oldX;
float $changeY = tankRoot.translateY - $oldY;
float $changeZ = tankRoot.translateZ - $oldZ;
float $distance = sqrt( $changeX * $changeX + $changeY * $changeY + $changeZ * $changeZ);
float $angle = tankRoot.rotateY % 360;
int $switch = 1;
int $switch2 = 1;
if ($changeZ < 0)
$switch = $switch * -1;
if (($angle == 90 || $angle == -270) && $changeX < 0)
$switch = $switch * -1;
if ( ($angle == -90 || $angle == 270) && $changeX > 0)
$switch = $switch * -1;
if ($angle > 90 && $angle < 270)
$switch = $switch * -1;
if ($angle < -90 && $angle > -270)
$switch = $switch * -1;
if ($changeX == 0 && $changeZ == 0)
$switch2 = 0;
else
$switch2 = 1;
L_GearWheel.rotateX = L_BigWheel.rotateX * -2 % 360;
L_FrontWheel.rotateX = L_BigWheel.rotateX * ($LbigWheelDia / $LfrontWheelDia) % 360;
L_BackWheel.rotateX = L_BigWheel.rotateX * ($LbigWheelDia / $LbackWheelDia) % 360;
tankRoot.LtrackMovement = L_BigWheel.rotateX * ((3.1415 * $LbigWheelDia) / $trackLength) / 360 * 21 ;
L_BigWheel.rotateX = L_BigWheel.rotateX + ($distance / (3.1415 * $LbigWheelDia) * 360 * $switch * $switch2)% 360;
$oldX = tankRoot.translateX;
$oldY = tankRoot.translateY;
$oldZ = tankRoot.translateZ;
Replies
https://www.youtube.com/watch?v=QpDc93br3dM