My previous question asked was about setting the rotation of an sprite to face the Mouse at all times, with help of a member here I managed to get that workng, now that I have done that, I have created a Bullet class, and great knews, I’ve got everything set up just the way I want it, minus one thing. The movement. I have no idea how to go about moving this properly, I’ve tried a few things, but I can’t get it the move in a straight line.
What I’m Trying to do: Instantiate a sprite to move in a certain direction.
I’m just not sure on what needs to be done for the logic calculations, once again. I’ve done some research and I was brought to a topic on GameDev forums that provided a solution, however it was giving me the same issue that I had to begin with. There is not a “target point” for this object, it’s just supposed to move along an angle.
This angle is the same angle that the sprite it rotated by, fortunately, so getting the angle wasn’t a problem.
But how would I move it?
Currently I’m using a Vector2 for my positioning and just using a standard system for movement.
void moveLeft() {
setX(getX() - playerSpeed);
}
^This is to give you an example.
While I was developing in Unity a few years ago, this was called “adding force” to an object, but I’m not exactly sure how it all worked, but it caused it object to move forward constantly.
Suggestions? Psuedo?