Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Red on November 30, 2014, 02:19:55 PM

Title: Moving platforms help requested.
Post by: Red on November 30, 2014, 02:19:55 PM
Like the title...

What I need to figure out is how I can get the player to move while they're on a moving platform and move with that platform... It's a standard game mechanic but I'm having a hard time adapting the video tutorial (which deals in code) to PlayMaker.

Here's the video I'm referencing. In code it seems relatively simple... But I'm having a difficult time wrapping my head around how I'm going to get this working using PlayMaker.

Attached is the way I've got it set up for now... The first shot shows the three actions that give me the custom gravity.

I've also got the "set velocity" being what drives the movement... I know it's a little odd but it's the cleanest way I could figure out how to do this since I was getting some really odd results with the "translate" and the character controller would throw some even odder results... So, I am somewhat limited in how I can approach this.

If you want to see other bits of this, feel free to ask and I'll do what I can.

As for how I have tried to address this... Well, I tried the suggestion in another thread to change up the parenting to make it a child of the platform while it's on there but that didn't give me nice results for what I wanted (when I tested I noticed a slight jumpiness as the parenting did it's thing.)

What I have to work with:
-I have a system that detects what it's standing on and determines what it is (if it's a moving platform or not) this uses raycasts. This system is also important to detect when it's grounded or not (since I had to scrap the use of the character controller component, I had to cobble together my own "is grounded" checking system... That is the same system that the "am I on a moving platform?" test uses so I'd rather not have to re-roll that element.

Any ideas? The biggest hurdle I've been trying to figure out is how do I calculate the movement of the platform itself to feed into the "movement = movement + platform movement distance" thing (as outlined in the video.)

I know this is long. Thank you for reading this far.

edit: Yes, this is for an asset store package but also for a game I want to make... That's kinda how I do that part of my side-job... Making games and also selling the bits and pieces for a little extra scratch. If the idea of helping with something I plan to monetize is troubling to you then I completely understand.
Title: Re: Moving platforms help requested.
Post by: Red on November 30, 2014, 03:12:11 PM
So, I've been mulling it over and I think I might have an idea how to adapt the video technique to this one.

Thing is, I need to figure out a way to get the distance that the platform has traveled per-frame (I'm using iTween right now but if that's not advisable I can find a different method but I suspect that may not be required.)

One thing I could do is an "every frame" deal where the platform takes it's current position, compares to the position it was at in the previous frame and does the maths (I'm not the best at it but I believe subtracting the previous from the current would be the most ideal to get the "how far has this traveled.")

Thing is... If I do this in the actual FSM that handles the movement I get it managed cleanly in terms of performance... But that'd then likely turn that set of states into a bit of a nightmare (And I'd have to repeat it for each state such as when traveling right or left.) But if I handle it in a separate FSM such as the platform itself then there's the issue of lag if the functioning of transferring that data (the "Distance travelled" bit) between FSMs might make it lag.

As you can tell, I'm obsessed with performance... But to me a good side-scroller has to have very, VERY tight controls and clean response time... Call me old-fashioned but the oldies-but-goodies such as SMB and MegaMan are my inspiration here.
Title: Re: Moving platforms help requested.
Post by: Red on December 03, 2014, 01:17:12 PM
Okay, so I discovered that adding a rigidbody to the platform won't kill the systems... AS long as I make it kinematic.

So, the "when standing still on the platform" is solved simply by taking the velocity and feeding that directly into the "Set velocity" action in the "idle/standing" action set.

Still trying to figure out the "when moving" bit... Since the actions I have are "every frame" kinds, the first attempt at taking the velocity of the player and platform and adding it every frame gave terrible results (basically, it had me zooming all over the place.)
Title: Re: Moving platforms help requested.
Post by: Red on December 03, 2014, 01:46:02 PM
And it looks like I may have solved it.

Here's the layout. Expanded actions are the relevant actions.
Title: Re: Moving platforms help requested.
Post by: djaydino on December 03, 2014, 07:44:23 PM
i have not watch that whole movie, but on this ( tutorial it looks a lot easier to do this.