Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411433 Posts in 69363 Topics- by 58418 Members - Latest Member: Pix_RolleR

April 20, 2024, 08:30:20 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogs2D Platformer (learning Unity)
Pages: [1]
Print
Author Topic: 2D Platformer (learning Unity)  (Read 12034 times)
beeglebug
Level 0
***


View Profile WWW
« on: September 11, 2014, 01:55:13 AM »

So I decided it was about time I learned Unity.

I actually started this a week or so ago, but forgot to post it, so i'm gonna do a couple of posts showing progress.

The first version was just controlling the character, collision with the ground (including slopes) and 1 way platforms:



I'm using Kenney's Platformer Art: Pixel edition for the time being to save me getting bogged down creating assets, the art will be changing down the line.

For anyone interested in technical details, I used Prime31's 2D Character Controller script as a starting point for moving the player about. It's a great script for retro style non physics-based movement. Like a lot of old school platformers it uses ray casting, which gives it a really tight feel. I've stripped it right back and re-written a load of it by now, but it's a great starting point.

For the map I used Seanba's amazing Tiled2Unity tool, which lets you create maps using the Tiled editor, and export them really easily into Unity prefabs with nice optimised collision meshes.
« Last Edit: September 18, 2014, 01:13:24 AM by beeglebug » Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #1 on: September 11, 2014, 02:03:22 AM »

New stuff:

  • I scaled down the Kenney tiles to 16x16 from 21x21 so the change to my own art later will be easier
  • The camera now follows the player.
  • Camera stays in the bounds of the level geometry.
  • Climbable surfaces eg ladders (what a pain in the ass they were)
  • You can now drop down through 1 way platforms
  • Scene transitions

To implement scene transitions I add Rectangle objects to the edge of the map in Tiled, and use a custom importer script to make Unity Triggers out of them. I have custom properties which I pull in for the destination scene name etc, and when the player hits the trigger I use these properties to load in a new map, warp the player to the destination and discard the old map. It seems to work ok.

Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #2 on: September 16, 2014, 12:47:15 AM »

The last couple of days I've been playing a bit with a toolchain and decided on a new way to work which feels a lot nicer to me.

Previously, I was building each scene in Tiled, then exporting it wholesale and using a custom import script in the middle to parse things like triggers, spawn locations etc into Unity equivalents, but this always felt a bit hacky to me.

What i'm doing now is using Tiled to build smaller components, and then using Unity itself as the scene editor, and building larger levels out of the smaller blocks, and creating triggers etc directly in Unity. This has the advantage that I don't have to maintain an increasingly complex import script, and I have a lot less back and forth between two programs.

Worryingly, I still need to decide on what direction to take the game overall. I don't want to fall into the trap of adding features for the sake of it (i'm not even sure if I want combat for example), but I don't really have a vision of what I want the finished thing to be, so it feels a bit aimless at the moment.

I guess I can try adding stuff and playing around until I get something that feels fun and go from there?
Logged

rj
Level 10
*****


bad, yells


View Profile WWW
« Reply #3 on: September 16, 2014, 12:48:29 AM »

this is cute
Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #4 on: September 16, 2014, 12:56:34 AM »

Thanks, it's not my art though, it's free stuff from a guy called Kenney on OpenGameArt.

I'm trying to stay focussed on the programming at the moment so i'm not messing with the art too much (I always get bogged down when I start pixelling).

I think if I get really into this project i'll probably look into hiring a pixel artist to do some stuff for me, but that's a way off yet.
Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #5 on: September 17, 2014, 01:43:19 PM »

Tonight i've been adding in some more basic systems, like player health, and an enemy which can collide with the player and cause damage. This lead me down the path of trying to add a new animation of the player taking damage, simple enough you might think, but not for this unity novice  Durr...?

I'm still struggling to get my head around Unitys animation system (Mecanim?). My code at the moment is full of lines like `animator.play("run")`, but from looking around it seems like I should be using animator parameters (like `isRunning`), and letting the state machine handle choosing what to play and when, which makes sense.
Logged

Neeko
Level 1
*


View Profile WWW
« Reply #6 on: September 17, 2014, 02:28:33 PM »

Very cool. Thanks for sharing Tiled2Unity. I've been using 2D Toolkit, which has a tile map editor, but I'm always on the lookout for alternative tools. I might have to give this a shot.
Logged

Currently developing Demons with Shotguns, a 2D competitive platformer arena game.
MindShaft Games
beeglebug
Level 0
***


View Profile WWW
« Reply #7 on: September 18, 2014, 01:13:06 AM »

Cool. I haven't tried 2D toolkit, so i'll be interested to hear your thoughts when you've compared the two.
Logged

Neeko
Level 1
*


View Profile WWW
« Reply #8 on: September 18, 2014, 06:19:48 AM »

Cool. I haven't tried 2D toolkit, so i'll be interested to hear your thoughts when you've compared the two.

I'd imagine the tile map editor in 2D Toolkit is more robust than using Tiled2Unity, if for the simple fact that you can assign actual prefabs to each individual tiles (makes it easy to animate specific tiles, have MonoBehaviours attached, etc). From just reading the Tiled2Unity site, I'm not sure if you could pull off thing. I could be wrong though!

Edit: I spoke too soon  Tongue After reading this (excellent) devlog, it does look like you can attach scripts and such to specific tiles through Tiled2Unity http://www.seanba.com/megadadadventures.html
Logged

Currently developing Demons with Shotguns, a 2D competitive platformer arena game.
MindShaft Games
beeglebug
Level 0
***


View Profile WWW
« Reply #9 on: September 30, 2014, 05:05:23 AM »

Still beavering away at this.

I've added some simple enemies that wander back and forth until they bump into stuff, and a nice generic hazard/health system for things to deal damage to each other.

Next thing I want to add is moving platforms. I always hear people talk about how hard they can be, so i'm a bit trepidatious, but i'm hoping Unity will make it not so bad, everything else has been pretty easy so far (famous last words).

I've also started doodling some ideas for the graphics style, not entirely convinced yet, but it's getting closer.

Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #10 on: October 01, 2014, 04:08:09 AM »

Trying out a slightly simpler style for characters. I want something easier to draw and animate with my limited pixel art skills.

Logged

gbelo
Level 0
**


hanging out


View Profile WWW
« Reply #11 on: October 01, 2014, 05:16:25 AM »

Lots of potential here. Gonna keep watching.   Beer!
Logged

Kyle Preston
Level 2
**



View Profile WWW
« Reply #12 on: October 01, 2014, 09:30:19 AM »

Yeah, this could be something really cool! I applaud you for taking the plunge and learning Unity, and I really like direction you are taking this.

I'm seriously considering learning Unity as well and building a 2D platfomer as a musical experiment, but the tiny bit of time I've spent coding with it, feels like it's going to be a huge learning curve for me. Are there any books or resources that you've found particularly helpful? The stuff I've seen on YouTube hasn't been super-useful for a noob like me.

Anyway, best of luck finishing.  Will be coming back to see what you're up to.  Gentleman
Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #13 on: October 02, 2014, 04:31:03 AM »

Are there any books or resources that you've found particularly helpful? The stuff I've seen on YouTube hasn't been super-useful for a noob like me.

To be honest I just sort of dived in and started playing around, the only tutorials I did from start to finish were the Unity 2D stuff from Ray Wenderlich, which were pretty good at covering all the basics.

All I managed to do as far as updates go today was a quick bit of lunch break pixel doodling:



I'm still trying to find a character template i'm happy with, I think i'm almost there. I find it too easy to obsess over every pixel when doing low res art like this, I have to force myself to leave it alone when it's good enough.
Logged

beeglebug
Level 0
***


View Profile WWW
« Reply #14 on: October 05, 2014, 01:47:21 PM »

I find it too easy to obsess over every pixel when doing low res art like this

what did i just say



I still have no idea where i'm going with this, but i'm enjoying the pixel art practice. Now I think the outlines look dumb (especially on the dark backgrounds).

I really want to make something out of this, but i'm really at the limits of my art skills, I may have bitten off more than I can chew, and with me that normally means an abandoned project  Cry
Logged

absolute8
Level 5
*****


WTF, some aggressive nerd... (•̀ω•́)و ̑̑


View Profile WWW
« Reply #15 on: October 08, 2014, 01:21:59 PM »

I'm learning Unity too for the same purposes. Great job with what you've done so far. Keep posting :D
Logged

Sorsy
Level 0
***



View Profile WWW
« Reply #16 on: October 08, 2014, 01:30:55 PM »

@beeglebug
I think the characters look really cool. Big potential for customization. The limit you think you have is set there by you and you only. Just break through it.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic