Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Qbanyto on August 01, 2020, 01:38:12 PM
-
absolutely LOVING playmaker but..
I've been looking at many posts that show how to jump using a chaacter controller. How to do it with scripts, actions, etc. But did something change? Cause they don't work for me. I'm talking about the one by Jeanfabre with the characterMotor.js script
Also I saw many YouTube links posted by Padur but the videos are down! I tried the other one by but they are outdated, or when i try this, it won't work.
Can we put our heads together and try to figure this out for a Character Controller (no rigid body) and maybe save it in the ecosystem?
Right now I'm using a "Controller Move" action to move my play on the Y Axis to jump and manipulating the animation timing so it looks like a jump. but that's like the "bootleg" version of a real jump. looks a bit weird.
Keypoints:
How to make a jump for a third person character controller player?
Please advise fellow devs!
-
Hi.
May i ask, why no rigidbody?
As if you do not use rigidbody you can not use velocity or force.
So you could only use translate, which will ignore any collisions as it will ignore any physics.
-
Good thing I made a few videos on the subject of a basic fps character controller using Playmaker.
They are somewhat long and I'm not going by a script so it might be a bit rambly, but I go thru' everything you need to set up a basic character controller.
Movement - Jumping - Crouching -
The same principles can be used for thirdperson, since it's just an issue of camera placement, everything else is the same.
-
Hi.
May i ask, why no rigidbody?
As if you do not use rigidbody you can not use velocity or force.
So you could only use translate, which will ignore any collisions as it will ignore any physics.
I think it's generally a bad idea to use rigidbody character controllers, where the physics are controlled by a rigidbody and a collider.
Since it leads to physics issues with collision detection and the general issue of "physics objects digging into stuff" when given much force.
Using Unitys character controller and calculating the gravity by script, along with the jumping is the best way to go for physics stability in a character controller.
-
Hi.
It probably depends on your project as i our project we need all sorts of physics.
I just took a quick look and i noticed @7:46 that you mentioned that transitioning to a other state 'cost a frame'.
This is not the case, you can loop thru 1000's of states in 1 frame.
But depending on your actions used you can have other results.
-
Hi.
It probably depends on your project as i our project we need all sorts of physics.
I just took a quick look and i noticed @7:46 that you mentioned that transitioning to a other state 'cost a frame'.
This is not the case, you can loop thru 1000's of states in 1 frame.
But depending on your actions used you can have other results.
Yeah I generalized it, but I've always felt it runs slower when I move through too many states quickly, idk might have been placebo :S
Perhaps it's because I've only ""noticed"" latency when doing 'every frame' stuff within those states if required.
But I feel it's better to do more things within one state than to have it spread out without it needing to be spread out into different states.
If you can solve the problem within one state, why wouldn't you :P
-
Hi.
its definitely not a 'general' thing :)
For something like movement yes, for other things maybe not.
But its important to know that changing to another state is Not using a Frame.
-
Dude! I loved those videos (It was one of them first ones I watched to making a character controller) and i did PRECISELY what u suggest about a week ago. I said “well i can apply this to my third person controllers easily” But I couldn’t get the animations animate. But I’m gonna try ur method again.but the more I use playmaker the better I get at it. So I’m gonna give your videos another go. Awesome that you are here man. I thought this was a ghost town.
And I agree About rigid bodies. I’ve had weird spams with them.
Good thing I made a few videos on the subject of a basic fps character controller using Playmaker.
They are somewhat long and I'm not going by a script so it might be a bit rambly, but I go thru' everything you need to set up a basic character controller.
Movement - Jumping - Crouching -
The same principles can be used for thirdperson, since it's just an issue of camera placement, everything else is the same.
-
Hi.
It probably depends on your project as i our project we need all sorts of physics.
I just took a quick look and i noticed @7:46 that you mentioned that transitioning to a other state 'cost a frame'.
This is not the case, you can loop thru 1000's of states in 1 frame.
But depending on your actions used you can have other results.
Yeah I generalized it, but I've always felt it runs slower when I move through too many states quickly, idk might have been placebo :S
Perhaps it's because I've only ""noticed"" latency when doing 'every frame' stuff within those states if required.
But I feel it's better to do more things within one state than to have it spread out without it needing to be spread out into different states.
If you can solve the problem within one state, why wouldn't you :P
If you can keep your state tidy, why not?
It follows that using events to jump from state to state would require more computation simply in dealing with these events, which cannot be free no matter what. So there would logically be a practical advantage in keeping more stuff inside a state.
-
Hi.
It probably depends on your project as i our project we need all sorts of physics.
I just took a quick look and i noticed @7:46 that you mentioned that transitioning to a other state 'cost a frame'.
This is not the case, you can loop thru 1000's of states in 1 frame.
But depending on your actions used you can have other results.
Yeah I generalized it, but I've always felt it runs slower when I move through too many states quickly, idk might have been placebo :S
Perhaps it's because I've only ""noticed"" latency when doing 'every frame' stuff within those states if required.
But I feel it's better to do more things within one state than to have it spread out without it needing to be spread out into different states.
If you can solve the problem within one state, why wouldn't you :P
If you can keep your state tidy, why not?
It follows that using events to jump from state to state would require more computation simply in dealing with these events, which cannot be free no matter what. So there would logically be a practical advantage in keeping more stuff inside a state.
Yes, my point exactly (but I didn't word myself well enough).
I did make a mistake by saying "it costs a frame", what I should have said is "it costs more computational power".
In fact, it costs quite a lot of computational power.
I've previously searched the web to quell a thirst for knowledge, that of "How expensive are operations on a CPU", and my answer was as follows:
It varies depending on instruction set and bit width and cpu architecture, but adding and subtracing is fairly cheap (pretty much the cheapest you can get), followed by multiplication.
Division is very expensive, and doing exponent and cos/sin operations is even more expensive.
Then we have branching. Branching is in orders of magnitude more expensive than division and the likes.
But branching can also be somewhat cheap, if the branch was predicted "right".
So I'd have a hard wager that switching between states with events can cost quite a lot if done too much.
I guess bottom line is; keep your states, and subsequently your code tidy.
-
Hi.
In fact, it costs quite a lot of computational power.
This is untrue as well. changing states does virtually nothing.
C# you could compare this as methods (but i am not sure how Playmaker is doing this back-end)
Things like Creating / Destroying objects, those are cpu heavy stuff and can lag your game.
-
If you have the playmaker editor open while playing your game, it slows down and chugs as it changes states. Could this be the issue? Closing the editor stops this.
-
Hi.
Making inspector and playmaker window not visible will reduce editor lag indeed.
The reason for that is the (Gui) refresh for the inspector uses a lot of resources.
"Inspector" is actually more heavy than the Playmaker window depending on how many and what kind of components are used on the selected object.
Many fsms on a selected object can make things a lot slower, this is due to the way unity handles their ui refreshing.
But its actually not (only) slowing down changing states, it slows down everything.
For performance tests you should always test in a build, even if you are not using Playmaker.
-
Hi.
In fact, it costs quite a lot of computational power.
This is untrue as well. changing states does virtually nothing.
It could depend on how many events and transitions you use in FSMs, the spread of the logic tree.
I haven't pushed that too far either into some kitbashed benchmarking project, but since it's always greatly advised not to have big FSMs on gameObjects, thus not too many states; there's an implied performance cost somewhere down the road with having tons of small states instead of less but bigger states. That's my speculation though.
As for an event transition, I suppose it just says endThisMethodNowAndLaunchThisOtherOne(). :)
-
Hi.
In the editor is will indeed slowdown if you have lots of states.
But in a build not.
Reason is that unity GUI refresh need to refresh more stuff to get the visuals playmaker has.
-
Hey Dj, so I got the jump working from the video above but it’s messing up my animations and movement directions (relative to camera).
I guess I’ll try the rigid body route.wish me luck!
-
Using rigid body just glitches out my animation.
I also tried using “translate” action script to get my character to jump. Still no success. Sigh....
-
What method are you using to control your animations?
-
I didn’t realize you Responded. I had pm’ed you about this.
So in my third person camera system I use the free look style like most third person games do. So player directions movement is relative to camera position. (Which is Great)
My animation is triggered by the inputMagnitude Parameter in the animations module.
I now implemented your jump system which to me is very important since I’m making a 3D platformer. I’m willing to keep the jump and fix the controls lol.
What method are you using to control your animations?
-
Hi.
Controller Simple Move will not work.
If you use Controller move, you should be able to manipulate the Y velocity.
I think its best to have Controller move in a separate fsm and setup like this :
Fsm 1 :
(https://i.imgur.com/dyBrHkF.png)
Fsm 2 :
(https://i.imgur.com/FK4bTqm.png)
(you can adjust multiplier for faster movement)
Fsm 3 :
(https://i.imgur.com/7gvdAcc.png)
On Check grounded you will need a fms bool test (found on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181))
The Playmaker Tween can be found Here (https://hutonggames.fogbugz.com/default.asp?W1714)
You also need to make a fsm to check grounded (that fsm depends on how you want to check)and have it set a variable if grounded or not.
And on Set Gravity/Grounded value you need to use a Set Fsm Float to adjust the value on the Move Handler FSM.
Before you do, you might want the have a look at this :
https://medium.com/ironequal/unity-character-controller-vs-rigidbody-a1e243591483
To animate you will probably do that best in a separate fsm as well.
You can Send a event to that fsm from the 'gravity animator' on the Animate jump state.
Then to animate you can use Animator Play. or use a 'Set Animator Trigger' (I prefer to minimize using Parameter in the animator).
Then you probably also need to check for grounded (probably 1st if 'not' grounded, as it needs to start the jump) then when grounded you can play a 'Land' animation for example.
-
Thank you so much. I will try this as soon as i get home from work.
Why do you minimize using parameters? Is it unstable? Just curious.
Also what are the actions inside the move handler fsm: Idle & don’t move events (i notice they are not tethered) and the two right ones in the gravity animator fsm? I just want to replicate everything you have so I can get this working.
-
Hi.
In move, they are just empty.
But you can send an event if you want the player not be able to move
(for example on cinematics, talking to npc etc)
the other ones i explained what in it.
-
I got lost in the Gravity Animator portion. what values do i put in the fsm bool test and others? I don't know what fsm name, variable name, etc. also i have the "start" on top of get grounded but how do i get the "jump" rectangle pointing down to "done" on the left there?
What/how do i put it in the "set gravity value" and "set grounded value?
-
Hi.
For Grounded you need to make an fsm to check if you player is grounded.
You can do this with a trigger under the foot of the player, or use raycasts.
that fsm need to set a bool 'true' if grounded and 'false' of not grounded.
in Set Grounded you can set the Move Y Value to 0 (by using set fsm float)
in Set Gravity you can set the Move Y Value to minus something (for example -5)
For the jump pointing, here is a video on Global Transitions :
-
Ok So I already have controls set in place, so what I did was implement your Tween jump to my Jump FSM and he jumps perfectly HOWEVER, if I'm running and then I jump, he jumps in place instead of jumping forwards. The x/z Value doesn't transition on the jump. so he runs runs runs and jumps straight up.. lol.
How do I carry over the directional value?
Hi.
For Grounded you need to make an fsm to check if you player is grounded.
You can do this with a trigger under the foot of the player, or use raycasts.
that fsm need to set a bool 'true' if grounded and 'false' of not grounded.
in Set Grounded you can set the Move Y Value to 0 (by using set fsm float)
in Set Gravity you can set the Move Y Value to minus something (for example -5)
For the jump pointing, here is a video on Global Transitions :
-
hi can you show your fsms/states/action.
if you use multiple character move actions you will have issues.
-
I only have one character controller. see photos. I added my movement actions and also my jump. I'm really happy with it all with the exception that he only jumps straight up. which obviously is fine when standing still but not when moving around. I want the player to jump in the direction I'm moving and manipulate the jump a bit while in the air as well.
(https://i.postimg.cc/kXshbtpx/Capture.png) (https://postimages.org/)
(https://i.postimg.cc/y8NpXYM2/Capture2.png) (https://postimg.cc/0bLC9x2C)
upload images no registration (https://postimages.org/)
hi can you show your fsms/states/action.
if you use multiple character move actions you will have issues.
-
Hi.
Why are you using translate?
Also it is totally different from my sample.
On my sample there is 1 fsm that does the move and the other fsms are giving the data to move (xyz)
-
Im not using translate it’s unchecked. I should delete it since I’m not using it.
And when I tried your method, my character wouldn’t move at all. So i went back to mine and just added your tween to position for the jump.
Do I have to implement your movement to be able to jump forward?
Would it just be easier if I use a rigid body instead of a character controller?
Hi.
Why are you using translate?
Also it is totally different from my sample.
On my sample there is 1 fsm that does the move and the other fsms are giving the data to move (xyz)
-
Hi.
How/where are you moving the character?
-
With the “get axis vector” on my picture above.
Hi.
How/where are you moving the character?
-
Hi.
“get axis vector” is only getting a value from you input.
Are you using 'Controller Move/Controller Simple Move/Move Object/Move Towards actions somewhere?
-
I'm not using any of those. I appears get axis vector takes the input system and applies movement from there. the only "move to" type i use is "smooth look at direction" for when I'm turning my character in any direction.
(https://i.postimg.cc/zvnFfhHH/Capture.png) (https://postimg.cc/rRwrnKJq)
(https://i.postimg.cc/G3YQKWg3/Capture2.png) (https://postimg.cc/nMFBcPtN)
Hi.
“get axis vector” is only getting a value from you input.
Are you using 'Controller Move/Controller Simple Move/Move Object/Move Towards actions somewhere?
-
Hi.
It looks like you are moving with the animator, i did not know that was possible.
Also not sure if that is a good way to move your character.
-
Yea. You’re probably right. Let me try your method one more time. Whenever I try doing it your way, I just can’t move the character when pressing the buttons.
Hi.
It looks like you are moving with the animator, i did not know that was possible.
Also not sure if that is a good way to move your character.
-
Dj, I just tried everything exactly how you wrote it and hes not moving at all. I press the directional keys and nothing happens. Can you make a small sample project and post it so I (and others) can download it and learn from it?
Yea. You’re probably right. Let me try your method one more time. Whenever I try doing it your way, I just can’t move the character when pressing the buttons.
Hi.
It looks like you are moving with the animator, i did not know that was possible.
Also not sure if that is a good way to move your character.
-
Hi.
Have you tried on a new scene with a object that has only a character controller?
-
ok i got it working.
Also he moves vertical and horizontal but not relative to the camera. this is a third person free look camera. so this wouldn't work.
however, I implemented the "tween move" action script you showed me to my movement system and I'm happy with it. the only issues now is that when he jumps, his speed slows down in the X/Z axis until he lands on the floor and is running again. so he runs fast and SLOW MO jump. its a cool EFFECT but not what i want especially since its not intentional.
I am playing around with the animation speed and its helping a bit. any idea why he slows down while in the air?
I tried parenting a small cube infront of the player and have player move towards that direction while in air but its a bit wonky.
Hi.
Have you tried on a new scene with a object that has only a character controller?
-
Hi.
I do not know why its moving slower while 'jumping'
Maybe you could increase the axis multiplier while jumping.
-
What would be the best way to do that? using Set fsm float? I’m currently using “translate” to make my jump. Anyways to make it translate faster upwards as well? Any way to adjust the translate speed?
Hi.
I do not know why its moving slower while 'jumping'
Maybe you could increase the axis multiplier while jumping.
-
hi.
Probably that's why your jump is slowing down the movement as its conflicting with each other.
so even increasing the axis multiplier will not work.
-
That’s the only way i can keep moving around in the air after I jump. I have tried many different playmaker tutorial and NONE of them have a jump feature for a 3rd person camera system. I would like to try using a rigid body and “add force” but I can’t seem to get rigid body controls to work with my camera system. I won’t give up though.
I may just have to copy and paste some code from the template that unity has. Which sucks. I was hoping playmaker could give me Mario 64 type of controls
hi.
Probably that's why your jump is slowing down the movement as its conflicting with each other.
so even increasing the axis multiplier will not work.
-
I THINK I SOLVED IT!
So I can now continue my movement momentum while jumping by using “controller move” and using the “inputVector” variable set by “get axis vector” action.
Works very nice! :P Wow! what a relief. Ha. Now to work on my triple jump. Woot woot!
Que bueno.
However I still can't manipulate movement WHILE in the air.
-
Change the vector midair or increase the impulse in certain directions.
-
Actually I forgot to update this but I fixed it. I just had to change the animation to a jumping “in place” type. How do i add “solved” to the subject ? It won’t let me.
Edit: never mind i got it :)