playMaker

Author Topic: Jumping character controller  (Read 4148 times)

Hen7

  • Playmaker Newbie
  • *
  • Posts: 3
Jumping character controller
« on: September 16, 2017, 12:05:04 PM »
Hey
Fairly new to Playmaker, so far I had a good time but lately came across an issue that drives me nuts.
I know it's been asked here a lot, but even after hours of searching on the forums and online I just can't get anything to work.

I have a character controller with super simple FPS controls, get axis vector and simple controller move, just like everyone do in all the tutorials.
I've been trying to make it jump, and no matter what kind of tricks I've tried I simply can't.

So far I've tried:
  • Using addforce (found out physics do not work with a character controller)
  • Ditching the character controller and trying to use rigidbody instead (works but  feels really crappy compering to the controller)
  • Trying to disable the controller component and enabling a rigidbody via a fsm (too buggy and way hacky)
  • Trying an animated float that translate the player's Y up and down (feels bad and buggy)

Any help would be greatly appreciated.

PS - seems like controller simple move doesn't work while you're in the air, any way to fix that as well?

Thanks

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Jumping character controller
« Reply #1 on: September 16, 2017, 11:50:33 PM »
Hi,

You could try rigidbody setup plus set velocity (up)? I recall I'm using this, and it works well (cannot check at the moment).

Note, the setup below is a bit fancy. You technically only need a button press, set velocity (passing through the state, finish) and back. The gravity takes care of it. But you probably want to polish it up, and have falling and landing etc.

The setup I build works like this: The first state listens for button down. I also get velocity up/down every frame. Also, every frame compare this float whether it is below zero, give a bit of threshold. If so, it means the character is falling (goes into a falling state).

On the state after the button, set the velocity. It only passes through that one. Afterwards another velocity/compare state like at the start, to detect whether the character is still rising. If not (velocity is negative), move into a following falling state. I use a different one there. I think I again do the velocity/compare pair once more, this time, waiting for velocity to be zero or positive — because that means the character has landed on something.

This way, I also don't need collision detection or rays that detect the grounded state — but I don't know if this method is superior. I also have a few more details in there, like jump height based on button pressed, and I also add downwards velocity after falling, but that's choice (makes it snappier and better in my view).
« Last Edit: September 16, 2017, 11:57:24 PM by Thore »

Hen7

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Jumping character controller
« Reply #2 on: September 17, 2017, 03:40:29 AM »
Hey, thanks for the reply!

While I would love to use a rigidbody, like I mentioned, it's movement and colision with other objects feels really bad comparing to the controller (keeps jerking and jittering around).
The internet says there are ways to fix it via scripting, but... well, I'm using Playmaker for a reason.

I did managed to get a good working jump system for the controller since posting here, using an animated vector3 Y value and a controller move action.
But I'm dealing with two issues:
  • No air controls, very annoying if you jump with zero momentum.
  • If I'm jumping on objects that were very close to me (aka hugging them) the controller starts to shake like crazy.
Video of the two issues:
https://www.dropbox.com/s/jtb348nhl7j4rsa/JumpIssue.webm?dl=0

I'm so close.

Edit - Got mid-air controls to work, only issue remaining is the shake bug, anyone have any idea?

Edit 2 - Got the shake bug fixed as well, by adding a state with collision detection that pushes the player back on it's -Z if he's touching something right when jumping.
« Last Edit: September 18, 2017, 08:24:49 AM by Hen7 »