Hey all, I'm working on weapons for my 2d game (using 3d commands) at the moment and I'm having some issues with moving the bullets. The data I have to work with is as follows:
-Current bullet position
-Angle of travel
-Speed
I found a formula that I believe is supposed to do the trick, but I haven't had any luck getting it working. The formula was found on
this website (look at the first reply), and it may just be an issue that I didn't convert the code to DBP properly. Here's my code:
`Find values for the angle.
var_PositionX# = LIMB POSITION X(arr_Saves_CharacterData(0).Model_BodyID, arr_Saves_CharacterData(0).Model_HandID_Joint)
var_PositionZ# = LIMB POSITION Z(arr_Saves_CharacterData(0).Model_BodyID, arr_Saves_CharacterData(0).Model_HandID_Joint)
var_DistanceX# = glob_Mouse_3DPositionX# - var_PositionX#
var_DistanceZ# = glob_Mouse_3DPositionZ# - var_PositionZ#
`Calculate angle, assign speed, and find new position.
var_Angle# = WRAPVALUE(ATANFULL(var_DistanceX#, var_DistanceZ#) + 90)
var_Speed# = 5.0
var_PositionX_New# = var_PositionX# + COS(var_Angle# * (con_PI / 180)) * var_Speed#
var_PositionZ_New# = var_PositionZ# + SIN(var_Angle# * (con_PI / 180)) * var_Speed#
NOTE: I'm using the Z value as the Y value in my game.