How do I use On Left button released in multiplayer

Get help using Construct 2

Post » Sat Jun 27, 2015 11:25 pm

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.
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Sun Jun 28, 2015 9:26 am

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.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Sun Jun 28, 2015 1:37 pm

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.
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Sun Jun 28, 2015 2:24 pm

I applied a similar concept here for movement: viewtopic.php?f=147&t=148958

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
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Sun Jun 28, 2015 3:07 pm

Thanks Lennaert.

I will research this you've sent me, and see if I can use it. It looks promising. :)
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Sun Jun 28, 2015 4:33 pm

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.
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Sun Jun 28, 2015 5:00 pm

Haha, good work,

And no worries, you can always ask in the forum here. :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562


Return to How do I....?

Who is online

Users browsing this forum: Sparkz, Yahoo [Bot] and 1 guest