Jump to content

  • Log In with Google      Sign In   
  • Create Account


VildNinja

Member Since 06 Mar 2008
Offline Last Active Sep 17 2014 04:39 PM

#5178429 Physics system for a tilemap scenario.

Posted by VildNinja on 05 September 2014 - 08:01 PM

I would definitely recommend a quadtree. As you mention yourself, most grids would be empty most of the time. Managing linked lists is a lot of work considering the amount of bullets, that will travel several grids, before getting close to any enemy.

 

By using an algorithm with low tolerance for enemies in large areas, you should be able to create mostly enemy free regions where the bullets can travel without checking for collision.

 

That being said, you need a big game before performance should be an issue. Assuming you are using sweep scan with aabb.

 

As an alternative to a dynamic quadtree you could let several cells share a linked list. i.e. 5x5 cells share one linked list = 3600 in a 300x300 map. And no, a linked list with no elements uses very limited space.




#5141113 Is hatred for unity justified?

Posted by VildNinja on 21 March 2014 - 03:31 PM

He does have a point about the initial loading time, even for small scenes. A lot of companies create their own scene exporters in order to create their own loading pipeline.

 

The type of games made in Unity is often a simple physics based platformer. This is because Unity is an amazing tool for creating that kind of games, but no. Just because Unity is inviting (and to some extend does all the work for you) to make that kind of games it doesn't mean you have to create the game like that. A "mistake" a lot of people do is to make their games too physics based, because it is so easy. So to some extend I understands what he is saying, but there are tons of games not like that.

 

No I don't think his hate for Unity is justifiable. If you care about tech then maybe yes, but if you care about games then no.

 

Related: http://blogs.unity3d.com/2012/04/01/semantic-game-builder-interface-to-be-integrated-into-unity/




#5141110 Multithreading synchronization problem

Posted by VildNinja on 21 March 2014 - 03:16 PM

You could add a queue to the thread such that you don't need to synchronize any of the core elements. http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html then you just need to see if anything new has arrived, and then add it to your list from the thread owning the list.




#5140468 Is GameMaker any good?

Posted by VildNinja on 19 March 2014 - 05:37 PM

1) yes they have their own language

6) vlambeer is doing quite well http://www.vlambeer.com

Game maker is a nice tool for 2D games, but it's not gonna land you a job anywhere fancy.. But then again no single engine will do that. Make a super game and take it from there. And for that vlambeer have proved that it works great. Check out ridiculous fishing if you want to see what game maker is great at.


#5139356 Determine the 3d position of this vector

Posted by VildNinja on 15 March 2014 - 07:48 PM


if its 90 degs it seems that C can be on either left or right side according to B position in relation to A.

In 2D yes, but this is 3D. This means that any point on a circle with the radius y around A is a valid point C.

 

Also: Vikings cheer in Valhal whenever people mention the cross product! You might as well learn to use it, it is quite useful in vector math :)

 

Read up: http://en.wikipedia.org/wiki/Cross_product




#5139011 Determine the 3d position of this vector

Posted by VildNinja on 14 March 2014 - 10:39 AM

C = A + Normalize( Cross( B-A, Cross(A,B) ) )  * y;

 

Cross(A,B) is a non-unit "up" vector, normal to AB.

 

B-A is a non-unit vector from A to B.

 

Cross(B-A, Cross(A,B)) is normal to both AB and "up," i.e., points from A to C, normalized to a unit vector for applying the length of the side (y).

Yes, but that's still assuming that C is also in the plane with the normal "up" gretty didn't specify that.




#5138996 Reliable UDP: Correct Order, Error Correction

Posted by VildNinja on 14 March 2014 - 09:50 AM

Ashman72's approach is the right one to follow if you want the in-order + reliable layers added to UDP. But keep in mind that in the case of lost packages you either need to wait for an ack message from the server with a too low sequence number, or resend them often any ways.

 

First case will stall the connection in the same way as TCP does it and second case will send more data.

 

I recommend the second approach where you send unconfirmed messages just in case they should have gone missing.

 

There is a naive and simple way of doing this - the one I explained in my previous comment - If you couple that with Ashman72's approach you'll get relaiable and in-order. Further more you wont need to resend the latest second of messages, but rather just the last few, as you no longer need them as a safety net, but rather for decreasing the likeliness of package loss.

 

Another appoach for this is to append each package by its previous package XOR the package before that:

 

package n => id(n) + content(n) + (content(n - 1) XOR content(n - 2))

 

In that way you can append two packages for the price of one. Afterwards you can easily recreate lost packages, unless three is lost in a row.




#5138850 Reliable UDP: Correct Order, Error Correction

Posted by VildNinja on 14 March 2014 - 12:19 AM

One simple way simple way to solve this, would be to add the latest second of packages to the current package. For a game like this it wouldn't add much overhead.

 

Assuming the game is running at ten or twenty ticks per second and each message is one byte (none, up, down, left, right, place bomb, use ability ...) unless you are planning on adding more than 256 actions one byte should be enough. your total package size will still only be (player id) + (current tick) + (action) * 20 == 28 assuming you use int32 for both id and tick.

 

This means that missed packages wont matter as long as it doesn't happen too many times in a row. But in that case the client has probably left the game.

 

The server should just send the state every tick with every players position and velocity (for client side prediction) and all active/recently exploded bombs.




#5138842 Determine the 3d position of this vector

Posted by VildNinja on 13 March 2014 - 11:30 PM

First of don't use x, y and z for anything but coordinates.. that's just confusing. Call the sides a, b and c or something else.

 

The problem is unsolvable with only two initial points, as this will produce a wheel of possible positions of C around A, remember this is 3D, so there exists infinite directions orthogonal to the vector (AB).

 

If you have an up vector and know that A, B and C are all in the "ground" plane orthogonal to the up vector you can find C:

 

// by taking the cross product between two vectors you get a direction vector that is orthogonal to both (A - B) and up

v = Cross((A - B), up)

// by normalizing the vector v and multiplying with the length of y you scale the direction to the right length

directin = Normalize(v) * y

// you can now easily find C

C = A + direction

 

But this is only if A, B and C is in the ground plane.




#5011826 Tutorials sought

Posted by VildNinja on 17 December 2012 - 03:37 PM

Sounds like you ought to step away from video tutorials, and start reading some :) While they may not be less explanatory, it is way easier for you to skip ahead, once you understand the topic.

Based on my own experience these are good points of entry:
http://lwjgl.org/ Best OpenGL wrapper for Java (I should probarbly not call it the best, since there are a lot of different opinions on this topic, but it is the most used wrapper for comercial use).
http://nehe.gamedev.net/ OpenGL Most of their guides have LWJGL code as well. Otherwise OpenGL is OpenGL regardless of Java or not.
http://www.cokeandcode.com/ A great blog! also the home of the Slick library

Also remember that c++ is not the necessarily the next step. It is some thing that is good to learn at some point, but you can make great games with Java, without knowing any c++.


#5010798 Threads + Concurrency & Weird Issue

Posted by VildNinja on 14 December 2012 - 06:49 PM

Could you provide some code?

Also it almost sounds as if you are creating a thread for each event? And using another thread to activate them? Threads aren't some thing you should create a lot of. They will mostly just give you trouble. If you want to add timed events you should either only have one thread doing it, or even better, add a priority queue in your game loop and perform and remove/reinsert the event at the top of the queue if its time has expired.

But any ways post your code, then I'll take a look at it tomorrow :)


#4985981 Adice for my game project prototype?

Posted by VildNinja on 02 October 2012 - 01:37 AM

That is a lot of questions. rather than answering them all, I'll tell you how I would approach this type of game.
  • You need a grid. I would not place the tiles manually, since that would make it difficult to determine which tiles are connected to which. I would start out with a 2D array of Tile, where Tile is an enum of tile types:
    Edit: aparently <= breaks the code block. So I use (less or equal)..

    [source lang="csharp"]public enum Tile {DIRT, ROCK, WATER, BOMB}; public GameObject dirtPrefab; public GameObject rockPrefab; public GameObject waterPrefab; public GameObject bombPrefab; Tile[][] map = { { DIRT, DIRT, ROCK, DIRT, DIRT }, { DIRT, DIRT, ROCK, DIRT, DIRT }, { DIRT, WATER, BOMB, WATER, DIRT }, { DIRT, DIRT, BOMB, DIRT, DIRT }, { DIRT, WATER, BOMB, WATER, DIRT }, { DIRT, DIRT, ROCK, DIRT, DIRT }, { DIRT, DIRT, ROCK, DIRT, DIRT } } int bombLocations = 3; int bombsToBePlaced = 1; void Start() { for (int x = 0; x < map.Length; x++) { for (int y = 0; y < map[x].Length; y++) { switch (map[x][y]) { case Tile.DIRT: Instantiate(dirtPrefab, new Vector3(x, 0, y), Quarternion.identity); break; case Tile.ROCK: Instantiate(rockPrefab, new Vector3(x, 0, y), Quarternion.identity); break; case Tile.WATER: Instantiate(waterPrefab, new Vector3(x, 0, y), Quarternion.identity); break; case Tile.BOMB: if (Random.Range(0.001f, bombLocations) (less or equal) bombsToBePlaced) { Instantiate(bombPrefab, new Vector3(x, 0, y), Quarternion.identity); bombsToBePlaced--; } else { Instantiate(dirtPrefab, new Vector3(x, 0, y), Quarternion.identity); } bombLocations--; break; } } } } [/source]
  • In the editor you should create a Prefab for each tile type you want, and add them to into the script. The prefabs should be no more than 1x1 in x and z. Now you'll get a map where one bomb is randomly placed on one of the three bomb locations.
  • Next step is to be able to click a tile. Since your tiles are axis aligned on x and z in y = 0, you can easily where the player clicks in your grid:

    [source lang="csharp"]if (Input.GetMouseButtonDown(0)) { Vector3 pos = Camera.main.transform.position; Vector3 dir = Camera.main.ScreenToWorldPoint( new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1)) - pos; float scale = pos.y / dir.y; Vector3 point = pos - dir * scale; int x = Mathf.RoundToInt(point.x); int y = Mathf.RoundToInt(point.z); print("x: " + x + " y: " + y); } [/source]
  • To import the 3D model you should drag it to the scene, create it as a prefab, scale it to the desired size, apply and remove it from the scene, and finally instanciate it from a script.
  • I don't have time to talk about movement now, but I think this should be enough to get you started Posted Image
Edit: split up source block, since it didn't show entire code


#4985717 Adice for my game project prototype?

Posted by VildNinja on 01 October 2012 - 05:29 AM




So i need to make a grid kindof like chess has.

you should use a 2D array for that.


What do you mean?

...
If you make your grid as one big tile with a grid texture (or if you're merging tiles) you can still use the raycast to get the point on the grid that was clicked on and then divide that by your tile width and height to get the tiles position in a 2D array.

Yes that is the approach I would use. That way you can always decide to remove the texture from the big grid, and add your own cubes or tiles as a graphical overlay. But use the single simple plane to maintain the relation between your 2D array and world/input space.

I dont get option to rename scene or script files inside from unity projects view.

Yes you do. If you click the name twice you can rename it.

True.. this is good advice but is it really so much more work to make many planes next to eachother? isnt it possible in some kind of loop?
I dont know yet how big playing field i want or how big each tile should be... that is another thig i must test in this prototype.. so it must be easy to edit how big map and how big tiles.

Yes you can easily write two loops that can instantiate a number of tiles in the scene.
[source lang="csharp"]int width = 10;int height = 10;Tile[][] tiles = new Tile[width][height];for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Instantiate(tilePrefab, new Vector3(x, 0, y), Quarternion.identity); }}[/source]

I don't really understand your directions.. sorry
I know what variable and reference is but I don't understand... if I am standing on a tile how can i click somewhere so it moves to a nother tile? so if i click somewhere that the game can see i clicked within a grid tile (how can i make a grid? i have board to looks like a grid but its just texture that code doesnt know is a grid?

Get a ray from the camera towards the mouse position. Get the x and z coordinates where y hits zero, and cast x and z to integers and plot them into your array (tiles[x][z]). If your characters should walk around like humans, you'll probably need some path finding (A*). If your characters move around like chess pieces you should just use slerp or lerp to move them between the two tiles with a coroutine.


#4985479 Adice for my game project prototype?

Posted by VildNinja on 30 September 2012 - 02:34 PM

I have very advanced complex combat system that is too much complex to have on just paper.
I need to prototype it.

Start of with something you can put on paper. Once you got that working you can think about how to make your idea fit on paper. If you really can't I would suggest you to redesign your idea.

So i need to make a grid kindof like chess has.

you should use a 2D array for that.

IM USING UNITY! and will use c#.

I want it to be in 3d too with isometric or 3rd person camera.

Well first step is to make it top down with no perspective. The difference between that and isometric 3D is one matrix a checkbox and moving the camera. So I see no reason why you should bother with that before you got your grid working.

But I need help with how i will make the play field.

So how do i make this tile based grid? (guessing its coreect lingo.)

You shold take the simple soloution and use ONE plane with ONE texture on top of it. This can be limiting if you want randomized maps or animated tiles. But for now you should just make the game work with one static image.

I want each tile to be seen graphically too.

So i need to have a texture for what each tile looks like with a nice border.
then I import the texture to unity and assign it to material.

then i create a plane that i assign this material for.

Then I will have 1 tile so far.

You got plenty of coding to do right now, so don't bother with this quite yet. You'll have plenty of time fiddleling with the right approach later on, but don't waste time on this now.
Edit: your ONE texture should contain several tiles.

Now what's the best way to create a 3d board tile based grid?

maybe its better to not use plan but instead cube?

Cube or plane really dosn't matter! The best way to create a 3D grid, is to calculate the mapping between mouse clicks and coordinates in your array. Whether you use planes or boxes or teapots for each tile should not be relevant to your logical grid.

ok..
So i want to be able to move my characters from one tile to another by either being able to click on a tile and it moves there or by for example using arrow keys to move one tile ahead.

use on variable to hold a refrence to the selected character. If the variable is empty/null assign it with the next clicked character. Else move the characters logical position to the desired tile, and use a coroutine to animate the movement (with slerp or something).

also, the game i want to make should be multiplayer.
but im newbie at networking.

so i think for the prototype i will just make enemy npc controlled with simple AI?

Figure out a way two people can play the game on one computer. You can always play with AI, but AI is NOT simple! At least not if your game concept can't be written on paper ;)

Also, in unity..
If i have given a name to a file on projects tab like for example a scripts file or a scene file a name..
Is there an easy way to rename it later? because the codes and everything that uses that file will then have the old file name?

Yes Unity takes care of the file name - don't change it from explorer - and Mono Develop or Visual Studio have ways of automatically renaming variables and classes. I think it's on F2 - otherwise just right clcik the variable or class name you want to change, and select rename/refactor in the menu.

Big time thanks to everyone who reply.
This is the best forum.

Hope this is usefull


#4976401 Help me design an MMO-ish turn-based strategy

Posted by VildNinja on 04 September 2012 - 07:01 AM

You keep using that word MMO, but I'm not sure you know what it means.

The simplest solution I can think of, is to make the networking entirely http based. That way you can code the account system in php connected to a MySQL db or whatever server side language you prefer. And for a turn based muiltiplayer game with no more than 32 players at a time, you could just as well code the game logic in php.

That way every player just needs to connect to the server every second to check for updates.

Your updates could contain some json or xml with info on the recent moves/actions and maybe the entire game state, just to verify the synchronization. The update should also let everyone know whose turn it is.

This is no an optimized approach, since every player connects to the server even if there are no new updates. You could write the server using simple tcp sockets for better performance, but I don't think you'll gain anything from that on a 32 players tbs. Any ways code the account/login system in php or other server side language.

Hope this helps :)




PARTNERS