Hey Everyone,
I’m stuck at the moment and could really use some help.
I’m currently using the “lib_analog_stick.lua” class to spawn a joystick and am trying to shoot an a bullet in the direction of the joystick’s angle, but I cannot figure out how to get the bullet to go in the right direction. (top-down game)
I think my code will best explain the situation, any help would be awesome.
local speed = 1000
local movementScale = {}
movementScale.x = math.cos( math.rad( stickRight:getAngle() ) )
movementScale.y = math.sin( math.rad( stickRight:getAngle() ) )
local velocity = {}
velocity.x = movementScale.x \* speed
velocity.y = movementScale.y \* speed
bullet:applyForce( velocity.x, velocity.y, player.x, player.y)
The problem is that the bullet seems to go in almost random directions, and will never go to the left (decreasing X values). [import]uid: 62528 topic_id: 17684 reply_id: 317684[/import]