Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Captain Pike
Jul 29, 2003

I am trying to write a (simple) multiplayer server in C#.

From reading various tutorials and articles, I have cobbled together a server which lets multiple clients connect, send, and receive messages via UDP.

(The server is for an action game that requires timely messages)

I have recently read an article which states that while UDP should be used for most messages (such as player movements) TCP should be used for very important messages, such as player-deaths. (UDP messages aren't 100% guaranteed. If a player gets killed, but never gets this message, he will still be wandering around the map)

I do not know how to use both TCP and UDP.

In addition, all of the low-level networking details are very confusing to me. (non-blocking sockets vs threads, ports, IPs, etc).

Questions:

1. Does an open-source game server exist?
2. Are there any good books that will help me?
3. Should I start an open-source game server project?

Captain Pike fucked around with this message at 09:48 on Mar 10, 2008

Adbot
ADBOT LOVES YOU

Captain Pike
Jul 29, 2003

Unity is kind of driving me nuts. :( I have programmed several games before, and Unity's WYSIWYG nature is alien to me. :(

I wish to change the texture of an object, in C# code. Google tells me that I am meant to do this:

code:
public class MyButtClass : MonoBehaviour {

	Texture myAssTexture;

	void myTushyFunction()
	{
		myGameObject.renderer.material.SetTexture("_MainTex", myAssTexture);
	}
}
Google further states that I am meant to assign a texture asset to 'myAssTexture', in the 'Inspector'.

The Problem:

- My game consists of several classes. Only ONE of my classes has an 'Inspector'. This is a class I have named 'Main.cs'. I have dragged this class into my Main Camera, in the Inspector. I did this because Unity apparently will not let me write code until I 'drag' a code file onto a physical object on the 'stage'.

- I have no objects on the 'stage', other than a camera and a light. Everything is created dynamically.

- The only 'Inspector' I have is on the Main Camera. This class file represents the game entry point. [Main.cs]. I do not want to assign my dynamic texture values to 'Main.cs'. I have seven textures for a particular game object. It would make far more sense to assign and use these texture values in the class which represents the relevant game object. Furthermore, I would not be able to reference texture variables assigned in Main.cs, from my game object class instance, unless I passed a reference of my 'Main.cs' instance, into my game object class instance, which would be insane.

- The game object that will use these textures is a 'prefab'. This prefab DOES have an Inspector, but the Inspector does not appear to have a place for scripts to be added. I have a class named 'Block.cs' that serves as a wrapper for the game object. This class contains variables and logic, as well as a reference to the prefab instance. Within THIS class is where I would love to store the seven texture references. However, I can find no way to access an 'Inspector' on a class file. :(

How am I meant to assign texture files to texture variables? Must I assign all such values 'globally', in my 'Main.cs' file? Am I meant to plop 'dummy' objects onto the 'stage', for the sole purpose of overcoming Unity's inability to reference project assets in code?

Why can't I reference project assets in code? (Note: I found a StackOverflow answer which states that one can reference project assets by name, but doing so is 'bad' because of something called the 'atlas'.)


(I apologize for sounding like an angry rear end in a top hat. :( I do like Unity very much. I am just very frustrated by what appears to be a large and 'backward' departure from traditional game programming.)

Captain Pike fucked around with this message at 07:47 on Dec 13, 2014

Captain Pike
Jul 29, 2003

xgalaxy posted:

any tutorials you read that show how to do something the editor-centric way there is a way to do it the code centric way as well. There is just a lot less tutorials showing that stuff because it doesn't make for pretty pictures in a blog. You have to do manual digging through the rather lovely Unity documentation, unfortunately.

Also Pro tip:
- People who say not to do something in code and do it in editor because "its bad" are stupid and you should ignore them. Aside from a very minuscule amount of stuff there is nothing you can do via the editor that you can't also do via code.

Thank you VERY much for your informative post!

It is also nice to hear someone acknowledge the Unity documentation/community problem.

Typical Unity Tutorial:

[YOUTUBE VIDEO]

"HEY YOUTUBE WHAT'S UP! THIS IS J-DUB AGAIN BACK AT YA! SUBSCRIBE AND FAVORITE! Let's drag a little dog into the scene, then make the dog wag its tail without ever writing a single line of code! Isn't code stupid? Programming is too hard! We're all game programmers now!!!"

Programmer: "Ok, but how would I make an Asteroids game? Do you expect me to manually place every asteroid into the "scene", and then do this for every asteroid that might appear in the game, and then for every single level? Like hundreds of asteroids sitting off-screen or something??

Tutorial Guy: [I don't knooooowwwwwww!!!!! JavaaaaaaScript noooodeeeeeeejsssss html55555555555 - rides away on razor scooter]


Edit:

quote:

You sound like you want to do as much as possible via code and avoid the editor centric approach, so a couple of tips:

I am willing to anything that make sense. :)

Many years ago, I used a Flash timeline and stage, so I am not a complete autist. :)

(Though I quickly learned how to get the gently caress away from the Flash IDE all together, and use code, like a sane person.)

While it WAS possible to assign weird little scripts to nested Movie Clips, that were nested into the Flash timeline, it was loving HORRIFYING if one had to debug such an abomination. There is a reason that we separate logic from assets. We use proper classes now, and in good IDEs.

However, if I am meant to drag some global dummy 'Asset Class' onto the 'scene', then individually drag assets into 'slots', then I will do it, if it makes the game run better on target platforms.

My problem with the "Inspector-Drag" approach is that if assets change (Like texture files, .3DS files, Sound files, various shader textures, etc), then manually finding the correct asset in a massive GUI library, then dragging each of what could be tens or hundreds of items into various 'slots' seems like a nightmare. Then add in the concept of scope and refactoring, or God-forbid loading dynamic assets from a server. Actual games are complex sets.

I will follow your advice, and learn how to load assets dynamically. In the development of any 'game', the models, textures, and sounds, fonts, and EVERYTHING else are going to change MANY times. It would be completely loving idiotic to manually assign "scripts" to the individual assets.



Captain Pike fucked around with this message at 16:20 on Dec 13, 2014

Captain Pike
Jul 29, 2003

I am writing my first Unity 3D game. I wish to tween (animate) objects at various times, for aesthetic reasons. (The objects don't need collision detection, for example).

In ActionScript or JavaScript, I was able to do easy tweens with function calls such as: tween(ObjectToMove, duration, newXYZ, easing, onCompleteFunctionToCall);

Unity does not appear to offer such a mechanism, so I have been forced to construct an enormous switch statement within the Update() function. For example:

code:

Update()
{
    switch(movementState){

      case 0: 
            if (object.x < 50){
                 object.x + =1;
           }else{
                 movementState = 1;
         }
         break;
       }
       case 1: 
            if (object.y < 50){
                 object.y + =1;
           }else{
                 movementState = 2;
         }
         break;
        }
	.........
   }

}
This is all kind of awful. :(

I see that someone has made their own Tween() function, but I do not know if it is any good. http://itween.pixelplacement.com/index.php

Does anyone have suggestions for these kinds of simple object movements?

Captain Pike fucked around with this message at 09:32 on Feb 1, 2015

Captain Pike
Jul 29, 2003

I have a question about Bitmap Fonts!

To make attractive bitmap fonts in the past, I have:

1. Choose a fixed-width font. (So I don't have to deal with kerning)
2. Assemble all characters into a grid within Photoshop.
3. Apply my cool colors, gradients, effects, etc.
4. Save the whole thing as a texture/image.
5. Write something in my game code that shows the correct grid-cell-character(s), at the correct X/Y, so that words are formed.

I am about to do this again in Unity.

However, am I restricted to fixed-width fonts? Is there like a "bitmap font" library or standard that I could use, AND apply cool gradients/effects to my text in Photoshop?

EDIT: Yes I can! I can use BMfont http://www.angelcode.com/products/bmfont/ to generate the grid PNG and edit it in Photoshop!

Captain Pike fucked around with this message at 01:07 on Feb 22, 2015

Captain Pike
Jul 29, 2003

Pollyanna posted:

I imagine a collection of Maps that are all made of an n-by-m 2D array of Tiles.

would a Map object basically have a nested array of Tile objects

This is generally how it is done, yes. You would make a 2D array of 'Tile' class objects. Each Tile object would have a 'column', a 'row', an x/y, an ID number, and any other information you wish to store, such as "this tile has water in it".

Pollyanna posted:

the Player would be "in" one of those Tiles.

while one of those Tile objects has a Player in it? How would you handle the Player moving from one tile to another? Would it be a method on the Player, the Tiles, or the Map?


To identify which Tile the user is "in", one simply compares the player's x/y to the number of columns/rows of the tile grid, and the Tile width/height. Where you store this code (in the Player class, Tile class, or Game class) is entirely up to you. I usually have a Grid class that stores the 2D Tile array, and I do all of my Tile computations in it. For example: Grid.getTileFromPosition(x, y) - Which returns a Tile object.

Moving of the actual player I personally put in the 'Game' class, but you could do it on the Player class.

There is no "right" way, but one thing to consider which class to put all of these things in: Will the code need to know information about *other* class objects? For example, if you put a given function into the Player class, will this code need to iterate over all of the Tiles? If so, it would probably be better to put such code in a 'parent' class, such as Game. This would be better than storing a copy of the tile grid array within the Player class object. (And the score variable, and the sounds, etc, etc)

Captain Pike fucked around with this message at 04:27 on Feb 22, 2015

Adbot
ADBOT LOVES YOU

Captain Pike
Jul 29, 2003

I have made my first animation via Unity 5's Animation Window. However, the animation loops forever. I wish the animation to simply play once. I can't seem to find a "loop" checkbox anywhere, nor am I able to figure out how to add a 'Stop" event frame. :(






edit:




\/\/\/\/\/ THANK YOU!!!!! It never would have occurred to me that the "animation" I created within the image had an asset of its own!

Captain Pike fucked around with this message at 20:00 on Jul 6, 2015

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply