Hello,
I am trying to make a 2d fighting game with unity and I find that the physics system is just not right for me. For example, the animated frames for jumping don’t match the time it takes for the gameobject to return to the ground once the jump has been initiated using add force. I have to remove frames and add frames in order to get it to look like it matches. I am aware of the gravity feature that Unity has but that does not help either. I would like for everything to be handled by the animation the jumping, the walking, etc… I am using Smooth Moves for the animation. I was told not to embed the collider taking the damage(the hitbox) in the animation. If I do that then I must use the physics engine, because hit box will not move along with the animation. For example, if I translate the gameobject forward or backward the collider will move with the gameobject, but if I make the player jump the hitbox collider stays on the ground. Then there is actual collisions, the players walk toward each other and pass through one another, which is not what I want at all. I am also using Playmaker to handle the scripting. In a 2d fighter the hitbox must move along with the player whether it be jumping, walking attacking, being attacked, etc… I would like to know if Unity is right for what I am trying to achieve? Is there anyone else here developing a 2d fighter, and if so how did you handle the issues talked about earlier in this post? Is there anyway to not use the physics engine yet still have collisions where when the two players walk toward each other and they stop? Smooth Moves allows for colliders to turn on and off during certain parts of the animation but when you uncheck the trigger box they don’t work as colliders. I guess I may need to script the collisions but what must I do in order to get the triggers to behave the way I want? Please let me know if I did not explain thoroughly enough. This is very complicated and I may have left out an important detail.
Thank in Advance
Yes, Unity can do fighting games.
A basic fighting game, even with physics and all should be fairly easy to throw together without too many problems.
The tough part typically comes afterwards when you push it for more speed and precision. That definetely is something that you want to do with code so that you can abuse the system to get the most out of it.
The faster stuff moves across the screen, the harder it gets with detailed collision because it is always checked and calculated X times per frame. Even physics engines do it this way. This is why you can get stuff that moves really fast to pass walls and stuff in some games. The solution to this problem is typically to predict the future a bit, best case, find unavoidable collision points that you know will happen. Worst case, find a possible collision, do magic and add funny laws that determine if it will collide or not.
Then comes the pixel precision stuff
Maybe two things that have overlapping collision boxes aren’t still colliding.
Your collision problems sound strange though, sounds like something isn’t working properly. Where and how did you add the collision boxes to your characters? Maybe some images or other detailed explanations on how they are connected?
Maybe someone can spot the problem if given enough detailed information with images and such.
Here’s how I have the players setup at the moment:
Player- Gameobject that contains the logic, ridigbody, and collider(hitbox = takes damage).
Grounder- Gameobject child of Player that detects when player is on the ground(this is only used because I am using physics).
Animation- Gameobject Child of the Player that holds the animations and (hurtboxes = does damage).
This works but as I said the physics cause problems with the timing of the animations. I am working with 24 fps so if a jump is 22 frames it should just be shy of 1 second. But with the physics it may take more than 1 second to complete the jump, which causes the animation to be mistimed. I don’t mind working with Unity’s physics engine but cannot get some of my animations to match as far as timing. I guess I my concern is how do I get the time in unity to match up with the time of my animations?
1 Like