Hi guys,
I am having a very, very strange issue with DarkBasic.
I'm trying to do something quite ambitious - make an RTS game. Some of my units have turrets which I want to be able to turn to face an enemy. All action takes place on a 2D x-z plane, so all rotation is about the y-axis.
I've written a function to do this, based on the function that makes the units themselves turn (which works fine), using the ROTATE LIMB command in place of ROTATE OBJECT. The model is a .x exported from Blender, with hierarchical limbs (one for each turret).
However, every time the ROTATE LIMB command is called, the following happens:
- The limbs snap position to the centre of the model, instead of where they should be on its wingtips.
- The limbs rotate 90 degrees so that the gun barrel of the turret is pointing straight up.
And most weird of all:
- The turret limbs resize to GIANT size, much bigger than the whole model.
At no point have I resized the limbs in DarkBasic; they are used as-imported from Blender.
Can someone tell me what on Earth is going on here?
Here is the code:
function turn_obj(obj, targ_x#, targ_y#, targ_z#,turn_v#,v#)
ang0#=object angle y(obj)
point object obj,targ_x#,0,targ_z#
heading#=object angle y(obj)
rotate object obj, 0,curveangle(heading#,ang0#,turn_v#),0
endfunction
function turn_turret(obj, targ_x#, targ_y#, targ_z#,turn_v#,v#)
//Turns unit turrets to face enemy
//Doesn't work
ang0#=object angle y(obj)
point object obj,targ_x#,0,targ_z#
heading#=object angle y(obj)
rotate object obj, 0, ang0#, 0
for i = get_num_limbs(obj)-unit_fire_pts(obj) to get_num_limbs(obj)-1
rotate limb obj, i, 0,curveangle(heading#,ang0#,turn_v#),0
next i
endfunction
UPDATE: Exactly the same thing happens with SCALE LIMB and OFFSET LIMB. It seems any attempt to move or alter the limbs of the model causes this weird effect. Anyone have any ideas?