Confusing question

Hi,

I got a problem here. I dont know how to fix it

need help~

my code here:

this is from client

[java]

private class MyMessageListener implements MessageListener<Client> {

private Message message;

private Vector3f position = new Vector3f(3f, 20f, -8f);

@Override

public void messageReceived(Client source, Message m) {

if (m instanceof Messager) {

Messager myMessage = (Messager) m;

if (myMessage.getText().equals(“New Client connected”))

{

fakePlayer = new FakePlayer(subNodeOne, assetManager, bulletAppState, animControl, skeletonControl, animChannel, position);

fakePlayer.createFakePlayer();

fakePlayer.createFakePlayerAction(“Dance”);

sendMessage(new PostionMessage(sinbad.getLocalScale()));

}

}



if (m instanceof PostionMessage)

{

System.out.println(“got message from client1”);

fakePlayer = new FakePlayer(subNodeOne, assetManager, bulletAppState, animControl, skeletonControl, animChannel, position);

fakePlayer.createFakePlayer(); // error here

fakePlayer.createFakePlayerAction(“Dance”);

}

}

[/java]

When I run the server and then client#1 and client#2. client#2 could receive messege “got message from client1” but it shows an error on

[java]fakePlayer.createFakePlayer();[/java]

this is my fakePlayer class and createFakePlayer method:

[java]



public FakePlayer( Node rootNode, AssetManager assetManager, BulletAppState bulletAppState,

AnimControl animControl, SkeletonControl skeletonControl, AnimChannel animChannel,Vector3f position) {

this.rootNode = rootNode;

this.assetManager = assetManager;

this.bulletAppState = bulletAppState;

this.animControl = animControl;

this.skeletonControl = skeletonControl;

this.animChannel = animChannel;

this.stateManager = stateManager;

this.name = name;

healthPoint = 100.0;

this.position =position;



}



public void createFakePlayer() {

fakePlayer= (Node) assetManager.loadModel(“Models/Sinbad/Sinbad.mesh.xml”);

fakePlayer.setLocalScale(0.3f);

fakePlayer.setLocalTranslation(position);





CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(0.7f, 1.5f, 1);

fakePlayer_phy = new CharacterControl(capsuleShape, 0.2f);

fakePlayer.addControl(fakePlayer_phy);

fakePlayer_phy.setGravity(10f);

fakePlayer_phy.setViewDirection(new Vector3f(-2f, 0, 0));

bulletAppState.getPhysicsSpace().add(fakePlayer);

rootNode.attachChild(fakePlayer);



//add sinbad’s swords

SwordR = (Node) assetManager.loadModel(“Models/Sinbad/Sword.mesh.xml”);

SwordL = (Node) assetManager.loadModel(“Models/Sinbad/Sword.mesh.xml”);

skeletonControl = fakePlayer.getControl(SkeletonControl.class);

Node swordR = skeletonControl.getAttachmentsNode(“Sheath.R”);

swordR.attachChild(SwordR);

Node swordL = skeletonControl.getAttachmentsNode(“Sheath.L”);

swordL.attachChild(SwordL);



}

…[/java]

I just want to client#2 see client#1(make client#1 be visible) when client#2 connects to server.

I might be wrong at the beginning…



Need help~~

[java]if (m instanceof Messager) {

Messager myMessage = (Messager) m;

if (myMessage.getText().equals("New Client connected"))

{

fakePlayer = new FakePlayer(subNodeOne, assetManager, bulletAppState, animControl, skeletonControl, animChannel, position);

fakePlayer.createFakePlayer();

fakePlayer.createFakePlayerAction("Dance");

sendMessage(new PostionMessage(sinbad.getLocalScale()));

}

}[/java]

these things above work well and I think they r the exactly the same with below;

[java]if (m instanceof PostionMessage)

{

System.out.println("got message from client1");

fakePlayer = new FakePlayer(subNodeOne, assetManager, bulletAppState, animControl, skeletonControl, animChannel, position);

fakePlayer.createFakePlayer(); // error here

fakePlayer.createFakePlayerAction("Dance");

}[/java]



but above part works well. below doesnt…

OK I got it. should use enqueue(new Callable()