Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


BCullis

Member Since 16 Feb 2007
Offline Last Active May 15 2015 09:58 AM

#5224707 Save/Load High Scores

Posted by BCullis on 21 April 2015 - 10:50 AM

Why can't it just run once?  It's something you only need to do once at the end of a game session.  Certainly no need for including it in every frame.

I'd lean towards sticking it in a static utility function just for ease of editing later.  Then in whichever method handles "what happens when a game is over" you just call over to the score-checking method and shuffle around high score order if necessary.

There's no "one best way" (arguably) to do it, but there are certainly easier-to-maintain ways.  

 

First, just make it work.  Then, if you want and have the time/need, make it work better :)




#5224412 Is Unity3d right for someone like me, mostly doing 2d stuff?

Posted by BCullis on 19 April 2015 - 10:17 PM


Approximately, how many MonoBehaviours go in to, say, a normal mob?

I grabbed a random mob prefab from the current build (since I have it on my home machine right now), here's the component list:

 

Mesh Renderer

Mesh Filter: [none]
Tk 2d Sprite

Tk 2d Sprite Animator

(those four come bundled together, tk2d is a 3rd party sprite handling library we grabbed since the project started before native 2d support really took off)
Audio Collection - our mobs own their sound collections

World Object - base component inheriting GameObject that we use for most in-game world-contextual objects
Character Module - component for anything that has sentience (self-movement and physics mostly)

Sprite Module - Where we control worldObjects' sprite changes (new animation clips/states)

Combat Module - component for any objects that can deal/take damage

Ability Module - component handling our ability system: any kind of "action" a combatant can perform (things like "meleeAttack, fireball, laser, etc")

AIControl Module - lets a tweakable FSM control this object's actions (player character has a playerInput module here instead)

 

And that's it.
All of those components have custom editors (the AI FSM even has its own visual scripting tool we wrote custom) and aren't light on the actual backing code.




#5224090 Save/Load High Scores

Posted by BCullis on 17 April 2015 - 04:35 PM

Exactly.  The dat file had previously serialized out an older version of the struct that held a single integer instead of an array.  As the dat file was external to the program context, nothing updated its internal structure when you changed the code itself.  Deserialize was reading this old data type and choking when your explicit cast said "now populate this array field with this integer".




#5224071 Save/Load High Scores

Posted by BCullis on 17 April 2015 - 03:53 PM

So it's choking on the deserialize line.  Try this: delete the .dat file and see if a newly created one plays nicer with the current code.




#5224064 Save/Load High Scores

Posted by BCullis on 17 April 2015 - 03:14 PM

There should be more information in the Console tab/window, to include the full stack-trace of the error/output (when you select any entry in the Console list, i.e. one left click).  Each entry in the trace should tell you which file it was in for that step, and which line the function call for that step happens at.  Resize the console tab to see more (as the stacktrace content appears at the bottom of the window), or just highlight the whole mess and paste it into a notepad or something to read.




#5224063 Rice Texture Help - Random Rotation on Pattern Fill?

Posted by BCullis on 17 April 2015 - 03:08 PM

So I know that in Photoshop and Sketchbook you can define custom brushes that let you define randomized rotation and spacing of the individual brush image.  Looks like you can do something similar according to this tutorial with Gimp.




#5224043 Save/Load High Scores

Posted by BCullis on 17 April 2015 - 01:27 PM


ArgumentException: Object type System.Int32 cannot be converted to target type: System.Int32[]

"An integer can't be converted to an array of integers"
Which line is throwing that error?




#5223762 Save/Load High Scores

Posted by BCullis on 16 April 2015 - 12:36 PM


how could you manage this for multiple users?

Off-the-cuff here, but a high level version would be if you want the scoreboard to reflect local players only, the game can just load up the external .dat file when you start the game (so the current high scores are in memory), and then save it back out on exit with any changes.  

 

If you want it integrated to facebook and reflecting multiple remote users, that .dat file will need to live somewhere all the FB instances can access it, or be converted to a database table (with interface changes in the code as well as you'd no longer be loading in from a file stream).

If you want it integrated to facebook but still only want to track the local players' high scores, you can save some kind of file off into browser cache/cookies.

There are other solutions as well, my web-stack experience is much shorter than my desktop/enterprise knowledge.




#5223722 Save/Load High Scores

Posted by BCullis on 16 April 2015 - 10:42 AM

You're instantiating a new HighScores instance (hScore).  Unless the constructor for HighScores populates itself with data (?) there will be nothing to dereference at the following line:

 

 

if (GameManager.score >= hScore.highScores[score])

because hScore.highScores (an array or list I'm assuming) hasn't been populated with any content.  For all we know, hScore.highScores itself is still null.




#5223718 Problem instantiating objects

Posted by BCullis on 16 April 2015 - 10:38 AM

Try setting weapon.transform.localPosition to zero after the parent assignment.  See if that helps?

Also, have you looked in the scene hierarchy during runtime to make sure the parenting is attaching to the object you expect?  For example, is t still a child element of the character model?




#5223715 Script Order

Posted by BCullis on 16 April 2015 - 10:26 AM

Is GameManager a MonoBehaviour?  Is the Resources.LoadAll() call being done in Awake(), OnEnable(), or Start()?  The first two will always run before Start, and are great places to do asset initialization like you're mentioning.

(Also, nitpicky, but your code example there doesn't actually use the rand variable.  I'm assuming this is because you re-typed it for an example, but if not you'll only ever use the second sprite in your loaded sprites list.)

 

 

Edit: I just realized this could be an issue where the GameManager is on a separate object from the SetObjective caller, and I misunderstood the issue.  However, according to this doc, Awake and OnEnable should still run on all the objects in the scene before Start.  Specifically: 

 

Note that for objects added to the scene, the Awake and OnEnable functions for all scripts will be called before Start, Update, etc are called for any of them. Naturally, this cannot be enforced when an object is instantiated during gameplay.




#5157423 Is working in terminal/console really a waste of time?

Posted by BCullis on 01 June 2014 - 04:13 PM


If you want to learn more specifically about game programming rather than programming in general, modding a game is much more valuable.

 

This group right here is where most of the facepalm moments come from in the "For Beginners" section of this site, though.  I think this group, more than any other, needs the console programming time to get past the CS101 problems.




#5142670 Where To [Re]Start?

Posted by BCullis on 27 March 2014 - 01:55 PM

I want to piggyback on Serapth with an anecdote here:

 

In my signature you'll see a link to my personal game project, something that's been sitting dormant for the last year thanks to other projects and that whole "real life" thing I have to spend time maintaining.  I started with a specific game goal (so not just "I want to make a game engine for no specific game") and the side task of creating some editor tools to accompany that game.  

 

I began with XNA as a great starting point, and then when I heard that it was reaching end-of-life, I cranked up the difficulty and decided to learn DirectX fundamentals as implemented through SharpDX to replicate everything XNA had offered, but with complete control over how everything was implemented (I naively thought that this would mean I could write a lean, efficient framework that didn't spend any spare cycles on anything that wasn't necessary for my specific game project).  And I did, to a fair degree, learn all about the programmable graphics pipeline, become more familiar with content I/O, get practice designing useful interfaces for tools, etc.  But the project wasn't making much progress (hey, I have these great minimally-buggy tools that get me about ...1% closer to having an actual game) as I was learning and building every piece as I went.

 

Then I was picked up to work on Cryamore, where we quickly grabbed some Unity licenses.

 


Don't ever, ever, attempt to create a game engine until you've used a game engine.

 

This is SO AMAZINGLY TRUE that I'm sorry I took this long to get to reiterating it.  

 

After a few weeks learning how Unity went about their component-based approach to game object logic, their material-driven rendering system, the data-driven asset designs...I could see dozens of ways that my work on Hazard Pay was going to turn brittle and self-destructive as I continued to build on top of a framework I *thought* was stable and extensible.  And I could also tell how I was never going to get the game into anyone's hands if I kept on developing an entire game framework on my own from the ground up (at least, with the amount of time I have to devote to it).

 

Once Cryamore has been pushed out I might rehash my framework as a hobby project, having much more experience with a successfully built engine, but I'll likely just leverage UE4 to get the game made.

 

CherryWine:


My end goal is to make the 3D game about the islands and magic fountains

If this is doable in 1 time unit,


using an engine I wrote myself using only libraries such as OpenGL, SDL, etc.

This will turn that into 10 units, minimum.

I'm a huge fan of the learning process that I went through when I started implementing my own graphics and content framework, but it will inevitably slow your progress on the actual game to a disheartening crawl.  Learn the individual systems you want to know about with smaller projects, like learning SDL via a tetris-level game (or just learning it enough to have a rendering/input context that OpenGL can draw in) but if you have bigger (multi-A) title dreams, leverage anything you can to limit the number of wheels you need to reinvent.




#5142668 Can you make an entire game with UE4 blueprints?

Posted by BCullis on 27 March 2014 - 01:31 PM

It's easier to learn to use blueprints.  Especially if you're a visual learner.

The faster development question is entirely specific to the developer(s) and the goal product.  For you as a non-programmer, you would develop a game much faster than learning to do it in code.

Watch some of the youtube videos, there are over a dozen on Blueprints alone.  It is possible to script any game mechanic you can define in their system.  Chances are most of them are probably already implemented as a node or layout (like your 3rd person shooter character controller).  You can create event-driven scripts for levels, you can customize behaviors of actors, you can dynamically spawn/destroy other actors, and if you ever REALLY hit a wall with something and have scoured the documentation without hope, chances are you can find someone in the UE4 community that could (or already did) implement your vision via source code changes.




#5142665 Farseer Physics collision detection problem.

Posted by BCullis on 27 March 2014 - 01:19 PM

It sounds like (apologies if this is already apparent) your rendering and your physics simulation are out of sync.  Two questions:

 

What happens in world.step?

Are you using any debug output to confirm that the location of the box as you're seeing it lines up with where the simulation thinks it is?






PARTNERS