I’m not sure what I’m doing wrong when it comes to rotating game objects, I’m not used to having to use fancy vmath, so I don’t really know what I’m doing. I have this code here, where the “walk_down” and “walk_up” for the rotation are working…probably because the z is 0. But on the “walk_left” and “walk_right” conditions, the sprite completely dissappears. I’ve looked at the examples that use rotation, but they all use calculations instead of manually setting so I don’t really know how to do this. Any help would be appreciated.
local p = go.get_position("/test1_go_weapon")
local i = go.get_id("/test1_go_weapon")
local pw = go.get_position("/test1_go_slash")
local iw = go.get_id("/test1_go_slash")
local rw = go.get_rotation(iw)
if self.current_anim == hash("anim_hero_walk_down") then
p.x = -8
p.y = 3
p.z = 0.1
pw.x = 0
pw.y = -23
rw.z = 0
elseif self.current_anim == hash("anim_hero_walk_up") then
p.z = -0.1
p.x = 8
p.y = 3
pw.x = 3
pw.y = 23
rw.z = 0
elseif self.current_anim == hash("anim_hero_walk_right") then
p.z = 0.1
p.x = 0
pw.x = 27
pw.y = 0
rw.z = 180
elseif self.current_anim == hash("anim_hero_walk_left") then
p.z = 0
p.x = 0
p.y = 3
pw.x = -25
pw.y = 0
rw.x = 0
rw.y = 0
rw.z = 270
end
go.set_position(p, i)
go.set_position(pw, iw)
go.set_rotation(rw, iw)
end