object position

i have a two object on my server and i can controll it but the proplem only one object i can see her moves in the client
the objects are “Server” and “Cube”

there are’t any errors in terminal but i don’t know what’s the wrong ?

Attachments

test.blend (363 KB)

You need to become more familiar with programming before you attempt to modify this code. Networking is particularly difficult, and it needs at the absolute bare minimum an understanding of the programming language you intend to use.

For example, in these scripts you’ve effectively added the line “some_obj = scene.objects[‘obj_name’]”. Now what? What do you expect that to do? Do you think the script will automatically know what you want to do with it?

I suggest you try and learn some basic Python programming examples, and build an understanding of how it works, until you develop the “programmer mindset” - where you solve the problems you encounter for yourself. There will be times you need some help, but those will usually be obscure APIs, or more general design pattern questions.

sorry im noob and not good in english
you are right i added a code but when i move the “Cube” object the “Server” object move can you check that :3

Attachments

test.blend (367 KB)

In general this file is no good setup.

What do you expect an object that is called Server (or Client) is supposed to do?

Does it mean they establish a connection (client calls server)?

What happens after the connection is established?

What object should communicate with what other object? And should does it say? What should happen after communication?

Yes, you can have a single application that acts both as client and server at the same time, especially for testing. The questions remain the same.

I need to know:
A) what object sends what data to what other object?
B) what should the other object do with the received data?

I can see you wrote such code several times:


try:
	Data, SRIP = GameLogic.sClient.recvfrom(1024)
	UPData = pickle.loads(Data)
	PosServer = [UPData[0],UPData[1],UPData[2]]
	Server.worldPosition = PosServer 
except OSError:
	pass		

A) it is a lot of code replication
B) it mixes business code and framework code together

Why is A) a problem? Imagine you need a change in the communication works … now think about how much work it is to update all these code locations.

How to solve it:

  • place replicated code into a framework (function/module/package).

Why is B) a problem? And what is business and framework code?
Your business is that you want to copy the position of an object (master) to another object (slave).
Your framework transfers the necessary data.

Without network your framework would be just a variable e.g.


position = master.worldPosition 
slave.worlPosition = position

it is so easy that you do not even think about it. But what if the slave is not available at that time?

then you need a frame work to carry the position to the slave.


position = master.worldPosition 
transferPosition(position)


position = receivePosition()
slave.worlPosition = position

You see the business (copying position) is separated from framework. You do not even know how transferPosition() and receivePosition() work.

It could be this:


storage = {}
def transferPosition(position):
   storage["position"] = position

def receivePosition():
   return storage["position"]

or this


def transferPosition(position):
   try:
      ...
      server.sendTo(pickledPosition, ...)
   except OSError:
...


def receivePosition():
   try:
      ...

I hope you get the idea

the Client object are connected with the client.py script and server object and cube object are connected with server.py what i want to do is to controll multi objcts from the server screen when i click “F1” i get acces to server objects controller and that’s move and seeing the moves in the client screen but with a proplems the blue cube “Server” object disapper

A) what object sends what data to what other object?
-servers.py and secondob.py sending position when i click controller buttons from server screen to client screen
B) what should the other object do with the received data?
-other object should move

idid’t understand what you mean "copy the position of an object (master) to another object (slave) "
i just want to controll multi objects from server screen and sending positions to client screen

that’s are my last code edit and i will upload video
to controll the white cube from server screen press w and the server cube press arrows

Attachments

test.blend (367 KB)

the proplem video

guys ???

:(((((((((((((((((((((((