playMaker

Author Topic: Clamp local transforms?  (Read 2445 times)

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • MABManZ.com
Clamp local transforms?
« on: September 23, 2014, 11:02:29 AM »
Is it possible to set this up in Playmaker?

I'm trying to figure out a way to prevent connected bodies and ragdolls from "stretching", since my game involves a lot of high-velocity forces that can cause it. They will usually quickly snap back into place but it's still noticeable and can sometimes cause some weird things to happen if certain body parts get caught inside of environment colliders.

I'm trying a way to set up a rigid body to clamp the local transform values, so connected bodies can't extend past a certain point and prevent the stretching effect.

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: Clamp local transforms?
« Reply #1 on: September 23, 2014, 11:12:16 AM »
I think the question is- how would you snap the objects back into an acceptable position without physics acting bonkers?

Typically people suggest more iterations or a smaller timestep.

I think it's probably better to find a way to make the physics engine work for you. A hacky fake distance joint will probably behave pretty weirdly.

Anyway, you could just set up an FSM to GetParent, check distance, normalize the distance vector, multiply by max stretch.

It's probably about 10 actions or so.

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: Clamp local transforms?
« Reply #2 on: September 23, 2014, 11:58:14 AM »
I went ahead and made this FSM for you.









Of course, this would require you to tie the action to all of your children. ArrayMaker would probably make this better. You could also use GetChildNum and interate through them all. This should get you started though. Good luck.
« Last Edit: September 23, 2014, 11:59:52 AM by TrentSterling »

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • MABManZ.com
Re: Clamp local transforms?
« Reply #3 on: September 24, 2014, 08:33:04 PM »
Thanks! I'll try out this solution soon and let you know how it goes :)

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • MABManZ.com
Re: Clamp local transforms?
« Reply #4 on: September 25, 2014, 05:39:01 PM »
Well your fsm setup pretty much worked perfectly, without any discernible problems with the physics! At worst, it seems to reduce some of the force/velocity because of the limbs are not stretching so far anymore.

I'd been scratching my head about this problem for months and tried quite a few failed solutions. Seems like I can finally say goodbye to the stretchy ragdolls! Thanks so much!

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: Clamp local transforms?
« Reply #5 on: September 25, 2014, 06:48:39 PM »
I'm glad it worked so well. I expected weird bugs because that's what everyone says. Turns out it seems to work fine. Enjoy.  ;)