I'm trying to make a gun....
#2
There's currently no way to get the position of the tool. Until that is added, the only way to do it is to turn the tool's rotation into a vector, multiply it by the length and add it to the character's position.

Example from the rocket tool:

[lua]
function normalizeVector(vec)
local m = math.sqrt(vec.x * vec.x + vec.y * vec.y)
return Vec2D(vec.x / m, vec.y / m)
end
[..]
body = character.Body
local v = normalizeVector(Vec2D(mousepos.x - body.Position.x + 0.1, mousepos.y - body.Position.y - 1.5))
bullet.Position = Vec2D(body.Position.x - 0.1 + v.x * 7, body.Position.y + 1.5 + v.y * 7)
[/lua]
Reply


Messages In This Thread
I'm trying to make a gun.... - by sckum555 - 02-02-2011, 06:37 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)