Godot Version
4.3
Question
Hello all,
With a lot of help I am getting really close to solving this problem of controlling my top down tank and movement with the Analog sticks only, ditching the mouse and keyboard controls entirely which though cool were … erm, problematic to say the least.
Now I have this code:
func get_input():
var input_direction = Input.get_vector("c_left","c_right","c_up","c_down");
var turret_direction = Input.get_vector("r_left","r_right","r_up","r_down");
velocity = input_direction * speed;
#try and change turrent rotation
if(turret_direction):
print("turret direction: " +str(turret_direction) );
#to change turret_sprite rotation - works
turret_sprite.rotation = turret_direction.angle() - deg_to_rad(90);
#how to change turret rotation to fire in the correct direction
##this line causes the problem##
#turret_pivot_point.rotation = turret_direction.angle();
if (input_direction):
print("Input Direction: " + str(input_direction)) ;
tank_sprite.rotation = input_direction.angle() + deg_to_rad(tank_offset);
#to get the spawn point to the correct rotation
#turret_pivot_point.rotation = tank_sprite.rotation - deg_to_rad(90);
tank_uncombined.rotation = input_direction.angle() + deg_to_rad(tank_offset);
#tank_combined_dark.rotation = input_direction.angle() + deg_to_rad(tank_offset);
#end if
#end
Now, this configuration of code allows the tank to move in the correct direction with the left analog stick AND allows control of the turret sprite with the right. However, I cannot get the Turret_pivot_point the 2D node object to rotate properly around the outside of the turret sprite to fire in the correct direction. That was supposed to be handled by the line under: ##this line causes the problem##
Not only does it not rotate properly getting out of alignment very quickly it also causes the tank turret_sprite rotation to act weirdly as well.
So, there is some math to be done here or working out the vectors but it a bit beyond me at the moment, so, any help would be appreciated.
Thankyou and Regards.
