playMaker

Author Topic: Moving platform support [SOLVED]  (Read 2662 times)

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Moving platform support [SOLVED]
« on: February 26, 2014, 05:25:04 PM »
I'm having trouble with moving platforms - my character isn't "inheriting" their motion. Right now I have a simple platform with a box collider on it as my platform.

  • If it rotates, the character is able to stand on the platform but doesn't rotate with it.
  • If the platform moves, the character does not, and will eventually fall when the platform moves far enough.
  • If the platform moves up, the character will fall through.
  • If it moves down, the character will fall, hit the platform, fall a little, etc.

This may be a Unity issue, or maybe PlayMaker can help, I'm not sure :D Can anyone offer any advice?
« Last Edit: March 02, 2014, 12:00:58 AM by Breadman »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: Moving platform support
« Reply #1 on: February 27, 2014, 01:27:20 AM »
Hi,

 what is your character made of? is your platform moving too fast maybe? try making move slowly, if that works then it's your physics set up not sturdy enough and make the collision of your rigigbody "Continous dynamic" for a start.

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: Moving platform support
« Reply #2 on: February 28, 2014, 12:07:46 AM »
Hi Jean,

My character doesn't have a rigidbody on it - could this explain why it doesn't inherit any motion from moving platforms?

I tried to add a rigidbody to see for myself, and got this error when hitting play:

Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
UnityEngine.Transform:set_rotation(Quaternion)
HutongGames.PlayMaker.Actions.SmoothLookAtDirection:DoSmoothLookAtDirection() (at Assets/PlayMaker/Actions/SmoothLookAtDirection.cs:112)
HutongGames.PlayMaker.Actions.SmoothLookAtDirection:OnLateUpdate() (at Assets/PlayMaker/Actions/SmoothLookAtDirection.cs:69)
HutongGames.PlayMaker.FsmState:OnLateUpdate()
HutongGames.PlayMaker.Fsm:LateUpdateState(FsmState)
HutongGames.PlayMaker.Fsm:LateUpdate()
PlayMakerFSM:LateUpdate()

Have you ever seen this error before? I'm guessing that I need the rigidbody added to the character to solve my first issue, but doing so causes this new issue. :P

createasaurus

  • Full Member
  • ***
  • Posts: 145
    • View Profile
Re: Moving platform support
« Reply #3 on: March 01, 2014, 08:28:20 PM »
I'm having this exact same problem.  The good / bad news is people all over the internet seem to have this problem with Unity too.  A solution that sometimes pops up involves temporarily parenting the character to the platform.  To me, that seems so messy, confusing and problematic.  My hope is we get the definitive answer on how to get a character to ride, jump on / off, some crazy multi directional spinning platform, that just works... and is understandable to PlayMaker beginners.   Thank you in advance to anyone who will rise to this challenge!!
« Last Edit: March 01, 2014, 08:30:33 PM by createasaurus »

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: Moving platform support
« Reply #4 on: March 02, 2014, 12:00:46 AM »
Createasaurus, I agree, that solution could get messy quickly. I wish there was a box somewhere that I'm just forgetting to enable, but it seems that's not the case.

Given that it's not an ideal solution, I did give what you said a try, and it does work. It's not that messy, but it does feel a little bit iron-fisted. Then again, my game is already filled with iron-fisted solutions! :P

Basically, my moving platform has an empty gameobject attached. This gameobject has an "is trigger" collider that is the width/depth of the platform, and much taller.

When an object tagged "player" triggers the collider, it passes to a state where the camera object and the character object (both containing within them smaller objects, FSMs, etc) are both parented to the platform. This was necessary because my character relies on the camera for movement relative between the two. This also causes the camera to rotate with the platform, which is slightly disorienting, which was desired, so yay for two birds with one stone.

When the collider senses an object tagged "player" exiting the collider, it passes to the original state which sets the parents of my camera and character objects to "none".

I'm also fond of this solution because I can use a similar FSM for my moveable puzzle cubes, and this enables me to forget about rigidbodies on my platforms and character, which was causing a whole slew of other issues. My second post, with that error message, went away when I removed the rigidbody component from my moving platform, by the way (in case anyone searching for that is brought here).

These might change based on your camera/character setup, but I went through a few iterations that I imagine would each work for different setups. Let me know if you want to try this solution (despite its slight complications) and I can help you try to work through it if you hit any snags!

createasaurus

  • Full Member
  • ***
  • Posts: 145
    • View Profile
Re: Moving platform support [SOLVED]
« Reply #5 on: March 02, 2014, 04:52:59 AM »
Breadman, first off, thank you for writing up your solution so clearly!  You came here looking for help, and now you are helping us all.  Thank you.  I will be using this as a roadmap to work this out.

I wish there was a box somewhere that I'm just forgetting to enable.
Cool.  I now know to stop searching for that "box" to enable!

Basically, my moving platform has an empty gameobject attached. This gameobject has an "is trigger" collider that is the width/depth of the platform, and much taller.
Not having tried this yet, here is a question... What if the player jumps over the platform and through the trigger collider, but never touches the platform?  Even more, what if the platform is rotating?  Would not the character seem to be thrown in a strange way?  I am wondering if this is even a problem,  and how it might be compensated for.  Perhaps the collider could be very, very short?

...that error message, went away when I removed the rigidbody component from my moving platform.
Noted.  Thank you.


***Edit*** I implemented this!  It works.

Here are some issues:

1.)  It does act a little weird when jumping onto it while it is dropping, or if I jump through the collider space without landing on the platform.  In both cases the character gets caught in the logic and gives a little jump.  My workaround is to make the collider a little shorter, so it happens less often.  However, not too short, or the system does not work.

2.) Rotation.  Rotating on Y works great!  I'm really amazed how well this works and how cool it is!  Rotating a little on Z or X, however... causes my character to warp and deform in weird ways!  No go.

Conclusion.  This is an awesome solution and will work well for many of my needs.  However, because of its limitations, I will still be in search for the ultimate 3D Super Mario solution that can handle a character jumping off all manner of rotating cubes.  Any leads?  Let me know!  Thanks.
« Last Edit: March 02, 2014, 01:50:30 PM by createasaurus »

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: Moving platform support [SOLVED]
« Reply #6 on: March 02, 2014, 09:34:30 PM »
Glad to hear you got some use out of the solution as well!

Like you, I was concerned about the "passing through" issue - wouldn't my character rotate oddly for a moment when jumping through the tall collider? I suspect he would, if he were able to move faster/jump farther, but since he can't, it works out well. If this were a problem, I could always shorten the collider as you did!

I haven't considered rotating on X or Z yet. I may at some point have X or Z rotating cubes/platforms... the current solution will cause the character to rotate oddly with it like you said. I might require a pass to a new state which changes the behaviors on X or Z rotation, or perhaps a new solution entirely.

I too would love a "plug and play" Super Mario solution, but until (if ever) that exists, we'll just have to be clever and piece together our own! Alas, the benefits of Playmaker :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: Moving platform support [SOLVED]
« Reply #7 on: March 03, 2014, 09:50:11 PM »
Hi,

 yeah, Also, have you looked on the asset store for such thing? I am sure a lot of platformer kits will provide a solution for this. I never tested any myself tho.

bye,

 Jean