playMaker

Author Topic: FPS Controller, Crouching!  (Read 4357 times)

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
FPS Controller, Crouching!
« on: June 30, 2011, 10:32:55 PM »
My FPS controller made with Playmaker needs crouching. I've animated the Camera to and from a lower position with a key press, so everything appears perfect.

But the Character Controller on the parent object has the collider information and I can't tell it to half the height. So I can't allow the player to crawl under obstacles.

Is it possible to control this or somehow bypass it and use a different collider?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: FPS Controller, Crouching!
« Reply #1 on: July 01, 2011, 03:10:50 AM »
Currently you'd need a custom action to set the controller height property.

When I get a moment I'll make a Controller Settings action to set the Controller radius, height, center etc.

The 1.2 update will have Get Property and Set Property actions so you can get/set public properties on any Unity Objects without writing custom actions.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: FPS Controller, Crouching!
« Reply #2 on: July 01, 2011, 10:39:53 AM »
Give this Controller Settings action a go:
http://hutonggames.com/playmakerforum/index.php?topic=395.0

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: FPS Controller, Crouching!
« Reply #3 on: July 01, 2011, 07:27:35 PM »
That is absolutely awesome! Thanks. I got it working easily.

Just the one last thing with it. I need to detect a collision above (within the standing height volume) so it doesn't allow standing up again into the thing the player is crouching under. I've tried three things and still can't get it to work.

I saw there's a Detect Collisions option in the new Controller Settings Action. I tried using that and a Get Controller Collision Flags Action, but it only set my crouch bool to true while moving, plus other issues, not too sure about that one. Seemed a bit daring to not let the player stand again only once he collided with the scenery. What if the scenery is just high enough not to collide but still low enough you need to crouch under.

Then I thought of firing a ray upwards 1m to check for collisions, but I need a lot more practice with ray firing. Haven't managed to do it successfully yet.

Then it occurred to me how simple it could be if I just put a capsule above (where the players head is in standing mode) with it's collider set to trigger. Then use that to check if there's something above while crouching. I like this solution best but I can't get it to work. Seems so simple but it doesn't want to trigger with a collider that's attached to the Player (colliding with scenery), only works if the player collides with it (not attached). I tried using Collision Event and Trigger Event. Is it possible? Is this the best solution?