Jump to content

  • Log In with Google      Sign In   
  • Create Account

Paragon123

Member Since 02 Oct 2013
Offline Last Active Apr 11 2016 02:09 PM

Topics I've Started

Efficent Tagging

14 March 2016 - 02:32 PM

I am sorry, I am having difficulty articulating the problem I am having, so I hope this doesn't sound like I am rambling.

So I am working on a cascading procedural generation method of sorts... so, assuming I am generating an NPC. First, by looking at the location where the npc is to be generated I choose a race (orc/human/etc) based on the population distribution for the location. Let's say I choose an Orc. The next step is to select the orcs class. So, I would choose from the classes that are tagged with ORC on the white list and not on the black list. Then I can choose a weapon type that is either tagged for ORC or for the Class and not black listed for ORCs or the class.


Another example might be trying to create a gem to add to the loot, first select the race that mined/cut it, then the type of cut they used (different races may prefer different cuts), then the type of material it is made of (Some races or regions are more likely to select particular materials then others) then it's size (Different materials may be more prone to different sizes) then finally based on all that generate a description and value.


The problem I am having is finding an efficient way to tag the records. My only idea currently, is to have two text fields, WTags and BTags and use string finding functions to see if a tag is in the white listed tags (WTags) or the Black Listed Tags (BTags) but a long series of string finding operations seems a bit inefficent.

Data Struct for 2D map with barracades

04 September 2014 - 09:43 AM

So gennerally for 2d tile maps a tile is either passable or impassible...  so an actor can move to any passable adjacent tile.

 

I am looking for a good way to decouple the passablity of a cell from the traversal to/from the cell.

 

Which do you suppose is the best way?

 

1) Each tile contains a value indicating if the passage to the right and bottom tiles are valid. 

    Pro: Requires very little modification to a standard 2d array implementation

    Con: Checking for passage works on different cells depending on direction of travel... i.e to travel right or down you check your current tile, but travel up or left requires checking the destination tile.

 

2) Each tile contains a value indicating the passage to adjacent tiles

    Pro: Can still be implemented using a standard 2d array implementation

    Con: Disabling travel between two tiles requires setting a value on both the tiles (semi-redundant data... semi b/c you could  implement 1 way passages, etc).

 

 3) Use a separate array for tile data and traversal data... in the tile array the data describes the tile, in the separate array the data represents the "wall" between two cells.

    Pro: No data redundancy, consistent mapping

    Con: Requires entirely new map structure with more complex mapping, look up functions...

 

4) Awesome method that I haven't thought of... pro: It may be awesome, con: I didn't think of it yet... 


GameObject State management

07 February 2014 - 10:19 AM

I am trying to use the 2D portion of Unity3D for the first time so I am creating a breakout clone. 

My issue is that the state management is getting decentralized... and I am not 100% certain if it is because a) It has to be, or more likely b) I'm doing something "wrong".

 

I have 4 major game objects, The ball, the paddle, walls, and blocks. The blocks state is simple, it starts at State N and each time the ball collides with it it moves to state N-1, at state N=0 it gets destroyed.

 

The walls and the paddle are also simple as they have only a single state each.

 

The ball is where it is getting tricky..

The ball has three states: Setup, LockedToPaddle and Moving.

It has a public function setState(state) :It's only public so the animation event can see it. SetState only changes to the new state if the new state is a valid state to transition to (For example, attempting to setState(Moving) from setup will not do anything, nor will setState(x) from state x.

When a state is successfully changed, it will also update the state variable in the animator.

 

The animator has an integer parameter State: 1=Setup, 2=lockedToPaddle,3=Moving

Each state has it's own animation, at the start of each animation there is an animation event which calls setState(State). 

The setup state has a transition with a 3 loop exit condition, which moves to LockedToPaddleState

LockedPaddleState has a conditional transition on State=3 to transition to Moving.

Moving has a conditional transition on State=1 to Setup.

 

Further, I have an inputmanager game object with a delegate OnBallFire which triggers when the user presses the space bar. The ball gameobject has a method ball_OnBallFire() which calls setState(Moving)

 

Then In the collision2d method for the ball, if the ball collides with the "deadzone" (the area below the paddle). It calls setState(Setup).

 

As you can see... stateTransitions are made from all over the place... is this normal? Is there a way to centralize the state transition logic? Is it an issue that the animator can update the state, but the state can also update the animator? 

 

 

 


Dealing with multiple scales of player wealth

17 December 2013 - 01:19 PM

 I was thinking about a game that combines RPG with a merchant trading system... the problem I am having though is how to deal with the two completely seperate levels of wealth. On the one hand, they should have a manageable amount of wealth to purchase things such as equipment/upgrades/consumables etc... on the other hand they need large amounts of wealth to do things such as purchase new transports/hire shopkeepers/transporters/farmers/buy property/buy expensive goods/etc.

 It wouldn't make much sense to have two separate currencies, but it if they had the money to purchase expensive items all personal needs would be trivial, but if they only had enough to make personal belongings non-infinite they wouldn't have enough to purchase the expensive items.


ECS - Renderable, Animation, Physics

21 October 2013 - 12:53 PM

I am running into some road blocks attempting to effectively implement ECS methodology. I have a heavy background in OOP, and I think that is really tainting my perspective.

 

According to a lot of the information I have gathered regarding ECS, one of the primary benefits is that each system is supposed to work independently, and also, using components should help avoid memory cache issues since components should be stored in contiguous Memory.

 

 The problem that I am experiencing is the following.

 Given a particular element for which Rendering, Animation and Physics need all be applied there is a particular sub set of information which must be available and synchronized to all systems, while an overlapping subset of information may not require availability and synchronization.

 

 For the rendering system to work it requires a component containing a Sprite, a position and a rotation.

 For the physics system to work it requires a component containing a position, a force and a rotation.

 

The animation system is slightly more complex, as there are three types of animation

  1) Tile: No animation, requires only a sprite

  2) Simple Animation: Loops through a single animation, requires a set of sprites

  3) State Animation: Infers sprite from a state and a TimeInState, requires a State and a set of sets of sprites.

 

So it seems that there is the following portions of data required for the ECS as a whole (not partitioned into components):

   Sprite - Current sprite representative of entities animation

               Rendering system Read

               Animation system Write

 

   Sprites - Complete set of sprites available to entity

                  Animation system Read

 

   State   - Current state of entity

                <Some System> Write

                Animation System Read

 

   TimeInState - How long entity has been in a particular state, to enable mapping to a specific frame of a specific animation

                  <SomeSystem> Write

                  AnimationSystem Read

 

   Position - Both physics position and drawing position (while in an idealized situation they would be equal in actuality they are only tightly coupled through some mapping function i.e drawing Y often equals -physics Y, and physics often work of Center of gravity while rendering works on either top left corner, or center of sprite)

                  Physics system Read/Write

                  Rendering System Read

 

   Rotation - Both physics position and drawing position (similar issues to position, but possible to avoid)

                 Physics system Read/Write

                 Rendering System Read

 

   Force - Physics

                <some system> Write

               Physics system Read

  -----------------------------------------------

As you can see, it becomes a rats nest of inter connectivity destroying the System Independence principle. Also, since each system uses multiple components it also destroys the Contiguous memory access principal as well. Some sources concede that complete system independence is not always possible but the breakage is acceptable as long as the more performance enhancing principal of contiguous memory access is preserved, this is seems would require Data duplication, something that I find great difficulty in accepting as good practice (this may be due to OOP and Database bias). 

 

The animation Components present a new challenge entirely... namely, how to efficiently store jagged arrays in contiguous memory. 

In my particular case it turns out to be a jagged array of jagged arrays. I plan to use a image packing software to create image atlases, the image packing software produces a string->box mapping file so a particular sprite can be located by providing the sprites String formatted Name/Id. Also, since various states may have more or less frames than other states, and since some entities may have more or less states than others you can see that the first jagged array is entity to states, followed by states to frames and finally frames to strings.

 

I suppose the gist of this post is.... ARRRRGGGG, WTF?!?! HELP PLZ!!


PARTNERS