How do I use On Left button released in multiplayer

0 favourites
  • 7 posts
From the Asset Store
Casual UI Button #3 is a customizable, ready to use desktop and mobile-friendly game UI Asset.
  • Hello!

    How do I use "On Left button released" in multiplayer - for the peer inputs?

    I use the Example for the Multiplayer - real-time game in construct as a starting point when I do my multiplayer games.

    In the Peer-Group where the peer send it's inputs to the host, there is an "On client update" and "peerid = Multiplayer.MyID" - condition. Then below that there's the sub-events that test the condition for an input. For example: Mouse - Left button is down... or Keyboard - Left arrow is down... and so on.

    However I can not choose "On Left button released".

    I'm allowed to choose it though in the Hosts Group.

    I know it's about the way constructs events work and why I'm not allowed as the event-sheet are set up this way in the example. But I would like to know if there's a workaround somehow to be able to use the input-condition "On Left button released"? Should I perhaps try to do it in the common group?

    The only thing I can think of at the moment - to be able to still have something in the inputs in the Peer-Group - is to design some kind of boolean-variable that get set as soon the mouse button is down, and then resets when the button is not. ... And use that somehow.

  • When a peer is holding down a mouse button or is in touch, you set the corresponding inputs variable its bit to 1.

    When you let go, the peer sets the state back to 0.

    This effectively leaves the host with a 1 or 0 for the mousebutton input from the peer.

    So on the host side of things, when you want to recognize a peer holding the mouse, you test if the inputs corresponding to the mouse/touch, is 1. If it is, the peer is pressing the button. If it is not, the peer let go.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello Lennaert, thanks for the reply

    The problem gets tricky this way, cause in my game I need to do things separately on certain conditions with the inputs.

    I'll try explain...

    I have a player that are going to aim something. The way he do it is that he click and hold down the mouse and then drags in a direction.

    What the player see, is a small cross where the mouse-pointer was when he first clicked. ... then he still holds down the mouse and drag in a direction. Then he see a line between the cross, and where he now has his mouse pointer. ... it's kind of drawing a bow and aiming.

    So when I did this game as a single player at first. I used 3 conditions.

    * On Left button clicked - I created the cross, and a line, at the mouse pointer position, and saved the coordinates in a variable.

    * Left button is down - I use the distance to set the width on the aiming-line and also sets the angle pointing towards the cross ( coordinates )

    * Left button is released - the projectile gets shot away.

  • I applied a similar concept here for movement:

    Check my capx near the bottom.

    the lookx and looky variables continuously gets synched.

    when the peer presses and holds the button, it uses the lookx looky as data for the targetx targety.

    This exact same concept can be used to do your aiming.

    while getbit x = 1

    -place the target cursor at the self.targetx,self.targety

    -distance/angle(self.X,self.Y,self.targetx,self.targety) for the width and angle of your line from player to target

    -set boolean armed = true

    getbit x = 0

    boolean armed = true

    -fire

    -set boolean armed to false

  • Thanks Lennaert.

    I will research this you've sent me, and see if I can use it. It looks promising.

  • It worked...

    I couldn't open your capx, cause it was Construct release 208 and I'm currently on 206. I downloaded the 208 and in the meanwhile, while I waited for the download, I tried to solve the problem with your info in your reply. And I got it to work, both for the Host and Peer... This is GREAT thanks.

    ...was a bit tricky as the host and peer update their values a bit different. I got the peer to work instantly, but had to tweak some more with the host.

    Now all I have to do is finish the rest, and actually put in what's gonna happen after they aimed... It's tricky with multiplayer to do stuff, but the more I work on it, the more I'm getting the hang of it. This is my third multiplayer game, and I'm still having problems and getting confused.

  • Haha, good work,

    And no worries, you can always ask in the forum here.

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