Blockland Forums > Modification Help
Help: Custom turret aiming
(1/3) > >>
Dannu:
Hey,

I'm looking to get back into Blockland modding by completing a long-term aspiration of mine. I want to use Port's DTS exporter to model and code an automatic ballistic turret. This would of course require some projectile math and standard 3D modelling that I could handle.

The problem arises with actually properly rigging a model and then controlling it. If at all possible, I would need as much pointers as possible.

Basic concept:


I can get as far as working out the angle A, but how would I accurately set up the movement on even a basic level on a turret and then actually set the angle A via script.

Any help is appreciated.
Conan:
are you also modeling and animating your own turret? if not then the only relevant thing is this function: AiPlayer.setAimLocation(%pos).

note this has to be on an aiplayer object, not a player object. fortunately spawned bots and turrets from vehicle bricks spawn as aiplayer type.
Rally:
Conan's suggestion to use AiPlayer.setAimLocation(%pos) is probably what you'd want to do because I'd imagine it's cleaner, but if you really wanted to use an angle, you could use %player.setLookLimits(%up, %down) to manually set the angle of the turret.

To convert the angle into a 0 - 1 value for the setLookLimits method, you'd divide by 180 and add 0.5. Then, an angle of 0 is 0.5, an angle of 90 is 1, and an angle of -90 is 0. Then you'd just have to animate the look sequence to match.

So, it'd be something like this:

--- Code: ---function AngleToLimiter(%a)
{
return (%a / 180) + 0.5;
}
function Player::setTurretAngle(%player, %a)
{
%player.setLookLimits(angleToLimiter(%a), angleToLimiter(%a));
}

--- End code ---
Dannu:
I will also be modelling and animating it on my own.

The latter is what I need the most help with. Probably due to my complete lack of experience in animating for Blockland. :P
Swollow:
you can specify the look limits in the player datablock with
minLookAngle = -$PI/2;
maxLookAngle = $PI/2;

this would allow the player type to look all the way up and all the way down
-PI/2 being straight down and PI/2 being straight up
for my turret player i use -0.2 and 0.2

this way you don't need to package and functions or anything for setting the look angle


http://files.swololol.com/bl/o/turretExample.blend

here is an example blend file of the animations you will have to make
please note any of the node/object names can be anything you want
EXCEPT for the node called eye, keep that as eye and just leave it where it is, it should be facing forwards towards where a player in control of this datablock will be looking
AND
mount0, this is where the player will be mounted to the turret

it shows two animations that are required for making a player, look and root

each of these animations will be exported to a seperate dsq file
you will want to export your turret model without any animations on it and the turret should be facing straight ahead for the animationless version

the look animation will be having the turret aim from directly up to directly down

in each dsq file open the blender text editor and add a file called Sequences
you will add one line of text respectivley for look and root animations

look: priority 8, blend
root: priority 0

at the end of all this you should have

turret.dts
t_look.dsq
t_root.dsq

(file names can be whatever you want but these are a good baseline)



now in your code you will have to create a TSShapeConstructor


--- Code: ---datablock TSShapeConstructor(turretNAMEDts)
{
baseShape  = "./turret.dts";
sequence0  = "./t_root.dsq root";

sequence1  = "./t_root.dsq run";
sequence2  = "./t_root.dsq walk";
sequence3  = "./t_root.dsq back";
sequence4  = "./t_root.dsq side";

sequence5  = "./t_root.dsq crouch";
sequence6  = "./t_root.dsq crouchRun";
sequence7  = "./t_root.dsq crouchBack";
sequence8  = "./t_root.dsq crouchSide";

sequence9  = "./t_look.dsq look";
sequence10 = "./t_root.dsq headside";
sequence11 = "./t_root.dsq headUp";

sequence12 = "./t_root.dsq jump";
sequence13 = "./t_root.dsq standjump";
sequence14 = "./t_root.dsq fall";
sequence15 = "./t_root.dsq land";

sequence16 = "./t_root.dsq armAttack";
sequence17 = "./t_root.dsq armReadyLeft";
sequence18 = "./t_root.dsq armReadyRight";
sequence19 = "./t_root.dsq armReadyBoth";
sequence20 = "./t_root.dsq spearready"; 
sequence21 = "./t_root.dsq spearThrow";

sequence22 = "./t_root.dsq talk"; 

sequence23 = "./t_root.dsq death1";

sequence24 = "./t_root.dsq shiftUp";
sequence25 = "./t_root.dsq shiftDown";
sequence26 = "./t_root.dsq shiftAway";
sequence27 = "./t_root.dsq shiftTo";
sequence28 = "./t_root.dsq shiftLeft";
sequence29 = "./t_root.dsq shiftRight";
sequence30 = "./t_root.dsq rotCW";
sequence31 = "./t_root.dsq rotCCW";

sequence32 = "./t_root.dsq undo";
sequence33 = "./t_pop.dsq plant";

sequence34 = "./t_root.dsq sit";

sequence35 = "./t_root.dsq wrench";
};
--- End code ---
   

essentially you will be setting every single default blockland animation to root except for the look animation, however you can of course add more animations to this either to an existing blockland animation by specifying a different dsq file or adding another line like
sequences36 = "./t_fire.dsq fire";
which would add a new animation under the name fire



if you have any further questions ask here,
also a really good reference is the default tank turret, you can import the dts model and look at the dsq animations and the playertype datablock in the tank turret file
Navigation
Message Index
Next page

Go to full version