Starbound

Starbound

View Stats:
PixelBlood May 3, 2018 @ 8:30am
Animated guns: How to animate a pistol's slide? [NEED HELP]
I am making a gun where upon firing, you can see the slide recoiling. This is accomplished by having a frame of the gun in its "ready" position, and one of the gun with the slide all the way back.
But somehow, I just can't get it to work! The gun is always stuck in the first frame. I also managed to have a continous looping animation of the slide recoiling even when not firing, but that is of course not what I want.
All my modding is done by copying together parts from already existing files within the game because I don't know how to code JSON or LUA.
Does anyone know how to accompliosh my goal? I will post the .activeitem and the .animation below.


{
"itemName" : "emperorpistol",
"price" : 1500,
"inventoryIcon" : "emperorpistolgun.png",
"maxStack" : 1,
"rarity" : "Legendary",
"description" : "Always No. 2",
"shortdescription" : "The Emperor",
"level" : 6,
"tooltipKind" : "gun",
"category" : "pistol",
"itemTags" : ["weapon","ranged","pistol"],
"twoHanded" : false,

"animation" : "emperorpistol.animation",
"animationParts" : {
"gun" : "emperorpistol.png",
"muzzleFlash" : ""
},

"animationCustom" : {
"sounds" : {
"fire" : [ "/sfx/gun/revolver1.ogg" ]
}
},

"baseOffset" : [0.40, 0.20],
"muzzleOffset" : [1.5625, 0.375],

"scripts" : ["/items/active/weapons/ranged/gun.lua"],

"elementalType" : "physical",

"primaryAbility" : {
"scripts" : ["/items/active/weapons/ranged/gunfire.lua"],
"class" : "GunFire",

"fireTime" : 0.33,
"baseDps" : 15,
"energyUsage" : 20,
"inaccuracy" : 0.0,

"projectileCount" : 1,
"fireType" : "auto",

"projectileType" : "standardbullet",
"projectileParameters" : {
"knockback" : 9
},

"stances" : {
"idle" : {
"armRotation" : 0,
"weaponRotation" : 0,
"twoHanded" : false,

"allowRotate" : true,
"allowFlip" : true
},
"fire" : {
"duration" : 0,
"armRotation" : 5,
"weaponRotation" : 10,
"twoHanded" : false,

"allowRotate" : false,
"allowFlip" : true
},
"cooldown" : {
"duration" : 0.15,
"armRotation" : 5,
"weaponRotation" : 5,
"twoHanded" : false,

"allowRotate" : false,
"allowFlip" : true
}
}
},


"builder" : "/items/buildscripts/buildunrandweapon.lua"
}



this was the .activeitem, now follows the .animation




{
"globalTagDefaults" : {
"paletteSwaps" : ""
},

"animatedParts" : {
"stateTypes" : {
"gun" : {
"default" : "idle",
"states" : {
"idle" : {
"frames" : 1,
"cycle" : 1.00,
"mode" : "loop"
},
"fire" : {
"frames" : 1,
"cycle" : 0.15,
"mode" : "transition",
"transition" : "idle"
}
}
},
"firing" : {
"default" : "idle",
"states" : {
"idle" : {},
"fire" : {
"frames" : 2,
"cycle" : 0.15,
"mode" : "transition",
"transition" : "idle"
}
}
}
},


"parts" : {
"gun" : {
"properties" : {
"centered" : true,
"offset" : [ 0.4, 0.2 ],
"transformationGroups" : ["weapon"]
},

"partStates" : {
"gun" : {
"idle" : {
"properties" : {
"image" : "<partImage>:idle"
}
},
"fire" : {
"properties" : {
"image" : "<partImage>:fire"
}
}
}
}
}
}
},

"rotationGroups" : {
"weapon" : {
"angularVelocity" : 0
}
},

"transformationGroups" : {
"weapon" : {},
"muzzle" : {}
},

"particleEmitters" : {
"muzzleFlash" : {
"transformationGroups" : ["muzzle"],
"offsetRegion" : [0, 0, 0, 0],
"particles" : [ ]
}
},

"lights" : {
"muzzleFlash" : {
"active" : false,
"position" : [0, 0],
"color" : [90, 90, 0]
}
},

"sounds" : {
"fire" : [ ]
}
}
Last edited by PixelBlood; May 3, 2018 @ 8:59am
Date Posted: May 3, 2018 @ 8:30am
Posts: 0