playMaker

Author Topic: Locking characters to Y/Z axis for 2.5 d game [Solved]  (Read 4110 times)

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Locking characters to Y/Z axis for 2.5 d game [Solved]
« on: October 20, 2012, 09:14:30 AM »
Hiya I couldn't find a proper solution using search so I thought I'd post.

Problem
I'm creating a game similar in vein to Deadlight and Rush N' Attack: Ex Patriot and I'm trying to figure out how to lock both the player character and enemy to the Y/Z axis (z being forward) and Y giving the player ability to jump/climb/change gravity e.t.c  

What I've tried
-I've tried getting the position of the Gameobjects, storing the float value and clamp - doesn't work as expected
-I've resorted to taking the input values for w/s out from the input manager... works but a hack and I forsee problems when adding a controller into the mix.
-I've given the enemy constraints on it's rigid body Z axis, which helps with collisions

My character is currently using the third person controller (need the wall jump function) a state containing a Get Axis Vector and smooth look at direction action. My enemy is using a capsule collider and rigidbody components.

Right now if the characters collide long enough they'll sort of do this dance and move around each other ignoring clamp values and so on.

Really need some help with this one as I'm about to add invisible wall colliders, creating a tunnel so the characters have to stay on path... but that's a hack that I know will get me in the end :)

thx!


« Last Edit: October 20, 2012, 05:12:39 PM by lildragn »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Locking characters to Y/Z axis for 2.5 d game
« Reply #1 on: October 20, 2012, 10:45:31 AM »
quick and dirty: create a new FSM and use a set position action every frame directly in the start state. Use LateUpdate and only set Z Value (the axis that the character never moves in) to the variable Z. Create a get position action (not every frame) and move it over the Set Position action. Get the Z value and save it as Z .
Create a global event called "sync" (or whatever).

Now, once the game starts, it will automatically get the Z axis and set the Z axis to that value each frame, no matter what would normally happen with collisions etc. It overwrites everything else because it's late Update.
If somewhere in the game you need to move it in the Z axis, you can call the "sync" event and it'll use the new Z value each frame.

EDIT:
If you want actual 3 dimensions, then why would clamping not work?! Use the Z axis and clamp it between min and max, Or use the float operator and use min and max there (they work exactly the other way around, use min to set the max value etc.)
« Last Edit: October 20, 2012, 11:23:21 AM by kiriri »
Best,
Sven

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Re: Locking characters to Y/Z axis for 2.5 d game
« Reply #2 on: October 20, 2012, 04:59:03 PM »
Awesome kiriri, thank you! I was almost there with a get property but didn't set it. I guess that's getter setter in coder lingo :) At any rate it works great! Thanks very much.