• Advertisement
Sign in to follow this  

Unity Asset toolchains for 2D Games

This topic is 2909 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have recently started work on a 2D platformer with XNA, the game basically uses sprite animations, now for me these sprite animations for player movement are a little restrictive and as seen as I am doing per pixel collision I thought it would be clever if I had a blend between ragdoll style physics and sprite animation. i.e player character runs into a wall, on collision there is a blend between current animation frame and ragdoll physics Is there any toolchains or custom data format out there that are specially made for 2D sprite based models with extensions for bones/keyframe animations or will I have to write my own? Ideally I want to keep my current sprite animations but I dont think this is going to be possible as there is no way of linking this together with physical data in a sprite format not unless something exists like I mentioned above... I could spend some time in writing a custom max exporter/importer but I want to avoid this if at all possible, besides MAX is designed for creating 3D models, if I am mistaken please say. There is a tool I found that converts a 3D model to 2D sprite sheets, which is along the right lines, but its animations/bone data that I want as well.
http://www.torquepowered.com/community/blogs/view/16207
Can anybody give advice or make any suggestions? Thanks Rama

Share this post


Link to post
Share on other sites
Advertisement
I'm a little confused how you expect "ragdoll physics" to work with sprites. Are you going to be applying 2D rotations or something?

I think the basic idea is that you define a model skeleton (basically, the geometry of a stick-figure), and have the physics calculate the final position of each endpoint; then, along each bone, you render the corresponding "flesh" sprite. I don't see how keyframes would figure into it.

That said, I can't imagine it looking terribly good with 2D artwork. :/

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
I'm a little confused how you expect "ragdoll physics" to work with sprites. Are you going to be applying 2D rotations or something?

I think the basic idea is that you define a model skeleton (basically, the geometry of a stick-figure), and have the physics calculate the final position of each endpoint; then, along each bone, you render the corresponding "flesh" sprite. I don't see how keyframes would figure into it.

That said, I can't imagine it looking terribly good with 2D artwork. :/


I see your point about the ragdoll without rotation. The effect I am going for is basically a 2D game but I want the player character to be effected by the world environment, hence if something is thrown at him, he will react realisticly rather than some predefined animation that is basically just repeated all the time.

Regarding the approach you mentioned, I imagine your talking about skinning, and just modelling the skeleton in a tool like 3DS max, I will have to look into the fbx or .x file format to see if they support the physics constraints I will need.

Perhaps I will have to just got for the 3D player character, and use a skeleton system with skinning like you said, from there I can do all the character ragdoll calculations in 3D. I would probably just ignore the Z or Y (whichever is forward/back) when doing collision detections.

[Edited by - reaper93 on February 27, 2010 5:50:04 AM]

Share this post


Link to post
Share on other sites
Hi Reaper,

Knowing only the basics of physics, I have to agree that it would be very odd to see this effect in 2D. Depending on what happens to the player(being hit or being burned) the player would respond with different predefined animations.

I'm not sure if there's a way around and achieving a realistic reaction without moving a fully rigged model.

You can of course construct the images and just direct the code to the proper animation in conventional fashion.

Share this post


Link to post
Share on other sites
Quote:
Original post by antmj2317
Hi Reaper,

Knowing only the basics of physics, I have to agree that it would be very odd to see this effect in 2D. Depending on what happens to the player(being hit or being burned) the player would respond with different predefined animations.

I'm not sure if there's a way around and achieving a realistic reaction without moving a fully rigged model.

You can of course construct the images and just direct the code to the proper animation in conventional fashion.


Yeh, I have already considered this solution but the problem I have with it is it is just too precalculated, I may want more dynamic movement for example he gets hit on leg, so his body gives way, or he gets hit on the head and basically the physics model just takes over allowing for natural movement. Or lets say he was trying to jump onto a ledge, but he just misses it and his foot gets caught on the edge, I would expect him to fall flat on his face while colliding with the floor. I will only be going for a basic stickman style of artwork but I want to make up for the simple styles with immersive player-world interaction.

What if I do the work in 3D but ignore the collision detection tests in the Z axis and then simply render the results from a fixed camera angle. That way we still get a 2D perspective of the game but the motion and physics are all fully modelled? So something like:


Start frame
1.From sprites in the scene, do per pixel collision tests.
2.If collision is detected for main player character, apply a force to the player model (full 3d physical model, in memory only, not displayed).
3.Allow physics engine to work out new model position.
4.Render model from a side view onto a texture in memory.
5.Use that texture as the sprite for the player character.
End frame


Does this sound viable? Not quite sure how I would map the collision detected from the sprite into a position to apply a force on the actual 3d player character, maths question I suppose.

ps Thanks for the responses so far, all helpful, any suggestions or obvious downfalls of the method i have suggested would be great.

Share this post


Link to post
Share on other sites
If you're going to do a render to texture of the model, why not just use an orthographic view and just render it to the screen instead? Not sure why you need to do an intermediate RTT step. You can still get that "spritey feel" to the game due to the ortho projection, minus all the weird hassle of trying to 2D-ify ragdoll.

Share this post


Link to post
Share on other sites
Quote:
Original post by JTippetts
If you're going to do a render to texture of the model, why not just use an orthographic view and just render it to the screen instead? Not sure why you need to do an intermediate RTT step. You can still get that "spritey feel" to the game due to the ortho projection, minus all the weird hassle of trying to 2D-ify ragdoll.


Is this just basically projecting the rendered scene onto the viewport without doing the extra transform from camera -> world space? My 3d maths is abit rusty, havvnt done much graphics programming lately.

Share this post


Link to post
Share on other sites
I'm surprised you're facing so much confusion about 2D ragdolls. Something like this, right? Well, it depends on how you're integrating physics into your engine. This link has information about doing it yourself. There's also physics engines already available; I know that Box2D has a 2D ragdoll in its examples section. Ultimately, though, you'll need some way to assign the textures per body segment; some way to apply your character's arm texture to the arm quad, the leg texture to the leg quad, etc. For that, you might want to make your own editor.

Share this post


Link to post
Share on other sites
yes thats exactly the kind of effect I am going for FunkyMonkey, but obviously mixed with preset animations, blending between the two somehow, dont see why so many people think it would be odd.

I have already integrated JibLibX into my XNA game as I was going to go with the solution I suggested above but I will take a look at what Box2D can offer before I go ahead with that, ideally I want to stick with the 2D approach and 2D physics engine, I heard the 360 can struggle with heavier apps. Somebody has already started a port it seems, not sure how complete it is, but its a bonus as it will run on the 360 which is my target platform.

http://code.google.com/p/box2dx/
hmmm wheres the source code... only dlls, looks like farseer is in a much bettr state.

Thanks alot for your input! Reading the article too.

[Edited by - reaper93 on March 2, 2010 6:28:59 PM]

Share this post


Link to post
Share on other sites
Okay, so i have made some progress.

I now have a ragdoll in my game world using Farseer Physics engine with my own textures tied to the different body parts, obviously he is all floppy, and cant do anything like run, walk, standup...

Now what I have decided to do is have some animation data that will basically control the 2D ragdoll sprite, there will be a weighting system, so when the character is idle, running/walking w.e the animation system with have 90% of the control, at which point the postional and rotational data from the keyframe data will be applied to the model. Whenever there is a collision however or something happens to the character in the physical world, the weighting system will favour the physics over animation for a short period of time for each successive collision, (time probably being relational to the force of impact).

Now the only thing really standing in my way at the moment is generating animation data that will give me positional and rotation info, I could write a tool to allow me to create animations, but I want to avoid this if at all possible, does anybody know of anything that is already available that will allow me to define basic line drawings in a root -> child structure and allow me to create keyframes and then export the positional/rotational data for each frame into a text format that I can parse in my engine? Will a flash editor let me do something like this?

edit: http://synfig.org/ this tool seems hopeful, need to investigate export formats

[Edited by - reaper93 on March 3, 2010 4:59:18 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Alexander Nazarov
      Hello. I'm newby in Unity and just start learning basics of this engine. I want to create a game like StackJump (links are below). And now I wondering what features do I have to use to create such my game. Should I use Physics engine or I can move objects changing transform manually in Update().
      If I should use Physics can you in several words direct me how can I implement and what I have to use. Just general info, no need for detailed description of developing process.
       
      Game in PlayMarket
      Video of the game
    • By GytisDev
      Hello,
      without going into any details I am looking for any articles or blogs or advice about city building and RTS games in general. I tried to search for these on my own, but would like to see your input also. I want to make a very simple version of a game like Banished or Kingdoms and Castles,  where I would be able to place like two types of buildings, make farms and cut trees for resources while controlling a single worker. I have some problem understanding how these games works in the back-end: how various data can be stored about the map and objects, how grids works, implementing work system (like a little cube (human) walks to a tree and cuts it) and so on. I am also pretty confident in my programming capabilities for such a game. Sorry if I make any mistakes, English is not my native language.
      Thank you in advance.
    • By Ovicior
      Hey,
      So I'm currently working on a rogue-like top-down game that features melee combat. Getting basic weapon stats like power, weight, and range is not a problem. I am, however, having a problem with coming up with a flexible and dynamic system to allow me to quickly create unique effects for the weapons. I want to essentially create a sort of API that is called when appropriate and gives whatever information is necessary (For example, I could opt to use methods called OnPlayerHit() or IfPlayerBleeding() to implement behavior for each weapon). The issue is, I've never actually made a system as flexible as this.
      My current idea is to make a base abstract weapon class, and then have calls to all the methods when appropriate in there (OnPlayerHit() would be called whenever the player's health is subtracted from, for example). This would involve creating a sub-class for every weapon type and overriding each method to make sure the behavior works appropriately. This does not feel very efficient or clean at all. I was thinking of using interfaces to allow for the implementation of whatever "event" is needed (such as having an interface for OnPlayerAttack(), which would force the creation of a method that is called whenever the player attacks something).
       
      Here's a couple unique weapon ideas I have:
      Explosion sword: Create explosion in attack direction.
      Cold sword: Chance to freeze enemies when they are hit.
      Electric sword: On attack, electricity chains damage to nearby enemies.
       
      I'm basically trying to create a sort of API that'll allow me to easily inherit from a base weapon class and add additional behaviors somehow. One thing to know is that I'm on Unity, and swapping the weapon object's weapon component whenever the weapon changes is not at all a good idea. I need some way to contain all this varying data in one Unity component that can contain a Weapon field to hold all this data. Any ideas?
       
      I'm currently considering having a WeaponController class that can contain a Weapon class, which calls all the methods I use to create unique effects in the weapon (Such as OnPlayerAttack()) when appropriate.
    • By Vu Chi Thien
      Hi fellow game devs,
      First, I would like to apologize for the wall of text.
      As you may notice I have been digging in vehicle simulation for some times now through my clutch question posts. And thanks to the generous help of you guys, especially @CombatWombat I have finished my clutch model (Really CombatWombat you deserve much more than a post upvote, I would buy you a drink if I could ha ha). 
      Now the final piece in my vehicle physic model is the differential. For now I have an open-differential model working quite well by just outputting torque 50-50 to left and right wheel. Now I would like to implement a Limited Slip Differential. I have very limited knowledge about LSD, and what I know about LSD is through readings on racer.nl documentation, watching Youtube videos, and playing around with games like Assetto Corsa and Project Cars. So this is what I understand so far:
      - The LSD acts like an open-diff when there is no torque from engine applied to the input shaft of the diff. However, in clutch-type LSD there is still an amount of binding between the left and right wheel due to preload spring.
      - When there is torque to the input shaft (on power and off power in 2 ways LSD), in ramp LSD, the ramp will push the clutch patch together, creating binding force. The amount of binding force depends on the amount of clutch patch and ramp angle, so the diff will not completely locked up and there is still difference in wheel speed between left and right wheel, but when the locking force is enough the diff will lock.
      - There also something I'm not sure is the amount of torque ratio based on road resistance torque (rolling resistance I guess)., but since I cannot extract rolling resistance from the tire model I'm using (Unity wheelCollider), I think I would not use this approach. Instead I'm going to use the speed difference in left and right wheel, similar to torsen diff. Below is my rough model with the clutch type LSD:
      speedDiff = leftWheelSpeed - rightWheelSpeed; //torque to differential input shaft. //first treat the diff as an open diff with equal torque to both wheels inputTorque = gearBoxTorque * 0.5f; //then modify torque to each wheel based on wheel speed difference //the difference in torque depends on speed difference, throttleInput (on/off power) //amount of locking force wanted at different amount of speed difference, //and preload force //torque to left wheel leftWheelTorque = inputTorque - (speedDiff * preLoadForce + lockingForce * throttleInput); //torque to right wheel rightWheelTorque = inputTorque + (speedDiff * preLoadForce + lockingForce * throttleInput); I'm putting throttle input in because from what I've read the amount of locking also depends on the amount of throttle input (harder throttle -> higher  torque input -> stronger locking). The model is nowhere near good, so please jump in and correct me.
      Also I have a few questions:
      - In torsen/geared LSD, is it correct that the diff actually never lock but only split torque based on bias ratio, which also based on speed difference between wheels? And does the bias only happen when the speed difference reaches the ratio (say 2:1 or 3:1) and below that it will act like an open diff, which basically like an open diff with an if statement to switch state?
      - Is it correct that the amount of locking force in clutch LSD depends on amount of input torque? If so, what is the threshold of the input torque to "activate" the diff (start splitting torque)? How can I get the amount of torque bias ratio (in wheelTorque = inputTorque * biasRatio) based on the speed difference or rolling resistance at wheel?
      - Is the speed at the input shaft of the diff always equals to the average speed of 2 wheels ie (left + right) / 2?
      Please help me out with this. I haven't found any topic about this yet on gamedev, and this is my final piece of the puzzle. Thank you guys very very much.
  • Advertisement