Make a bullet move in faced direction

#1

Hi! This may be duplicate, i don’t know. But, i am having a bullet (“bullet.go”) with this script

function init(self)
local self.movdir = theway
self.speed = 10
end

function update(self, dt)
    local rotation = go.get_rotation()
    local direction = vmath.vector(1,0,0)
    local updateddirection = vmath.rotate(rotation, direction)
    local updatedposition = position + updateddirection * self.speed * dt
 end

And it gets theway from the gun. If i understand the post i got the code from the bullet should move but it just floats in the air. Anybody that can help me.
(@britzl i know you have answered in a lot of discussions on this question but, i don’t understand so good)
I know we have a “answer” to this and that is

but i cant really read the code, so can somebody help me?

0 Likes

Make Bullets fly in Mouse direction
#2

You are not setting the position again. You should do something like:

go.set_position(updatedposition)
1 Like

#3

Edit: I solved it. I just needed to add the script. :grimacing: Well, everybody makes mistakes. I think, nobodys perfect… Im just gonna stay in this corner. Ok?

2 Likes