| Blockland Forums > Modification Help |
| How can I clamp the vertical component of a vector between two values? |
| (1/1) |
| Rally:
I would've thought that: --- Code: --- %x = getWord(%eyeVector, 0) + (%spread * getRandom()); %y = getWord(%eyeVector, 1) + (%spread * getRandom()); %z = getWord(%eyeVector, 2) + (%spread * getRandom()); %z = mClampF(%z, -0.4, 0.6); %muzzleVector = vectorNormalize(%x SPC %y SPC %z); %velocity = vectorScale(%muzzleVector, 200); --- End code --- Would do the trick, but as soon as the vector is normalized, the vertical component just returns to whatever the eye vector is. Clamping it after you've normalized it does not work either, and clamping the z value to 120 in the actual velocity vector once it's been scaled by 200 does not work either. So obviously there's some kind of tricky vector math required here in order to get this sort of thing to work. Anyone know what that might be? |
| Swollow:
before delving into all these calculations I'd recommend just setting the minLookAngle and maxLookAngle on the armor datablock directly down is -$PI/2 directly up is $PI/2 you'll notice the default tank does this to prevent you from looking AND firing higher lower than 0.5 radians |
| Rally:
--- Quote from: Swollow on January 14, 2018, 05:42:38 AM ---before delving into all these calculations I'd recommend just setting the minLookAngle and maxLookAngle on the armor datablock directly down is -$PI/2 directly up is $PI/2 you'll notice the default tank does this to prevent you from looking AND firing higher than 0.5 radians --- End quote --- Thank you for this because I actually totally forgot this existed, but I've also noticed that with min and maxLookAngle, when you aim outside the bounds of these values, the camera will kinda "stick" to that position until you aim down or up enough to leave those bounds, resulting in a kind of delayed aiming response. Did I set something up wrong? |
| Swollow:
never experienced that try copying the default tank turret variables |
| Navigation |
| Message Index |