So what I want to achieve is for the player to click were the bullet goes. Then using heartbeat have the bullet move to that location. What kind of maths/equation would I need to achieve this?
1 Like
So hearbeat service uses dt
, the change in time, a paramter which it sends through. This parameter is the difference of time between previous and this frame.
Now with that we have the velocity or the speed, we will call this v
. Let’s keep it constant.
Now we with the look direction, we will call this the LookVector
we will do the following:
x += v * dt
now with this new found position we will add it to the LookVector
for the position of the bullet.
bullet.Position = x * LookVector
Now you just have to use raycasts in between to make sure you didnt pass through a player.