[Released] 2D Platform Controller

Hi Parnell,

the controller just sends state events, it doesn’t know anything about your 3D model or 2D sprite set-up. You need to set up the animation controller to suit your models/sprites.

The ModelAnimator makes an assumption that your model will face 270 degrees when running right and 90 degrees when running left. This happened to suit the models I was using from 3DRT for testing (and is due to the use of the ‘back’ view… see below).

The character’s velocity is available through the Velocity property, if you want to speed up the animations you could use this to affect animation speed.

To be clear the model animator is a sample. When you build a game you are going to need to write a more complex animation controller that does all the things that fit your game (for example do you want to play a slide animation, or play a particle effect or ignore the SLIDING animation completely).

As for front and back, it makes a lot more sense to me for moving something to the the right to increase its x position, this is how every graph/diagram I have ever seen works, thats why I set the scene up that way. Also if I write Transform.translate(Vector3.right) I’d like it to move to the right on the game view (which it does from the “back” view).*

Regards,

John A


  • Just to clarify in a 3D world it makes perfect sense for the front view to move a character to the left of the camera when they move right … the character is moving to their right not to the cameras. But this is a 2D engine, and it simplifies things if Vector3.right = right of screen.

Awesome! Thanks Johnny, I fixed my left/right issue with my model and reversed the tweak I made in the script. Thanks for the clarification on the camera thing, I think it’s just late and my mind is mush. I appreciate you taking the time to answer my questions though.
Can’t wait for edge grabbing!
B

No problem its a good question. WIll be making it to the doco in the next version.


I’m working on ledge hanging now but I have some issues. I’m not sure how an animator would animate ledge hanging (in terms of where the character would be in relation to the origin). Would they offset the character (and thus whilst climbing I don’t actually move the character), or would the centre on the origin (in which case I move the character to suit the animation)?

Usually this is not much fo an issue, but ledge climbing has quite involved interaction between character position and animation (characters hands need to stay fixed to the ledge and their body moves around them).

Can anyone help?!?

Hey JohnnyA, how can i add fall health damage in it? Higher the fall = Greater the damage.

Thanks.

Just a quick reply as I’m about to leave:

Using platform mechanism create a platform that checks characters velocity in DoAction. You will need to attach the script to every platform in your game that can deal damage (maybe all).

Alternatively you could create a script attached to the character which checks velocity each frame and compares it. If the change is too large (i.e. from -10 to 0) apply damage.

Just some options, let me know if you need more help and I will get back to you when I have some more time.

  • John A

Hey JohnnyA,

Regarding your question about climbing animation;
I would make the animation so that whilst climbing the hands stay at a certain position, and the body moves around it. just like it would in real life :slight_smile:
This would also make the animation process easiers i think, it would give the animator a look of what the exact outcome of his/her animation wil be.

Hi Blaize,

that seems to be the general idea. I still think its going to be a bit of work for the animator to get it looking perfect but I can’t really see any way around it.

What I envisage is the following:

When edge hang is initiated, the EDGE_GRASPING event is sent and the character “box” moves to an offset position which would generally be overlapping the ledge, the time taken to do this is user specified. Users can also specify this offset, and can use 0,0 if they want. For example a 3D animator might want to set the root bone at the top of the ledge and “hang” their character from this.

Once the character reaches the hang position the EDGE_HANGING event is sent.

When the player presses up the EDGE_CLIMBING animations event is sent. The character doesn’t move for a configurable number of milliseconds (in this time the user can play their animation moving about the hands).

Once the time is up the character sends the EDGE_STANDING event and the transform moves back to its original position, the time it takes to do this is also configurable. Finally control reverts back to normal.

It’s still going to be a little bit of work to ensure the animation smoothly moves back to the right position without bobbling during the EDGE_STANDING phase.

My fall damage script is kinda dumb, but I do it based upon fall time. I added a public getter for falltime and if it exceeds the amount of a normal jump I start tracking its length and when the player IsGrounded again I check fall damage. I throw out small values (so the player doesn’t take small damage from slightly abnormal falls) and if its past that threshold I calculate the damage and apply it.

When I tried to do it based upon velocity the problem is sometimes velocity would change even though we were still falling and also I didn’t want to make terminal velocity falls automatically fatal and yet I also wanted to make sure a fall of sufficient length would be fatal. If it’s a bottomless pit the player passes through a collider that applies fatal damage.

I haven’t gotten around to integrating any of the last few versions of the controller into my game (I stupidly edited the controller directly so I need to move those additions to an extension or something and import the latest version), but I was thinking with the changes to character state noted in the last version I might be able to use that in the future.

Re:Ledges It seems pretty hard to make something abstractly and without using any physics or ragdoll elements on a 3D character (attach the hands and let the rest flop?). I would think for stock animations you would want the center point to be wherever the point of connection with other objects is happening and you would adjust your animations to suit that.

I think other ledge climbing asset store packages have their own character and animations instead of trying to engineer a generic solution. I think your best bet would be to come up with something that works for your own test character and then have it documented so people can customize it to fit their own particular animation needs.

EDIT ha didn’t see the last post by Johnny. That solution sounds good to me.

Thanks for all that info. I think I’ll include a fall damage solution in the next update. It’s something that will just be much simpler if its integrated in to the controller.

As to editing the main controller code… darn! I understand the need for it, but it does make it hard to keep up with updates. The animation updates in the last version are pretty important too :s

One thing I would suggest is if you can’t do something in the controller without editing the base code let me know! I can suggest a solution that doesn’t require editing the main controller, or provide a controller update which will be on the main branch and so will make it in to the next update. Of course I can’t guarantee that it will be included in a timely fashion but I will certainly try.

I’ve got bad habits from always being a solo coder. I’m sure whomever is maintaining my code from my last job loves my insightful comments like //this sucks and needs to be improved

An easy addition that I think makes a lot of sense is a public getter for the player’s platform. Part of the design of my camera system is to avoid moving in the Y direction as much as possible which I think is generally the best practice for a platformer However once the player is attached to a moving platform the camera hard locks in both X and Y (ignoring the push box) to the player. Giving the camera system an easy way to check if the player is on a platform and info about that platform was an easy solution.

If the character is parented then you can get the platform from a public property as of the last few versions :slight_smile:

Hi JohnnyA
So i’m adding in a simple 1 frame jump animation. As i’m finding the jump will happen the animation will be stuck in that look/state for a while after landing on the ground. I’m trying to figure out why this is happening and can’t see to figure it out. Also, I made an ‘airborne’ animation as well and set that up in the scripts so that it’s available and I don’t see it pop up either.
Any idea why this could be happening? I can send you the project if you like.
Thanks again
B

EDIT:
I cranked the Airborne priority up in the public enum CharacterState and I’m seeing the airborne animation play now however when he lands now the airborne animation is still playing for a while then the idle plays. Do I need to put the idle animation priority above everything else?

EDIT pt2:
I adjusted both the Airborne and Falling priorities WAAAAAY up ( and Falling above Airborne). This seems to have solved that issue. I need to look at Sliding a bit as well, but I’m figuring this out. I just hope I’m doing it correctly;)

It’s very unlikely that you would need to change the built-in priorities. And you definitely don’t want IDLE to be above everything else. Attach the AnimationLogger to your character to see if the events are being sent correctly. Jump should be sent and then immediately after (i.e one frame) airborne should be sent.

Welcome to send me your project if you would like (john at jnamobile dot com).

Regards,

John A

Thanks JohnnyA.

One thing I noticed would be good to have is a ‘land’ state. It’d play after fall and would bd interruptible by the player too.
B

For land just check the previous state (i.e. if current state = ILD E and previous state = FALLING) you landed. This way you can support landing at different speeds too (i.e play a different animation like a forward roll if current state = RUNNING and previous state = FALLING).

The release date for the new update is scheduled for today. Will it really come out today?

Unfortunately I haven’t updated that for a while.

For the ledge hanging stuff I really need an animation to test with. So its waiting on me hiring a modeller/animator. I’m hoping it wont be too far away!

I’ll help.
Let me know what you need.
B

How would you add attacks for the player and Playmaker support. Thanks

Having done a side-scrolling beat-em up using an early version of the controller I can say that my approach was to separate movement and attack controllers almost completely. The only touch point was an additional variable which stopped movement in the X or Y direction during combos (for example move forward while doing a dash uppercut, or pause falling while in an air combo).

Of course the animations need to be mixed in, and in my case I sent animation events similar to the existing CharacterState (I had another set of events which sent AttackState). These animations where higher priority than the movement animations.

There’s also a whole lot of stuff you need to do in terms of synching hit-boxes to animations, etc. This is well beyond the scope of the platform controller.

All of that said if you just want to add some simple attack, you really just need to add another button to the input controller and when the button is pressed down turn on your hit box and play the correct animation.


EDIT: Just thinking about this I might release an attack and combo system, and although it will work smoothly with the platform controller it will be a separate product.