Pages: 1
Topic closed
~My Main Point~
Hello!
I'm making this game but I don't know how sensor connections work in relation to each other.
I've looked at (some parts) in the forums, and even experimented myself, but I still don't understand what responses the host gets and the responses clients get (with sensor connections) in different situations (when there is more than one client OR when there is just one).
If you could make a diagram explaining how they get responses in relation to each other it would be great! If you can explain the answer in clarity, that's fine too. (But I'd prefer a diagram).
Also, can I make one project universal? (see notes)
I already know the mesh basics, it's just this I don't know.
~My Objective~
I was hoping to have one host and three clients.
So, one host project, and one client project if all goes well.
~Conclusion and Notes~
In the beginning I planned to make them all the same (one universal project with modes built-in), but does that even work?
If I don't figure out how this works, I'll end up making my game 2 player.
Offline
Basically, when you update one sensor from one client, you update the same sensor for all the projects connected to the host.
Host has 3 clients: Host, C1, C2, C3. C1 sends Host: sensor-update "x" 1. Host then sends: sensor-update "x" 1 to everyone else.
So with what you want to do, you probably want to assign the clients specific sprites and variables to update.
Basically how it works: You start up the host, which has a player_count of '0'. Then a client starts up and sets its player_number to '0' then connects, it broadcasts "New User" or something then the host updates player_count to (player_count + 1) then broadcasts "New User; Confirmed" and when the client receives the broadcast, it first checks if it looks at the current player_count and if it's already set. If it is, it ignores the rest, but if it isn't set (it's 0) then it looks in the sensor-value block for player_count and sets player_number to that number and based on that number, you can choose which variables it modifies.
Example:
C1 connects, Host assigns player_count to '1', and then C1 sets its player_number to player_count (which is '1') and then modifies only variables p1x, p1y, p1 etc. ; C2 connects, Host assigns player_count to '2', and then C2 sets its player_number to player_count (which is '2') and only modifies p2x, p2y, p2 etc.
It still requires creating all the variables for each player, but this is a way to keep clients separate so they don't accidentally move other players. You can still modify all the player positions, because of how mesh was designed, but it's a solution for games you may want to play together with friends.
An example of something that uses this technique is my Triangle Racing game. It uses Panther though.
Offline
Magnie wrote:
Basically, when you update one sensor from one client, you update the same sensor for all the projects connected to the host.
Host has 3 clients: Host, C1, C2, C3. C1 sends Host: sensor-update "x" 1. Host then sends: sensor-update "x" 1 to everyone else.
So with what you want to do, you probably want to assign the clients specific sprites and variables to update.
Basically how it works: You start up the host, which has a player_count of '0'. Then a client starts up and sets its player_number to '0' then connects, it broadcasts "New User" or something then the host updates player_count to (player_count + 1) then broadcasts "New User; Confirmed" and when the client receives the broadcast, it first checks if it looks at the current player_count and if it's already set. If it is, it ignores the rest, but if it isn't set (it's 0) then it looks in the sensor-value block for player_count and sets player_number to that number and based on that number, you can choose which variables it modifies.
Example:
C1 connects, Host assigns player_count to '1', and then C1 sets its player_number to player_count (which is '1') and then modifies only variables p1x, p1y, p1 etc. ; C2 connects, Host assigns player_count to '2', and then C2 sets its player_number to player_count (which is '2') and only modifies p2x, p2y, p2 etc.
It still requires creating all the variables for each player, but this is a way to keep clients separate so they don't accidentally move other players. You can still modify all the player positions, because of how mesh was designed, but it's a solution for games you may want to play together with friends.
An example of something that uses this technique is my Triangle Racing game. It uses Panther though.
Thank you Magnie!
Offline
miniluigi008 wrote:
Thank you Magnie!
Your welcome. Does that solve your issue?
Offline
You can also check out the Wiki: http://wiki.scratch.mit.edu/wiki/Catego … Networking is a collection of networking articles (which I have contributed significantly to —
).
Offline
Magnie wrote:
miniluigi008 wrote:
Thank you Magnie!
Your welcome. Does that solve your issue?
![]()
It solves my problem, although I still don't know how the client and host sensor connections are received in different situations.
Offline
Hardmath123 wrote:
You can also check out the Wiki: http://wiki.scratch.mit.edu/wiki/Catego … Networking is a collection of networking articles (which I have contributed significantly to —
).
![]()
I'll check it out.
Offline
Hardmath123 wrote:
You can also check out the Wiki: http://wiki.scratch.mit.edu/wiki/Catego … Networking is a collection of networking articles (which I have contributed significantly to —
).
![]()
Cool, but not what I wanted. It's cool, and some of those are good for me (because I use Xcode so I might try out the mesh example later.) But, it doesn't explain what answer projects get through sensor connections in different situations. Or at least, tell me the answer straightforward. (I may have overlooked some stuff while I was browsing.)
Offline
All the clients that are connected will receive any update from a global variable. So if you have a variable named 'player_count' on Host, then you set it to '1', for everyone connected, 'player_count' will show up in the sensor-value block as '1' (except for the host, since it doesn't update it client-side). But if you have a variable set for 'Only This Sprite' then it won't show up in the sensor-value block. All broadcasts are received on all projects.
In Scratch 1.3, nearly everything done on Scratch would be sent to the connected program. (Green flag clicks, stop flag clicks, etc.)
Offline
Magnie wrote:
All the clients that are connected will receive any update from a global variable. So if you have a variable named 'player_count' on Host, then you set it to '1', for everyone connected, 'player_count' will show up in the sensor-value block as '1' (except for the host, since it doesn't update it client-side). But if you have a variable set for 'Only This Sprite' then it won't show up in the sensor-value block. All broadcasts are received on all projects.
In Scratch 1.3, nearly everything done on Scratch would be sent to the connected program. (Green flag clicks, stop flag clicks, etc.)
Okay, thanks for that. One last question. What happens if a variable is used by the host, and client(s)? That's the last one and this is solved! Or at least, all of my troubles are.
Offline
Host updates 'player_count' to '1'. Client sees '1' for 'player_count' in the sensor-value block. Client updates 'player_count' to '2'. Host sees '2' for 'player_count' in the sensor-value block, but 'player_count' variable is still set as '1'.
Does that make sense?
Offline
Magnie wrote:
Host updates 'player_count' to '1'. Client sees '1' for 'player_count' in the sensor-value block. Client updates 'player_count' to '2'. Host sees '2' for 'player_count' in the sensor-value block, but 'player_count' variable is still set as '1'.
Does that make sense?
Yup. I guess that's it. Is there a way to close a topic? Or do I just leave it alone?
EDIT: Nice Tri-force by the way. ^.^
Last edited by miniluigi008 (2012-07-04 22:59:00)
Offline
miniluigi008 wrote:
Magnie wrote:
Host updates 'player_count' to '1'. Client sees '1' for 'player_count' in the sensor-value block. Client updates 'player_count' to '2'. Host sees '2' for 'player_count' in the sensor-value block, but 'player_count' variable is still set as '1'.
Does that make sense?Yup. I guess that's it. Is there a way to close a topic? Or do I just leave it alone?
EDIT: Nice Tri-force by the way. ^.^
Just click report and ask for the topic to be closed. That is probably that best way to get a topic closed.
Offline
miniluigi008 wrote:
Magnie wrote:
Host updates 'player_count' to '1'. Client sees '1' for 'player_count' in the sensor-value block. Client updates 'player_count' to '2'. Host sees '2' for 'player_count' in the sensor-value block, but 'player_count' variable is still set as '1'.
Does that make sense?Yup. I guess that's it. Is there a way to close a topic? Or do I just leave it alone?
EDIT: Nice Tri-force by the way. ^.^
As Nathan said, just report it to be closed.
Thanks.
Offline
Magnie wrote:
miniluigi008 wrote:
Magnie wrote:
Host updates 'player_count' to '1'. Client sees '1' for 'player_count' in the sensor-value block. Client updates 'player_count' to '2'. Host sees '2' for 'player_count' in the sensor-value block, but 'player_count' variable is still set as '1'.
Does that make sense?Yup. I guess that's it. Is there a way to close a topic? Or do I just leave it alone?
EDIT: Nice Tri-force by the way. ^.^As Nathan said, just report it to be closed.
![]()
Thanks.![]()
Um... Can I view this again if it's closed?
Offline
miniluigi008 wrote:
Magnie wrote:
miniluigi008 wrote:
Yup. I guess that's it. Is there a way to close a topic? Or do I just leave it alone?
EDIT: Nice Tri-force by the way. ^.^As Nathan said, just report it to be closed.
![]()
Thanks.![]()
Um... Can I view this again if it's closed?
Yes, you can.
Offline
Closed by request.

Offline
Topic closed
Pages: 1