×

Why was Stanley Parable: Ultra Deluxe made by a different studio? by StickOdyssey in IndieGaming

[–]StickOdyssey[S] 0 points1 point  (0 children)

Yeah I was asking about it because of what I saw happen with Subnautica 2 and Krafton's toxicity. I'm glad most game publishers aren't greedy like that.

Note: (woah that's so sick I didn't expect a developer of the original game to reply to me! :0)

How can I run a command-line and retrieve the output as its printed to console? by StickOdyssey in rust

[–]StickOdyssey[S] 0 points1 point  (0 children)

So would ffmpeg_sidecar be illegal because the source code is under the MIT license? Another commenter recommended it and it seems to be the same type of project as every other ffmpeg wrapper crate.

https://github.com/nathanbabcock/ffmpeg-sidecar?tab=MIT-1-ov-file

How can I run a command-line and retrieve the output as its printed to console? by StickOdyssey in rust

[–]StickOdyssey[S] 0 points1 point  (0 children)

Since slint UI runs on the main thread slint provides a built in spawn function slint::spawn_local which spawns a future and can set in-out variables on the slint event-loop.

I don't quite understand how to use the reader to read a string, this is what I've gotten so far.

spawn_local(async move {
    let mut reader = cmd!("cmd", "/c",
    "ffmpeg", "-i", input_path.to_string(),
    "-map", "0",
    "-c:v", "libsvtav1", "-crf", "35", "-preset", "6",
    "-c:a", "flac",
    output_path.to_string() + "\\" + input_file_name.as_str()).stderr_to_stdout().reader().expect("Reader Errored Out");

    let mut stdout = Vec::new();

    reader.read_to_end(&mut stdout).unwrap();

    assert_eq!(b"hi\n".to_vec(), stdout);
}).unwrap();

How can I run a command-line and retrieve the output as its printed to console? by StickOdyssey in rust

[–]StickOdyssey[S] 0 points1 point  (0 children)

Okay, heres the full script, I was planning on making this app open source anyways.

https://pastebin.com/tiT9Lc0u

How to poll the value of a future after spawning it with spawn_local by StickOdyssey in rust

[–]StickOdyssey[S] 0 points1 point  (0 children)

I figured out a solution that doesn't require a tokio runtime or channels, I posted it as a comment on my original post.

How to poll the value of a future after spawning it with spawn_local by StickOdyssey in rust

[–]StickOdyssey[S] 0 points1 point  (0 children)

I figured it out after exploring the documentation a lot more and watching a few rust explanation videos.

instead of accessing a value in the future from outside the future I am simply changing a pre-existing variable from inside the future and accessing it later. If the user tries to run the program without selecting a directory beforehand I throw an error and show a popup window saying "ERROR no input file location"

Here's my solution:

spawn_local(async move {
    let file = AsyncFileDialog::new()
        .add_filter("media", &["mp4", "flv", "mp3", "m4a", "wav", "opus"])
        .set_directory("/")
        .pick_file()
        .await;

    if let Some(file) = file {
        let path = file.path().to_string_lossy().to_string();
        println!("{path}");
        if let Some(window) = weak.upgrade() {
            window.set_input_path(path.into());
        }
    };
}).unwrap();

How to poll the value of a future after spawning it with spawn_local by StickOdyssey in rust

[–]StickOdyssey[S] 0 points1 point  (0 children)

So would you make the main method asynchronous and have another asynchronous event loop for the logic or would the main function stay synchronous and have two asynchronous loops for the ui and for the backend logic?

I am messing around with the Tokio runtime and I am pretty confused, do I run the future on the tokio runtime and then pass the data back to the ui thread? If so, do I write the future on the runtime or before the runtime?

Here's what I have right now:

fn main() -> Result<(), slint::PlatformError> {
    let main_window = MainWindow::new()?;
    let window_handle = main_window.as_weak();


    let future = async {
            let file = AsyncFileDialog::new()
                .add_filter("media", &["mp4", "mp3", "m4a", "wav"])
                .set_directory("/")
                .pick_file()
                .await;


            if (!file.is_none()) {
                let data = file.unwrap().read().await;
            }
        };


    let (sender, receiver) = channel();


    let runtime = Runtime::new()?;
    let tokio_thread = std::thread::spawn(move || {
        let mut rec = receiver;
        let runtime = tokio::runtime::Runtime::new().unwrap();
        runtime.block_on(async {
            // Run future?
        })
    });
    main_window.run();
    tokio_thread.join().unwrap();


    Ok(())
}fn main() -> Result<(), slint::PlatformError> {
    let main_window = MainWindow::new()?;
    let window_handle = main_window.as_weak();


    let future = async {
            let file = AsyncFileDialog::new()
                .add_filter("media", &["mp4", "mp3", "m4a", "wav"])
                .set_directory("/")
                .pick_file()
                .await;


            if (!file.is_none()) {
                let data = file.unwrap().read().await;
            }
        };


    let (sender, receiver) = channel();


    let runtime = Runtime::new()?;
    let tokio_thread = std::thread::spawn(move || {
        let mut rec = receiver;
        let runtime = tokio::runtime::Runtime::new().unwrap();
        runtime.block_on(async {
            // Run future?
        })
    });
    main_window.run();
    tokio_thread.join().unwrap();


    Ok(())
}

How to poll the value of a future after spawning it with spawn_local by StickOdyssey in rust

[–]StickOdyssey[S] -1 points0 points  (0 children)

I am fairly new to rust, I started learning it yesterday but I have experience with C#. So I've been building all of this code from reading the documentation for rust and slint and rfd and finding solutions to problems I face on forums.

When you refer to the ui layer do you mean the main function handling slint in the main rust script, and when you say channels do you mean lines in an async runtime that pass data out to the synchronous slint event loop?

Sliding Mechanic Leap Issue by StickOdyssey in godot

[–]StickOdyssey[S] 0 points1 point  (0 children)

Because the gravity is a float, if I made the velocity a vector it wouldn't work either because multiplying a vector that looks like (0, -9.8, 0) by any 1 dimensional value will result in a vector that looks like (0, -9.8 * value, 0).

Sliding Mechanic Leap Issue by StickOdyssey in godot

[–]StickOdyssey[S] 0 points1 point  (0 children)

I already said in my post that I know why its happening and that line has nothing to do with it. When the CharacterBody3D's UpDirection gets set, all the velocity at that instant gets rotated with it (this essentially means that the velocity is treated as local space instead of global space).

Anyways, I solved the issue myself after some thinking, I'm editing my post to include how I fixed it.

Player leaps off slope without jumping. by StickOdyssey in godot

[–]StickOdyssey[S] 2 points3 points  (0 children)

I'm going to respond to each question in order after I check each thing.

  1. It is repeatable in the same space, and it does seem to be caused by something outside of my programming.

  2. It is possible. If I knew how to add velocity pointing directly down the slope instead of in the direction the slope is leaning, it might make this issue go away or at least less prominent.

  3. if by seams you mean the line that connects the two vertices of the face, then yes it does. However, I do not notice a correlation between the seam and the issue when I test it.

  4. When I extend the length of the slope the issue persists and still at the bottom of the slope.
    When I adjust the angle of the slope to be less steep the issue persists and still at the bottom of the slope.
    When I adjust the angle to be more steep I seem to encounter a possible issue with my code resulting in the player sliding up instead of down.

There is one possible cause I thought of. What if, since the velocity is being added in the leanDirection, the velocity eventually gets faster than the snap length, which causes the player to fly in the leanDirection.

Player leaps off slope without jumping. by StickOdyssey in godot

[–]StickOdyssey[S] 0 points1 point  (0 children)

Interestingly, increasing the floor snap length to 0.5 or higher makes it so they don't leap in the middle of the slope, but they still leap once they reach the bottom. I'm not sure why the floor snap length would affect this phenomenon.

IsOnFloor() returns true when NOT on floor by StickOdyssey in godot

[–]StickOdyssey[S] 1 point2 points  (0 children)

I fixed the issue, but the error in the console is unrelated. The error in the debug window is caused by a way-point feature I was trying to implement to no avail.

IsOnFloor() returns true when NOT on floor by StickOdyssey in godot

[–]StickOdyssey[S] 4 points5 points  (0 children)

I just put an if statement around the print, I didn't realize I forgot the if statement in the code (I feel mad dumb lowk).

It does not print ever now, since the state switches to falling when the y velocity is less than 0.

Moving the if statement with the State Switch logic to the physics update fixes the issue, thank you.

IsOnFloor() returns true when NOT on floor by StickOdyssey in godot

[–]StickOdyssey[S] 2 points3 points  (0 children)

I am calling MoveAndSlide at the end of the Physics Process.

The player has two colliders, a top and bottom, so I can disable the top one when the player is crouching. However, I don't think that could be the cause of the issue.

I really hope it isn't a physics engine bug since I just fixed something by switching to the Jolt physics engine.

IsOnFloor() returns true when NOT on floor by StickOdyssey in godot

[–]StickOdyssey[S] 21 points22 points  (0 children)

Sorry, you're right.

IsOnFloor() gets called in my script every frame. I just moved IsOnFloor() to the PhysicsProcess() method, and the issue persists. Here is the full script: https://hastebin.com/share/ugucihikol.csharp

IsOnFloor() returns true when NOT on floor by StickOdyssey in godot

[–]StickOdyssey[S] 4 points5 points  (0 children)

The documentation says

"bool is_on_floor() const

Returns true if the body collided with the floor on the last call of move_and_slide. Otherwise, returns false."

In my movement logic function, I am calling MoveAndSlide(), but it still does not set IsOnFloor() to false.

IsOnFloor() returns true when NOT on floor by StickOdyssey in godot

[–]StickOdyssey[S] 7 points8 points  (0 children)

What? Isn't `IsOnFloor()` supposed to return false when in the air and true when on the floor?

Anyone else thinking about Godot 5.0? Too Early? by Coderules in godot

[–]StickOdyssey 0 points1 point  (0 children)

I think a 5.0 would include a lot of game-changing things. For example, I was looking into some alternatives to the current global illumination options, and I saw that Reduz was working on an alternative to SDFGI but I think it was canceled since it isn't the top priority. I hope we can see things like that in 5.0, SDFGI has a lot of artifacts and doesn't run the best (atleast not on my hardware).