komefai / PS4Macro

Automation utility for PS4 Remote Play written in C#
http://blog.komefai.com
MIT License
375 stars 89 forks source link

Character Very choppy while running #96

Open smj2000 opened 4 years ago

smj2000 commented 4 years ago

I am new to the program and im sure its something im doing wrong but as i run this script the character runs very choppy... it does what i want but it looks horrible and some times results in not getting to destination becasue of the choppy running ... any help would be appreciated and thanks in advance ... great project !!!

` using PS4MacroAPI;

public class Script : ScriptBase {

/* Constructor */
public Script()
{
    Config.Name = "Example Script";
    //Config.LoopDelay = 50;
}

// Called when the user pressed play
public override void Start()
{
    base.Start();

}

// Called every interval set by LoopDelay
public override void Update()
{
    while(true)
    {
        DualShockState up = new DualShockState();
        DualShockState down = new DualShockState();
        DualShockState left = new DualShockState();
        DualShockState right = new DualShockState();
        DualShockState cross = new DualShockState();
        DualShockState square = new DualShockState();

        up.LY = 0x0;
        down.LY = 0xFF;
        left.LX = 0x0;
        right.LX = 0xFF;
        cross.Cross = true;
        square.Square = true;

        Press(cross, 300);
        Sleep(4000);

        Press(square, 300);
        Sleep(1000);

        Press(square, 300);
        Sleep(1000);

        Press(down, 3000);
        Sleep(300);

        Press(up, 3800);
        Sleep(300);

        Press(left, 4200);
        Sleep(300);

        Press(down, 5500);
        Sleep(300);

        Press(right, 3000);
        Sleep(300);

        Press(up, 1000);
        Sleep(300);

        Press(cross, 300);
        Sleep(4000);

        Press(square, 300);
        Sleep(1000);

        Press(square, 300);
        Sleep(1000);

        Press(up, 2000);
        Sleep(1000);

        Press(left, 2000);
        Sleep(1000);

        Press(up, 3500);
        Sleep(1000);

        Press(right, 4500);
        Sleep(1000);

        Press(down, 4000);
        //Sleep(1000);

        Sleep(64000);
    }
}

} `

smj2000 commented 4 years ago

I should also say i have tried to mess with the loop delay and also tried to remove it all together.. again im very novice and thanks for help on awesome project!

Morty2323 commented 4 years ago

Hey, the Sleep function causes the system to wait a certain amount of time until the code continues, so for example at the bottom of your code after you press right for 4,5 seconds it waits 1 second before pressing down for 4 seconds.

If you didn't know this try to remove the unnecessary Sleep functions where you don't want the system to wait.

If you are aware of this and this isn't the problem then maybe it's the connection of the PS4 Remote Play. Sometimes it seems that PS4 Macro misses some of the inputs which can be solved by connecting a LAN cable from your PC to your PS4. Then you have to setup a network bridge. ( there are a lot of tutorials for this just google it)

I highly doubt that the loop delay is the source of your problem.

Also your while true loop is unnecessary because the update function gets called every 50ms. You can adjust this value at the very top where it says: Config.LoopDelay = 50;

Write here again if this solved your problem or the problem still persists.

smj2000 commented 4 years ago

Hello and thanks for a response!

So maybe i was not using the sleep function properly but basically i was trying to slow things down by pausing...

i have made a bridge between the ps4 and the pc and still there is choppy on character its like he "stutters"..

i have changed a few things based on what you said and made this test script here

he is supposed to just move forward and then jump... while moving forward its very choppy..

i have also tried messing with the loop delay but it does not seem to hurt or help anything.... thanks for any input!!

`using PS4MacroAPI;

public class Script : ScriptBase {

/* Constructor */
public Script()
{
    Config.Name = "Example Script";
    Config.LoopDelay = 75;
}

// Called when the user pressed play
public override void Start()
{
    base.Start();

}

// Called every interval set by LoopDelay
public override void Update()
{
    {
        DualShockState up = new DualShockState();
        DualShockState down = new DualShockState();
        DualShockState left = new DualShockState();
        DualShockState right = new DualShockState();
        DualShockState cross = new DualShockState();
        DualShockState square = new DualShockState();

        up.LY = 0x0;
        down.LY = 0xFF;
        left.LX = 0x0;
        right.LX = 0xFF;
        cross.Cross = true;
        square.Square = true;

        Press(up, 4000);
        Sleep(4000);

        Press(cross);
        Sleep(1000);

    }
}

} `

Morty2323 commented 4 years ago

Your character is supposed to walk forward for 4 seconds then do nothing for 4 seconds and then jump and then wait another second, after that the system waits 50ms and restarts the process.

Okay replace your Code with this code:

/ Constructor / public Script() { Config.Name = "Example Script"; Config.LoopDelay = 75; }

// Called when the user pressed play public override void Start() { base.Start();

}

// Called every interval set by LoopDelay public override void Update() { Press(new DualShockState() { DPadUp = true }, 4000); Sleep(4000);

    Press(new DualShockState() {  Cross= true });
    Sleep(1000);

}

If this didn't work then maybe the 4 seconds holding the button is too much, instead of Press(new DualShockState() { DPadUp = true }, 4000); insert:

int count = 0; for(count = 0; count < 4000 / 500; count++) { Press(new DualShockState() { DPadUp = true }, 500); }

smj2000 commented 4 years ago

Thanks for response!

Again i have tried all of your suggestions and still the character stutters while running...

Something i have to change that might make a difference is in this game you can not move with "DPAD" so i have to use command LY im not sure maybe thats causing the problem...

thanks again!

letito commented 5 months ago

Hi, did you ever solved this problem?. I have the same one. When I record the movement it doesn't sttuter, but when I play it, it stops and runs intermitently.

I remember using the program before and didn't happen, but now it does.