Playmaker Forum
PlayMaker Help & Tips => PlayMaker Tutorials => Topic started 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)
-
Thant you very much, Very clear instructions!
-
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!
-
Hi,
I made a note to self :) never been to NYC yet, going to california in december tho, too bad :P ;D
-
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 ! :)
-
Jean, if you are going to be near San Francisco, I'll get you that beer!
-
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
-
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.
-
I will! :)
-
Hi Jean !
I bump the topic as you said :)
-
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
-
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?
-
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
-
Thanks Jean !
I just downloaded it, i will try.
Thanks a lot :)
-
Thank you very much!
-
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!
-
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
-
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.
-
Does this only work with Capsule-Objects? I ran into some issues with Spheres and Boxes.
-
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
-
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.