Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Asset Forge

Create your own 3D models and 2D sprites! · By Kenney

.rotateSelection() on group or selectall()

A topic by damoat created Oct 09, 2021 Views: 285 Replies: 1
Viewing posts 1 to 2

Hey hey, trying to use a script to generate some sprites for an lame outrunnish style of game and its working as i expected but..

theres 2 loops, one giving a quater turn of the wheel objects, and another to rotate the whole model around the y axis.. the wheel rotation works fine, but the rotateselction() rotates each object around its own y axis rather than the selection or group y axis.. am i doin it right? tried some variations of grouping and reselecting but same result.

for y = 0, 18 do
    -- -45 to 45 around model y axis in 5degree increments ?
    for x = 0,10 do
        -- wheel rotaton, qtr turn
        forge.clear()
        forge.build("Moats/cg_Body", {0, 0, 0}, {0, 0, 0}, {1, 1, 1})
        forge.build("Moats/cg_Wheel_FL", {.65, -.29, .82}, {x * 9, 0, 0}, {1, 1, 1})
        forge.build("Moats/cg_Wheel_FR", {-.65, -.29, .82}, {x * 9, 0, 0}, {1, 1, 1})
        forge.build("Moats/cg_Wheel_RL", {.65, -.29, -.88}, {x * 9, 0, 0}, {1, 1, 1})
        forge.build("Moats/cg_Wheel_RR", {-.65, -.29, -.88}, {x * 9, 0, 0}, {1, 1, 1})
        imgcode = "WR" .. string.format("%02d", x) .."CA"..string.format("%02d", y)
        forge.selectAll()
        --forge.groupSelection("EntireModel")
        --forge.selectNone()
        --forge.selectAll("EntireModel")
        forge.rotateSelection({0, -45 + (y * 5), 0})
        forge.exportSprite(512, "C:\\cg_PlayerSprites\\cg_Player_" .. imgcode)
    end
end


(1 edit)

You may have solved this by now, but in case anybody is interested you can achieve it using a rotation matrix like so: example gist