Blockland Welcome, Guest. Please login or register.
Did you miss your activation email?
June 20, 2018, 08:01:38 PM

Home Help Login Register
+  Blockland Forum
|-+  Blockland Forums
| |-+  Modification Help
| | |-+  Help: Custom turret aiming
Pages: [1]
Author Topic: Help: Custom turret aiming  (Read 558 times)
Dannu

« January 11, 2018, 10:43:56 AM »

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.
Logged
Ad Bot

Full members do not see ads

Conan

« January 11, 2018, 10:50:15 AM »

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.
Logged
Rally

« January 11, 2018, 11:00:45 AM »

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));
}
« Last Edit: January 11, 2018, 11:02:44 AM by Rally » Logged
Dannu

« January 11, 2018, 11:07:32 AM »

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
Logged
Swollow

« January 11, 2018, 03:40:13 PM »

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";
};
   

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
Logged
Dannu

« January 14, 2018, 06:03:16 AM »

I don't understand what you mean by each of the animations being exported as a separate dsq file. It might be just Port's exporter, but all of the animations are exported as a single file.

In addition to this, the extremely basic FAQ says that for setting priority of the animations, you are supposed to create a text block called Sequences.

It might be that Port's exporter has some unique quirks.


Edit:
Taking inspiration from something called TurbolaserTower that I had in my add-ons folder, I managed to get something into Blockland. I simply created sequences to which I added
Code:
look: priority 8, blend
root: priority 0

After that, I exported DTS (turret.dts) and DSQ (turret.dsq) as one file and coded it as follows:
Code:
datablock TSShapeConstructor(TurretArtilleryDts)
{
        baseShape  = "./turret.dts";
        sequence0  = "./turret.dsq look";
        sequence1  = "./turret.dsq root";
};   

But now I have a problem.





My aim is pointing the wrong way. How can one go about fixing this?

« Last Edit: January 14, 2018, 06:59:47 AM by Dannu » Logged
Swollow

« January 14, 2018, 03:34:57 PM »

they need to be exported as dsq files, and you can only export 1 animation at a time, my file includes both animations just so I didn't have to upload two animations
create each animation so it is the only one animation on your timeline, then export that as a dsq, you should save each blender file differently for the animations probably

and yes I included information on how to set the animations in the sequences text block, please re read my information

each dsq has to be a separate file, try importing the tank turrets dsq and dts files to have look
Logged
Rally

« January 14, 2018, 03:39:59 PM »

I don't understand what you mean by each of the animations being exported as a separate dsq file. It might be just Port's exporter, but all of the animations are exported as a single file.

You should be able to select the start and end marker of an animation, export as .dsq, and check "Selection Only" to have it only export that sequence into a .dsq
Logged
Swollow

« January 14, 2018, 03:40:37 PM »

You should be able to select the start and end marker of an animation, export as .dsq, and check "Selection Only" to have it only export that sequence into a .dsq
didn't know you could do this, thanks
Logged
Conan

« January 14, 2018, 05:26:28 PM »

optionally just specify sequence0 = “./filename.dsq”; and that will work. if no name for the animation is specified after the dsq, all animations within the dsq will retain their name and be available for use. if a name is specified, only the first animation in the dsq will be available to use, under that name
Logged
Swollow

« January 15, 2018, 02:39:40 AM »

wtffffff no way
Logged
Pages: [1]  


Login with username, password and session length

Powered by SMF 1.1.20 | SMF © 2013, Simple Machines
Page created in 0.018 seconds with 19 queries.