Creating objects bulets,towers,boxes in the game "word""

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
Morph899
Posts: 4
Joined: 04 May 2012, 17:19

Creating objects bulets,towers,boxes in the game "word""

Post by Morph899 »

He Everyone,

I am new in this forum, i am trying some cool features with smartoxserver and alternativaplatform. I just came up with an idea to create objects in the 3d enviroment that everyone can see example a Sprite3d bullet or putting a turret to the sceen etetc. How can i achieve that thing? How will in sfs the object syncronised? Can anyone show me some examples about that? Thank you very much!

Good Day!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Creating objects bulets,towers,boxes in the game "word""

Post by rjgtav »

Hi.
I suggest you to check the Unity Examples, to better understand how to integrate SFS2X with the 3d environment:
http://docs2x.smartfoxserver.com/Exampl ... troduction
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Morph899
Posts: 4
Joined: 04 May 2012, 17:19

Re: Creating objects bulets,towers,boxes in the game "word""

Post by Morph899 »

Thans for answer. Am i have a 3d enviroment where players moving jumping on the x,y,z my problem is creating objects example droping my weapon to the ground that everyone can se or pick up.

Edit: I asume that a droped item is not an NPC than what is it? How can i create a player created object?:) Thank you for help!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Creating objects bulets,towers,boxes in the game "word""

Post by rjgtav »

Well, maybe you could use an SFSObject as a RoomVariable which would store all the objects that had been dropped, but this variable would only be used by the users that were joining the room. For the other users that are already in the room, you simply use a ObjectMessageRequest to send the object information (id, position, etc.).
Of course the best option would be to control all the game from the server, and so you would store the dropped objects in a list in an Extension.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Morph899
Posts: 4
Joined: 04 May 2012, 17:19

Re: Creating objects bulets,towers,boxes in the game "word""

Post by Morph899 »

Hm. I'm trying to shoot a bullet with sfs.objectmessage but i havent found any example about it:

Code: Select all

protected function onRightClickNow(event:MouseEvent):void
		{

sfs.addEventListener(SFSEvent.OBJECT_MESSAGE, onObjectMessage);

	
			bullet=new Bullet()
			bullet.x = myplayer.x
			bullet.y = myplayer.y
			bullet.z = myplayer.z+50
			
			bulletDirection.x = 100*Math.cos(camera.rotationX + (Math.PI/2)) * Math.sin(-camera.rotationZ);  
			bulletDirection.y = 100*Math.cos(-camera.rotationZ) * Math.cos(camera.rotationX + (Math.PI/2));  
			bulletDirection.z = 100*Math.sin(camera.rotationX + (Math.PI/2)); 
				
			scene.addChild(bullet)
			bullet.registerCollisionObject(scene);
			
			
		[b]	var dataObj:ISFSObject = new SFSObject();
			dataObj.putInt(bullet.x, myplayer.x);
			dataObj.putInt(bullet.y, myplayer.y);
			
			sfs.send(new ObjectMessageRequest(dataObj));[/b]

}

	private function onObjectMessage(evt:SFSEvent):void
		{
	//Dont know how to describe this event

		}

How will other see my object created and moving?
Morph899
Posts: 4
Joined: 04 May 2012, 17:19

Re: Creating objects bulets,towers,boxes in the game "word""

Post by Morph899 »

Pf. Made it in 10 minutes...:D
Thanks anyway:)
Post Reply