Created
July 20, 2021 01:56
-
-
Save izackp/ec81d1e370652330f63cf4e5553c407c to your computer and use it in GitHub Desktop.
Experiment Character Controller in JSON. Mostly just high level components, actions, and event handlers that can be mapped around pretty easily. State is stored via stack; by pushing and popping components (behavior). Falls short of usefulness mostly through readability. Perhaps that could be solved with a UI builder and live preview.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$type":"Models.Components.ComponentGroupVersioned", | |
"version": 0.1, | |
"subcomponents": [ | |
{ | |
"$type": "Models.Components.CharacterComponent", | |
"displayName": "Bandit", | |
"componentRefs":["DefaultSkin", "Body", "BodyStack", "Feet", "FeetStack", "Target"] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"Body", | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.AnimationAnchor", | |
"refName": "Body", | |
"x": 0.0, | |
"y": 4.0, | |
"z": 0.0 | |
}, | |
{ | |
"$type":"Models.Components.EventCombinationList", | |
"combinations" : [ | |
{ | |
"refName":"LeftStick", | |
"keys":["LeftStickX", "LeftStickY"], | |
"comboType":"any" | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"DefaultSkin", | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.AnimationDirectionalDesc", | |
"refName": "MoveBody", | |
"path": "Bandit/MoveBody", | |
"secondsPerFrame": 0.2, | |
"xPivot":0.5, | |
"yPivot":0.0 | |
}, | |
{ | |
"$type":"Models.Components.AnimationDirectionalDesc", | |
"refName": "MoveFeet", | |
"path": "Bandit/MoveFeet", | |
"secondsPerFrame": 0.2, | |
"xPivot":0.5, | |
"yPivot":1.0 | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentStack", | |
"refName":"BodyStack", | |
"componentRef":"IdleBody" | |
}, | |
{ | |
"$type":"Models.Components.ComponentStack", | |
"refName":"FeetStack", | |
"componentRef":"IdleFeet" | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"IdleBody", | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.AttachActions", | |
"actions" : [ | |
{ | |
"$type":"Models.Components.Actions.ActionPlayDirectionAnimation", | |
"loop":false, | |
"animation":"MoveBody", | |
"speedFormula":"0", | |
"anchor":"Body", | |
"resetAnimation":true | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.EventNameToActionNameMapping", | |
"eventsToActions" : { | |
"PressLeftStick":"MovePressed" | |
} | |
}, | |
{ | |
"$type":"Models.Components.EventActions", | |
"orderedActions" : [ | |
{ | |
"refName": "MovePressed", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionPush", | |
"target":"BodyStack", | |
"value":"MovingBody" | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"MovingBody", | |
"extensionRefs" : ["LeftStickVector"], | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.EventNameToActionNameMapping", | |
"eventsToActions" : { | |
"ReleaseLeftStick":"MoveReleased", | |
"LeftStickChanged":"MoveChanged" | |
} | |
}, | |
{ | |
"$type":"Models.Components.EventActions", | |
"orderedActions" : [ | |
{ | |
"refName": "MoveReleased", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionPop", | |
"target":"BodyStack" | |
} | |
] | |
}, | |
{ | |
"refName": "MoveChanged", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionPlayDirectionAnimation", | |
"loop":true, | |
"animation":"MoveBody", | |
"speedFormula":"LeftStickVector_Magnitude", | |
"anchor":"Body" | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"Feet", | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.AnimationAnchor", | |
"refName": "Feet", | |
"x": 0.0, | |
"y": 0.0, | |
"z": 0.0 | |
}, | |
{ | |
"$type":"Models.Components.Attribute", | |
"refName":"movementSpeed", | |
"value":2 | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"IdleFeet", | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.AttachActions", | |
"actions" : [ | |
{ | |
"$type":"Models.Components.Actions.ActionPlayDirectionAnimation", | |
"loop":false, | |
"animation":"MoveFeet", | |
"speedFormula":"0", | |
"anchor":"Feet", | |
"resetAnimation":true | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.EventNameToActionNameMapping", | |
"eventsToActions" : { | |
"PressLeftStick":"MovePressed" | |
} | |
}, | |
{ | |
"$type":"Models.Components.EventActions", | |
"orderedActions" : [ | |
{ | |
"refName": "MovePressed", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionPush", | |
"target":"FeetStack", | |
"value":"MovingFeet" | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"MovingFeet", | |
"extensionRefs" : ["LeftStickVector"], | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.EventNameToActionNameMapping", | |
"eventsToActions" : { | |
"ReleaseLeftStick":"MoveReleased", | |
"LeftStick":"Move", | |
"LeftStickChanged":"MoveChanged" | |
} | |
}, | |
{ | |
"$type":"Models.Components.EventActions", | |
"orderedActions" : [ | |
{ | |
"refName": "MoveReleased", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionPop", | |
"target":"FeetStack" | |
} | |
] | |
}, | |
{ | |
"refName": "MoveChanged", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionPlayDirectionAnimation", | |
"loop":true, | |
"animation":"MoveFeet", | |
"speedFormula":"LeftStickVector_Magnitude", | |
"anchor":"Feet" | |
} | |
] | |
}, | |
{ | |
"refName": "Move", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionMove", | |
"xFormula":"LeftStickVector_XNormal * Feet_movementSpeed", | |
"yFormula":"LeftStickVector_YNormal * Feet_movementSpeed" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$type":"Models.Components.ComponentGroupVersioned", | |
"version": 0.1, | |
"subcomponents": [ | |
{ | |
"$type": "Models.Components.ComponentExtension", | |
"refName":"RightStickVector", | |
"componentRefs":["VectorBase"], | |
"subcomponents":[ | |
{ | |
"$type":"Models.Components.EventCombinationList", | |
"combinations" : [ | |
{ | |
"refName":"RightStick", | |
"keys":["RightStickX", "RightStickY"], | |
"comboType":"any" | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.EventNameToActionNameMapping", | |
"eventsToActions" : { | |
"RightStickX":"X", | |
"RightStickY":"Y", | |
"RightStick":"XYChanged" | |
} | |
} | |
] | |
}, | |
{ | |
"$type": "Models.Components.ComponentExtension", | |
"refName":"LeftStickVector", | |
"componentRefs":["VectorBase"], | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.EventCombinationList", | |
"combinations" : [ | |
{ | |
"refName":"LeftStick", | |
"keys":["LeftStickX", "LeftStickY"], | |
"comboType":"any" | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.EventNameToActionNameMapping", | |
"eventsToActions" : { | |
"LeftStickX":"X", | |
"LeftStickY":"Y", | |
"LeftStick":"XYChanged" | |
} | |
} | |
] | |
}, | |
{ | |
"$type":"Models.Components.ComponentGroup", | |
"refName":"VectorBase", | |
"subcomponents": [ | |
{ | |
"$type":"Models.Components.AttributeList", | |
"attributes": { | |
"XNormal":0, | |
"YNormal":0, | |
"XMagnitude":0, | |
"YMagnitude":0, | |
"Magnitude":0 | |
} | |
}, | |
{ | |
"$type":"Models.Components.EventActions", | |
"orderedActions" : [ | |
{ | |
"refName": "X", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionSetAttribute", | |
"name":"XMagnitude", | |
"valueFormula":"value" | |
} | |
] | |
}, | |
{ | |
"refName": "Y", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionSetAttribute", | |
"name":"YMagnitude", | |
"valueFormula":"value" | |
} | |
] | |
}, | |
{ | |
"refName": "XYChanged", | |
"actions": [ | |
{ | |
"$type":"Models.Components.Actions.ActionSetAttribute", | |
"name":"Magnitude", | |
"valueFormula":"Sqrt (YMagnitude * YMagnitude + XMagnitude * XMagnitude)" | |
}, | |
{ | |
"$type":"Models.Components.Actions.ActionSetAttribute", | |
"name":"YNormal", | |
"valueFormula":"YMagnitude / Magnitude" | |
}, | |
{ | |
"$type":"Models.Components.Actions.ActionSetAttribute", | |
"name":"XNormal", | |
"valueFormula":"XMagnitude / Magnitude" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment