GML Visual Moving tank at an angle

R

Remeuf

Guest
Hello,

First of all, excuse my English (I have difficulties to follow the tutorials in English).
I am in beginner DnD mode.
My problem :

I have a parent object (tank) that pivots on itself with the right and left keyboard keys. This object has an angle.
I would like him now to advance (touch up) but keep his angle (he must advance in his angle = the front of the vehicle must always be in the direction of his direction - he is not a crab; )).

N.B: The parent object has another child object. A turret. The turret pivots by following the mouse cursor (this part works well).

thank you very much for your answer
 

GMWolf

aka fel666
you can use the 'direction' and 'speed' variables.
'direction' will set the direction of movement.
'speed' will set the speed at which you move in 'direction'.
 
R

Remeuf

Guest
Thank you for your answer Wolf
It does not work unfortunately.
I also tried the lengthdir function for x and y:
x = lengthdir_x (variable, angle_image);
No result, my tank always goes ahead anyhow or not at all.
I may go through fixed moves with sprite changes;)
 

Toque

Member
Cosmonaut did a tutorial space rocks. She covers rotating and moving in that pointed direction. That might help. It might learn a few other things too.
 
R

Remeuf

Guest
Bonjour,
I solved my problem in GML. It's simple and it works great. Here is the code for those who might be interested :

var avance;
avance = keyboard_check(vk_up);
if (avance)
{
x += lengthdir_x(4,image_angle+90);
y += lengthdir_y(4,image_angle+90);
}


Thanks Toque too ;)
 
Top