Animating 5 Legs

Animating 5 Legs

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Animating 5 Legs

Post by kalda341 »

I'm sure you are all tired of posts like these, but as far as I can tell there is no tutorial on animating with lua. How would I go about making a walking animation for something like in the attached pic? The legs are separate objects and labeled leg1 to leg5.
Attachments
72784_158000267568612_100000759194513_267708_4761431_n.jpg
(11.98 KiB) Downloaded 3 times
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Animating 5 Legs

Post by oksnoop2 »

Sweet virus. I don't know about the 5th leg but here's ct's trusty 4 legged animation. Just add more legs?

http://code.google.com/p/conflictterra/ ... .lua?r=673
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Animating 5 Legs

Post by kalda341 »

oksnoop2 wrote:Sweet virus. I don't know about the 5th leg but here's ct's trusty 4 legged animation. Just add more legs?

http://code.google.com/p/conflictterra/ ... .lua?r=673
The 4 legged one is looking good with it after removing all references to shins. What would I change in this script to speed up the animation?
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Animating 5 Legs

Post by SanadaUjiosan »

Code: Select all

                        Turn( forrthigh, x_axis, 0, 0.5 )
The 0.5 dictates speed in that line. As for the rate, I can't give you anything useful other than to play around with it.

http://springrts.com/wiki/Animation-LuaCallouts

That's a good resource if you haven't found it already.
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Animating 5 Legs

Post by kalda341 »

Can anyone see why sb is not moving?

Code: Select all

-- by KR
       
        --pieces
        local body = piece "base"

        local baclthigh = piece "leg2thigh"
        local baclshin = piece "leg2"

        local bacrthigh = piece "leg3thigh"
        local bacrshin = piece "leg3"

        local flare1 = piece "build"

        local forlthigh = piece "leg4thigh"
        local forlshin = piece "leg4"

        local forrthigh = piece "leg5thigh"
        local forrshin = piece "leg5"

		local sa = piece "leg1thigh"
        local sb = piece "leg1"
		
        --signals
        local SIG_AIM = 1
        local SIG_AIM_SEC = 5
        local walk_go = 4
        local walk_stop = 8
local SIG_AIM = 5
local SIG_BUILD = 4

function script.Create(unitID)
end

function script.StartBuilding(heading, pitch)
        Signal(SIG_BUILD)
        SetSignalMask(SIG_BUILD)
        Turn(body, y_axis, heading, math.rad(90))
        WaitForTurn(body, y_axis)
        SetUnitValue(COB.INBUILDSTANCE, 1)
        return 1
end
function script.Querybody() return flare1 end
function script.AimFromWeapon() return body end

function script.StopBuilding()
   Signal(SIG_BUILD)
   SetSignalMask(SIG_BUILD)
   SetUnitValue(COB.INBUILDSTANCE, 0)
   Turn(body, y_axis, 0, math.rad(90))
   WaitForTurn(body, y_axis)
   Sleep(1)
   return 0
end
function script.AimFromWeapon() return flare1 end

function script.QueryWeapon() return flare1 end

function script.Queryflare1Piece() return flare1 end

function script.Killed(recentDamage, maxHealth)
   return 0
end
       
        function script.Create()
               
        end
       
        local function RestoreAfterDelay(unitID)
                Sleep(5500)
                Turn(body, y_axis, 0, math.rad(150))

        end

        local function Walk()
                SetSignalMask( walk_go )
                Sleep(30)
                while ( true ) do
                        Turn( forrshin, x_axis, 5, 5 )
                        Turn( baclshin, x_axis, -5, 5 )
						Turn( sb, x_axis, -5, 5 )
						
                        Turn( forlshin, x_axis, 0, 5 )
                        Turn( bacrshin, x_axis, 0, 5 )
						Turn( sb, x_axis, 0, 5 )

                        WaitForTurn( bacrshin, x_axis )
                        WaitForTurn( forlshin, x_axis )
                        WaitForTurn( forrshin, x_axis )
                        WaitForTurn( baclshin, x_axis )
						WaitForTurn( sb, x_axis )
                        Sleep(30)
                       

                        Turn( forlshin, x_axis, 5, 5 )
                        Turn( bacrshin, x_axis, -5, 5 )
						Turn( sb, x_axis, -5, 5 )

                        Turn( forrshin, x_axis, 0, 5 )
                        Turn( baclshin, x_axis, 0, 5 )
						Turn( sb, x_axis, 0, 5 )

                        WaitForTurn( bacrshin, x_axis )
                        WaitForTurn( forlshin, x_axis )
                        WaitForTurn( forrshin, x_axis )
                        WaitForTurn( baclshin, x_axis )
						WaitForTurn( sb, x_axis )
                        Sleep(30)
                end
        end
       
        local function StopWalk()
                Signal( walk_go )
                Turn( forrshin, x_axis, 0, 5 )
                Turn( baclshin, x_axis, 0, 5 )
				Turn( sb, x_axis, 0, 5 )
               
                Turn( forlshin, x_axis, 0, 5 )
                Turn( bacrshin, x_axis, 0, 5 )
				Turn( sb, x_axis, 0, 5 )
        end
       
        function script.StartMoving()
                StartThread( Walk )
        end
       
        function script.StopMoving()
                StartThread( StopWalk )
        end
       

        function script.QueryWeapon1() return flare1 end
       
        function script.AimFromWeapon1() return body end
       
        function script.AimWeapon1( heading, pitch )
                Signal(SIG_AIM)
                SetSignalMask(SIG_AIM)
                Turn(body, y_axis, heading, math.rad(150))
                Turn(body, x_axis, -pitch, math.rad(100))
                WaitForTurn(body, y_axis)
                WaitForTurn(body, x_axis)
                StartThread(RestoreAfterDelay)
                return true
        end
       


       
        function script.FireWeapon1()
               Sleep(30)
        end



       
        function script.Killed(recentDamage, maxHealth)
                Sleep(30)
        end
Last edited by kalda341 on 22 Nov 2010, 22:31, edited 1 time in total.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6243
Joined: 29 Apr 2005, 01:14

Re: Animating 5 Legs

Post by FLOZi »

Please use the [code][/code] tag.
Post Reply

Return to “Lua Scripts”