I've been going crazy trying to solve this issue, and I have it down to a cause, but no solution (typical of my work it seems). Sorry for the long-winded question, just want to give all the information needed.
Details:
I'm using PlayMaker FSMs to control character movement. I've added a modified version of the "FPS Walker Enhanced" script - I gutted everything regarding character movement, except the bits that control jumping and sliding down steep slopes (an undertaking by itself).
When the character jumps, the script takes over and only accounts for the character's movement in the Y direction - and therefore any movement in the X or Z directions remains the same as when the character left the ground (inertia).
I want to be able to control the character in-air. Doing so via the script sounds easy, and it even comes with a few lines to do so, but I've spent weeks struggling with it. Since the script references the character's X and Z movement separately from the Playmaker FSMs, it was causing the built-in in-air controls to behave very oddly.
I think the solution is to reference the Playmaker FSM's stored variables, and plug them into the script. I've seen this asked before on the forums, (thanks again Jean!) but I'm not able to get it working. Problem: Using the script below, I get the
compiler error "Unexpected token: :. ", likely because I'm trying to get the X and Z components of the FSM string I'm referencing and Unity doesn't like that.
I've included an image of my FSM which moves the character.
Here's the script, I tried to take out the boring bits that aren't related to the issue for your convenience
import HutongGames.PlayMaker;
function Start () {
// get the global variable pointer
var pmove:FsmString = FsmVariables.GlobalVariables.FindFsmString("Player Movement");
}function FixedUpdate() {
if (grounded) {
stuff that enables sliding, etc// Jump! But only if the jump button has been released and player has been grounded for a given number of frames
if (!Input.GetButton("Jump"))
jumpTimer++;
else if (jumpTimer >= antiBunnyHopFactor) {
moveDirection.y = jumpSpeed;
moveDirection.x = pmove:FsmString.x;
moveDirection.z = pmove:FsmString.z;playerControl = true;
jumpTimer = 0;
}
Any ideas/advice greatly appreciated!