Open JekSun97 opened 1 month ago
I see the resources GDCubismValueAbs and GDCubismParameter, but I don’t understand how to change the value and apply it to the model
@MizunagiKB
I found the way:
cubism_model.get_parameters()[id].set_value(value)
only immediately after changing the value it is returned by default, perhaps in the source code you need to do _model->SaveParameters()
, as specified in the Cubism SDK, so that the parameter is saved
I am using code like this to change values:
func _process():
var id=4
if Input.is_key_pressed(KEY_A):
value-=0.01
cubism_model.get_parameters()[id].set_value(value)
if Input.is_key_pressed(KEY_D):
value+=0.01
cubism_model.get_parameters()[id].set_value(value)
but when I release the keys my eyes open again: https://github.com/user-attachments/assets/5dd2dd1b-7bf8-4860-b9cb-56778823296a
This happens even without animation, and with animations in which this parameter is not involved (I tested it on others)
@JekSun97
The reason the value doesn’t change when you try to modify the parameter is because the applied Motion is constantly overwriting the information.
By setting the ParameterMode of GDCubismUserModel to NONE_PARAMETER
, you can freely manipulate all parameters.
However, this is intended for control by the AnimationPlayer on the Godot Engine side rather than free manipulation of parameters, so it may not align with your purpose.
The inability to manipulate parameters is partly due to SaveParameter, but it is largely due to the circumstances of the Cubism Native Framework that GDCubism depends on.
It is processed at the timing of _process, but in GDCubism, we have prepared a node called GDCubismEffectCustom
so that only such processing can be performed.
By placing this node as a child element of GDCubismUserModel, you can receive signals before and after the update of Motion.
For example, you can change the parameter by receiving a signal called cubism_process
.
The method of change is the same as what you are doing in
_process
, but the user_model itself is set in the argument of the received signal, so you don’t need to pass or save the user_model itself in advance.
Although it is not a complete solution, this method allows you to separate the work related to Motion from the _proccess
processing, so it is recommended.
@MizunagiKB Thanks, I'll try this in a few days. It would be useful to have a small example of this, if I hadn't looked at the source code, I would hardly have figured out how to use it and find the parameters
@JekSun97
Documentation on parameter control and GDCubsimEffectCustom has been added.
https://mizunagikb.github.io/gd_cubism/gd_cubism/0.6/en/custom/motion.html
The following usage examples are provided:
In Live2D Cubism Editor I have a slider (Parameter) that hides a certain type of clothing and another slider for the appearance of other clothes, how can this be used in a plugin without including a certain animation, will I really have to redo all the animations with one clothing and then the same animation with different clothes? to somehow have customization
In short: @MizunagiKB how can I control certain parameters?