How can I change motions in the sample app project by mouse clicks?

edited December 2023 in Help
i wonder if i use sampleApp1, can i change motion by click the button that i made in unity?

for example:

button 1 = motion A
button 2 = motion B
button 3 = motion C
and i want after motion finished, motion back to iddle motion.

thank you :)
Tagged:

Comments

  • edited April 2015
    Add the following code to the end, You can change the motion by calling from UGUI button.
    [LAppModelProxy.cs]
    public void button1_click(){
    	model.StartMotion("shake", 0, 2);
    }
    
    public void button2_click(){
    	model.StartMotion("tap_body", 0, 2);
    }
    
    model.StartMotion(argument1, argument2, argument3)

    ・argument1 = model.json - GroupID("idle", "tap_body", "pinch_in", "shake"...)
    ・argument2 = model.json - GroupID - File number(0, 1, 2, from the top ...)
    ・argument3 = 2(fixed) → Priority

    Please try this.
     ↓
    ・Specified motion playback in SampleApp1 of Live2D
  • wooow thanks! it work! :D

    is LAppModelProxy.cs has function to stop motion (except idle motion) while playing ?
    I think it would be more fun i can control when motion of my model stop :)
  • edited May 2015
    I think you can stop the motion following code.
    [LAppModel.cs]
    public class LAppModel :L2DBaseModel
    {
        private LAppModelProxy parent;
        private LAppView view;
        public bool motion_stop = false; // add code
        .
        .
    
    
    public void Update(){
        .
        .
            live2DModel.loadParam();
        // modify code start
    	bool update = false;
    	if(motion_stop == false){
    //		bool update = mainMotionManager.updateParam(live2DModel);
    		update = mainMotionManager.updateParam(live2DModel);
    	}
        // modify code stop
            if (!update)
        .
        .
        if(motion_stop == false){  // add code
            live2DModel.update();
        }   // add code
    }
    
    [LAppModelProxy.cs]
    // add code
    public void button4_click(){
        // motion stop
        model.motion_stop = false;
    }
    public void button5_click(){
        // motion start
        model.motion_stop = true;
    }
    
  • thank you for your help, but after i followed your instruction i found this problem.

    it say:
    Assets/Scripts/sample/LAppModel.cs(197,22): error CS0136: A local variable named `update' cannot be declared in this scope because it would give a different meaning to `update', which is already used in a `parent' scope to denote something else
  • edited May 2015
    I don't know this error only.
    Do you have what code to 197 line ?
  • ah im sorry i forgot upload the screenshoot of error code
    here the code in 197 line.
    i found error code come from the code that you give

    i wonder, am i wrong write the code that you give or something?
    because i really follow your instruction correctly

    i upload code from LAppModel.cs and LAppModelProxy.cs
  • edited May 2015
    I was understand problem.
    Please look at my wrote code!

    The code in 197 line is comment out.
    //      bool update = mainMotionManager.updateParam(live2DModel);
    
  • oh my.... im sorry i am not scrupulous
    thank you a lot :D
    now my motion can stop but the audio still running.
    can audio set like motion too?
  • Answer was delayed.
    Voice stop is add the following code.
    [LAppModel.cs]
    public void Update()
    {
    	・
    	・
    	// Add code start
    	if (motion_stop == true)
    	{
    		// voice stop
    		asVoice.Stop();
    	}
    	// Add code stop
    	・
    	・
    }
    
  • it works!
    thank you naotaro, you really help me :D
Sign In or Register to comment.