Multiplayer plugin with analog stick of gamepad? Is possible?

0 favourites
  • 8 posts
From the Asset Store
Everything you need to incorporate old school hip hop bangers.
  • I want to ask already if what I'm trying to do is possible or not, (before continuing to try in vain).

    In short, I studied the multiplayer plugin a bit and looked at the example of the tutorial (the fourth), this: https://editor.construct.net/#open=multiplayer-game

    and I would like to know if it is possible to do the same thing but making each player use a gamepad.

    And use the analog stick to move the character at a precise angle. I already tried like this: Peer -> set inputs to -> floor(angle(0, 0, Gamepad.Axis(0, 0), Gamepad.Axis(0, 1))) and then Multiplayer -> set client input state to value Peer.inputs

    but it doesn't work and I can't understand why... someone help me?

  • and then Multiplayer -> set client input state to value Peer.inputs

    And then what do you do with it?

    Input state is just a value, it doesn't matter if it's from a keyboard, gamepad, mouse or any other input method. You need to translate this value to character movement. Perhaps something like this:

    Player move (speed*dt) pixels at angle (Multiplayer.PeerState(Player.peerid, "stick_angle"))

    Check out the official Pong example.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > and then Multiplayer -> set client input state to value Peer.inputs

    And then what do you do with it?

    Input state is just a value, it doesn't matter if it's from a keyboard, gamepad, mouse or any other input method. You need to translate this value to character movement. Perhaps something like this:

    Player move (speed*dt) pixels at angle (Multiplayer.PeerState(Player.peerid, "stick_angle"))

    Check out the official Pong example.

    yes, there are other events. Here is a screenshot of the entire event sheet. There aren't so many. If you want I can also share the project, but I think you should have a gamepad.

    With these events, everything works for the host. But for the Peer if I enable the event 16 enable local input prediction... seems to work fine, but what happens is that the object keeps moving back to its original position.

    maybe I'm making a mistake or this is not the correct method, what is it?

    [update] I noticed that the object moving back error only occurs when I try to move it up (for Peer preview) then moving the analog stick between 0 and -180. However, if I move it between 0 and 180 the object seems to move correctly in that angle.

  • Try increasing the precision in event #2 to "float 4 bytes". 1 byte can only represent numbers between 0 and 255.

  • Try increasing the precision in event #2 to "float 4 bytes". 1 byte can only represent numbers between 0 and 255.

    Thanks. now it works almost completely.

    But there is still a problem, when the stick is positioned to the right (so the value is 0) the problem persists.

    maybe I should change the "inputs" variable to a string?

    ugh I'm really struggling.

    How should I do?

    [update] I changed the "inputs" variable as a string and now it seems to work, but the sprite continues to move even when the stick is not touched, it continues to go in a straight line in the last recorded angle.

  • I don't have much experience with multiplayer plugin. Perhaps with string value you need to check that it's not empty. Add this condition to "For each cars" loop:

    Multiplayer.PeerState(cars.peerid,"inputs") not equal ""

  • I don't have much experience with multiplayer plugin. Perhaps with string value you need to check that it's not empty. Add this condition to "For each cars" loop:

    Multiplayer.PeerState(cars.peerid,"inputs") not equal ""

    your method doesn't work. I think is because the action set client input state "inputs" to value (int(cars.inputs2)) must be a number.

    Now I solved by putting an event below:

    if cars.inputs2="" --> set client input state "inputs" to value 200.

    and instead of your condition I put cars.inputs2 ≠ 200.

    Now it work.

    Anyway thanks. I realized that making multiplayer games is MUCH harder than making local games.

    I'll probably ask for help again

  • Input states can only be values, not strings.

    Did you try seeing input states interpolation to angle instead of none?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)