playMaker

Author Topic: dodge roll in 2d platformer  (Read 1337 times)

ffffffffff

  • Playmaker Newbie
  • *
  • Posts: 18
dodge roll in 2d platformer
« on: April 30, 2020, 12:04:20 AM »
how to make dodge roll in 2d platformer . which action should i use

ffffffffff

  • Playmaker Newbie
  • *
  • Posts: 18
Re: dodge roll in 2d platformer
« Reply #1 on: April 30, 2020, 08:58:51 AM »
pls help

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: dodge roll in 2d platformer
« Reply #2 on: April 30, 2020, 03:07:42 PM »
Hi,

add force (2D), probably set to impulse.



ffffffffff

  • Playmaker Newbie
  • *
  • Posts: 18
Re: dodge roll in 2d platformer
« Reply #3 on: April 30, 2020, 08:57:58 PM »
i try add force before but the player can only do that in the air so do i need ground check or what. secondly the player can only roll to the left . since it a dodge roll so i want to make the  player  box collider 2d to disappear for 1 seccond so the the player take no hit from the enemy.

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: dodge roll in 2d platformer
« Reply #4 on: May 01, 2020, 09:04:34 AM »
What you need to do depends on your setup.

When you add force, you need to detect the direction and multiply the force with -1 for a dodge to the left. You should not disable the collider, as then your character falls through the ground. Instead tell the HP FSM that it cannot take damage during the dodge state.

How, again, depends on how you implemented it. Could be as simple as deactivating the HP FSM for a simple controller, or more involved for a more complex one.

Last, I would not use a box collider on the character in 2d to begin with, unless your levels are totally grid based and there are no slopes, ever. Rather, use a capsule collider, or a circle (freeze the z axis on the rigidbody).







rechronicle

  • Full Member
  • ***
  • Posts: 119
  • Mystvaldia
    • Indie RPG Creator
Re: dodge roll in 2d platformer
« Reply #5 on: May 01, 2020, 09:20:48 AM »
The power of FSM. Make a "Rolling" state, in this state, disable the box collider, add force, and so on. Then get back to the "Normal" state with box collider turned on & other settings you would need in a normal pose. Lastly, your input (ex: Shift button) will send an event to the "Rolling" state.

Just a big picture tho, you can set it up to anything you want. It's your game.  :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: dodge roll in 2d platformer
« Reply #6 on: May 01, 2020, 10:49:58 AM »
Hi.
you should work with 2 colliders, 1 can be a trigger
on main parent use the 'floor' collider' this will detect floor only.
then in a child object use preferably a trigger.

this can detect getting hit, and this you can disable on roll