Playmaker Forum

PlayMaker Help & Tips => PlayMaker Tutorials => Topic started by: jeanfabre on July 16, 2012, 09:35:35 AM

Title: Character motor jump
Post by: jeanfabre on July 16, 2012, 09:35:35 AM
Hi,

 A lot of questions fired recently on the forum regards character jumping. So I am going to explain in this post how to implement it very easily.

The sample I will use to start is the ControllerSimpleMove sample provided by PlayMaker. Simply download the playmaker samples ( available in the "welcome screen" of PlayMaker).

The character set up uses a character Controller and a character Motor. But the FSM only tackle the character movement, not the jumping and you'll notice that the Character Motor component has a jumping section. So how can we benefit from the jumping system in the Character Motor?

Character Motor has an inputJump public property that is not visible in the inspector ( I know, not very clever nor obvious...). So what we need is to create a new Fsm on that gameObject and link that "inputJump" variable to the User's Jump Input.

First, make sure that the CharacterMotor component has the jump enabled, then you can do the following:

1: create a new fsm named "Jump character" attached to the character gameObject
2: add an Fsm boolean variable "jump input"
3: in the Start state ( name it "jump"), add a "Get Button Down" action and select the variable "jump input" in the field "Store result"
4: after the "Get Button Down" action, add a "Set Property" action
5: drag the "Character Motor" component in the "target Object". WARNING; really drag that component, make sure that "CharacterMotor" is displayed in grey in the "Object type" underneath the "Target Object" field
6: select the property "InputJump"
7: Select the Fsm Variable "Jump Input" in the field "Bool"
8: Make sure you check "Every Frame", else it won't work, we need to watch constantly for the jump input.

This is it, now you can run the scene, and press the space bar; the character will jump according to the jump settings defined in the CharacterMotor component.

Please find attached the package of the working scene.

Bye,

 Jean

Ps: this implementation is the most direct one, I will provide on my next post on jumping a custom jumping system made in playmaker so that it can serve as a base to expand on more complex jumping behaviour ( like multi jumps)

Title: Re: Character motor jump
Post by: tom3d on August 17, 2012, 03:20:05 AM
Thant you very much, Very clear instructions!
Title: Re: Character motor jump
Post by: brendang on August 17, 2012, 08:53:56 AM
Jean,
If you ever find yourself in NYC...  The drinks are on me!
You are  well above the helpful mark!

This entire community has such a good vibe.  Beers for All!
Title: Re: Character motor jump
Post by: jeanfabre on August 17, 2012, 11:18:19 AM
Hi,

 I made a note to self :)  never been to NYC yet, going to california in december tho, too bad  :P  ;D
Title: Re: Character motor jump
Post by: janvier18 on October 31, 2012, 11:56:45 AM
Hello.
It works perfectly, thank you.
But i try to mix it with a touch event, for an ios project.
Can i keep this method, cause it uses getbuttondown ?
Otherwise, how can I do it ?
Thank you ! :)
Title: Re: Character motor jump
Post by: amaranth on October 31, 2012, 04:11:23 PM
Jean, if you are going to be near San Francisco, I'll get you that beer!
Title: Re: Character motor jump
Post by: jeanfabre on November 01, 2012, 01:51:14 AM
Hi,

@janvier18:
 I'll see what I can do regards implementing touches on that package. Please bump this thread if you don't hear anything next week.

@Amaranth:
I am going to Los Angeles, and my schedule it packed so I don't think I am going to be able to trip to San Fransisco... would love it actually... but this is work trip, so don't think I will have day or two off I am afraid.

 If it turns out ok, I'll get in touch with you. It's not too far by train it seems.

bye,

 Jean
Title: Re: Character motor jump
Post by: amaranth on November 01, 2012, 07:11:40 PM
L.A. is a great place to be in December! I hope you have a great trip, and if you do end up in San Fran at some point in the future, please let me know.
Title: Re: Character motor jump
Post by: jeanfabre on November 02, 2012, 05:59:03 AM
I will! :)
Title: Re: Character motor jump
Post by: janvier18 on November 16, 2012, 01:29:36 AM
Hi Jean !
I bump the topic as you said :)
Title: Re: Character motor jump
Post by: jeanfabre on November 16, 2012, 02:57:57 AM
Hi,

 ok, please find a update version of another simple controller I did, and I added a touch pad texture on the right to jump, the fsm in itself is very simple, with a slight twist to make sure the jump input is not going into an infinite loop, but there are other ways to do it as well.

so you can apply the same technic wherever you want.

Bye,

 Jean
Title: Re: Character motor jump
Post by: shinodan on November 23, 2012, 06:30:34 PM
Hey im still stuck regarding this, i need an action to make my char jump but diagonally off a wall. i tried adding a y value with controller move or controller simple move and it didnt work :(

Any simpler methods?
Title: Re: Character motor jump
Post by: jeanfabre on November 26, 2012, 12:38:44 AM
Hi,

 Look at the M2H platform jumper, I can jump off the sides fo platforms, so you might want to look at how I did it.

https://hutonggames.fogbugz.com/default.asp?W890 (https://hutonggames.fogbugz.com/default.asp?W890)

Bye,

 Jean
Title: Re: Character motor jump
Post by: janvier18 on November 26, 2012, 12:06:06 PM
Thanks Jean !
I just downloaded it, i will try.
Thanks a lot :)
Title: Re: Character motor jump
Post by: tom3d on November 26, 2012, 02:26:59 PM
Thank you very much!
Title: Re: Character motor jump
Post by: teho on January 22, 2013, 03:34:56 PM
hello!
i'm trying to make a jump for my character, but can't find the component Character Motor... there is the Character Controller is applied, but not a Motor.
thanks!
Title: Re: Character motor jump
Post by: jeanfabre on January 24, 2013, 08:56:25 AM
Hi,

 I think the CharacterMotor is in the standard assets of Unity, so go in the assets menu and select "Import package" and then "Character Controller"

bye,

 Jean
Title: Re: Character motor jump
Post by: Graham on February 17, 2013, 11:12:23 AM
Do you have any idea why the jump power isn't affected by how long the jump button is held?

The property "extraHeight" is supposed to control this, but it doesn't seem to affect anything.
Title: Re: Character motor jump
Post by: Mayhem on March 16, 2013, 04:12:02 PM
Does this only work with Capsule-Objects? I ran into some issues with Spheres and Boxes.
Title: Re: Character motor jump
Post by: jeanfabre on March 18, 2013, 02:43:54 AM
Hi,

Actually, I think it only works with a character controller as it is a special type of capsule. For conventional colliders, use raw forces to have it jump.

see the platform jumper example for a custom jump system:

https://hutonggames.fogbugz.com/default.asp?W880

bye,

Jean
Title: Re: Character motor jump
Post by: app_advisory on June 09, 2014, 02:04:30 PM
Hi all,

I have an issue with this FSM : sometimes I don't have any response when I push "the button down"...

Do you have any advice to help me?

Thank you very much.