About Store Forum Documentation Contact



Post Reply 
Moving Platforms
Author Message
Scarlet Thread Offline
Member

Post: #1
Moving Platforms
Has anyone had success implementing moving platforms that work properly?

The main problem is of course that when you have a character standing on a platform and said platforms moves horizontally the character slides off. To counter this I added the velocity of the elevator to the controller but of course the disabled any control I had over the character controller.

I want my character to be able to move around on the platform relative to the platform without sliding around. Anyone have any ideas or done this before?

Also I have a room which changes its floor heights. Problem is similar. When The floor goes up I lose a lot of control and the character slides around almost uncontrollably. I think it's part of the same problem with horizontally moving platforms in the way that a force is being exerted on the controller and therefore it is behaving differently.

Cheers.
07-02-2013 09:06 AM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #2
RE: Moving Platforms
One way is to move the platform and add that speed to the character... The other way is to move the background and letting the platform stay still...

The latter could require some area modifications though.
07-02-2013 10:56 AM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #3
RE: Moving Platforms
(07-02-2013 10:56 AM)Dwight Wrote:  One way is to move the platform and add that speed to the character... The other way is to move the background and letting the platform stay still...

The latter could require some area modifications though.

By what method would you add the speed to the character?

Currently I already do that but it has the adverse effect of cutting off user input. I add the velocity of the controller body to the same velocity as the platform.

Possibly I need to intercept the desired velocity before it goes into the Update controller function and add the platform velocity to that.

The third option is not a possibility in my case... since there maybe be multiple moving platforms carrying different characters at the same time and for other reasons.
(This post was last modified: 07-02-2013 11:40 AM by Scarlet Thread.)
07-02-2013 11:39 AM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #4
RE: Moving Platforms
Just a wild guess here, I didn't try it, but this is what I would try:
Make the platform a physical material, and give it a very high friction coefficient. Somehow I'm hoping this would take care of the problem, but I might be wrong. I still think it's worth giving it a shot.

Alternatively, I'm thinking you could check if your player stays on another object (I assume the platform is not of terrain type). And If he is, add all support object movement's to the player also. Another wild guess.
(This post was last modified: 07-02-2013 01:02 PM by AndrewBGS.)
07-02-2013 12:59 PM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #5
RE: Moving Platforms
(07-02-2013 12:59 PM)AndrewBGS Wrote:  Just a wild guess here, I didn't try it, but this is what I would try:
Make the platform a physical material, and give it a very high friction coefficient. Somehow I'm hoping this would take care of the problem, but I might be wrong. I still think it's worth giving it a shot.

Alternatively, I'm thinking you could check if your player stays on another object (I assume the platform is not of terrain type). And If he is, add all support object movement's to the player also. Another wild guess.

Thanks

I gave your first suggestion a try.. It seems to reducing the sliding when trying to move on objects that move up and down but doesn't stop it alltogether.

Regarding your second suggestion. Yes that is what I do with my elevators already. My problem isn't getting the characters to go with the platform, my problem is allowing the player to still have user input to move the character around on that platform while it is moving. This is difficult because the moment you set the velocity of the controller actor to that of the platform, it takes away any velocity added from key presses.

I have tried Actor->vel(vel) to set the velocity of the platform to the actor.. This unfortunately stops character movement

I have also tried Actor::addVel(vel) - This allows movement but unfortunately it sends my character flying up in the air because each frame it is adding the platform velocity on top. Perhaps if I record the last velocity added and then minus it from the new velocity to add it will work.. bbs I'll give that a try. [Edit] nope didn't work and I remember trying it before now.
(This post was last modified: 07-02-2013 01:32 PM by Scarlet Thread.)
07-02-2013 01:19 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #6
RE: Moving Platforms
Why add velocity? Why not just treat it as simple movement control input? I don't have the engine here to check where that is, but anyway, I would try treating it as player movement, not velocity. Because, when you move the player you don't work with velocity, so you shouldn't do it here either. I suppose.... as I said I never tried this.

(maybe the first idea works if the player also has a highly adhesive physic material? But you probably don't want that..)
07-02-2013 01:22 PM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #7
RE: Moving Platforms
Actually the controller does move by setting a desired velocity.

void update(C Vec &velocity, Bool crouch, Flt jump);

This is just hidden in the Game::Chr object class

I tried the material on controller actor too but no difference.

Edit:
I'm thinking maybe I can intercept the desired velocity and add to it before the update. I will have to make a custom character class for this. Well sort of, I already have customized the animation of characters, all I need to do is copy the whole Game::Chr class and change a few things so that the desired velocity can be altered whenever on a moving platform before applying it to the controller.
(This post was last modified: 07-02-2013 02:11 PM by Scarlet Thread.)
07-02-2013 01:39 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #8
RE: Moving Platforms
What about instead of adding the velocity, just change the controller's position to the same relative position of the platform every frame? This should allow the other forces to remain unchanged-theoretically. I have a similar instance in which this worked unless I had multiple joints affecting the object which resulted in a strange lag.
07-03-2013 02:08 AM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #9
RE: Moving Platforms
(07-03-2013 02:08 AM)Rubeus Wrote:  What about instead of adding the velocity, just change the controller's position to the same relative position of the platform every frame? This should allow the other forces to remain unchanged-theoretically. I have a similar instance in which this worked unless I had multiple joints affecting the object which resulted in a strange lag.

I have a feeling I tried that when I was first making the elevators about 4 months ago. If I recall correctly it had the same effect as adding the velocity in the way that it eliminated any input movement.

I will give it a try though when I get home just in case.

Edit: I actually remember now that when I first did it, setting the velocity or position didn't take away user input.. This was back when PhysX3 was only just implemented and it had an issue where the controller got stuck when hitting walls instead of sliding smoothly accross walls. When this much needed fix came I think is when movement stopped completely when setting velocity or position. Though I don't think it was 100% before either If I recall correctly.
(This post was last modified: 07-03-2013 02:31 AM by Scarlet Thread.)
07-03-2013 02:27 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Moving Platforms
Hi,

Did you try doing this:
override the Game.Chr method which calls the ctrl.update(vel..)
and add to the 'vel' parameter the velocity of the platform?

I'll try to do some checks in the nearest future for controllers moving on platforms.
07-04-2013 01:04 PM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #11
RE: Moving Platforms
(07-04-2013 01:04 PM)Esenthel Wrote:  Hi,

Did you try doing this:
override the Game.Chr method which calls the ctrl.update(vel..)
and add to the 'vel' parameter the velocity of the platform?

I'll try to do some checks in the nearest future for controllers moving on platforms.

Cool I'll give that a try:

[Edit:] The actual function that calls the ctrl.update(vel..) function is void Chr::updateController(); This is not virtual so I cannot overwrite it. However, I can overwrite the bool Chr::update() function and just call one of my own UpdateController() type function instead of the default one.. I'll give this a try tomorrow cheers.
(This post was last modified: 07-04-2013 03:16 PM by Scarlet Thread.)
07-04-2013 02:57 PM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #12
RE: Moving Platforms
(07-04-2013 02:57 PM)Scarlet Thread Wrote:  
(07-04-2013 01:04 PM)Esenthel Wrote:  Hi,

Did you try doing this:
override the Game.Chr method which calls the ctrl.update(vel..)
and add to the 'vel' parameter the velocity of the platform?

I'll try to do some checks in the nearest future for controllers moving on platforms.

Cool I'll give that a try:

[Edit:] The actual function that calls the ctrl.update(vel..) function is void Chr::updateController(); This is not virtual so I cannot overwrite it. However, I can overwrite the bool Chr::update() function and just call one of my own UpdateController() type function instead of the default one.. I'll give this a try tomorrow cheers.

Ok so I've tried this and it doesn't work too well with up and down movement of platforms.. not sure about laterally moving. However, I have a feeling it may work for lateral movement... haven't been able to test yet though.

tbh I think this is part of the solution but not the full solution... not sure where to go from here tnow though :(

edit: I checked the value of velocity in debug VStudio so I know 100% that it was getting added to desired velocity and not just a mistake in my code.
(This post was last modified: 07-08-2013 01:37 PM by Scarlet Thread.)
07-08-2013 01:04 PM
Find all posts by this user Quote this message in a reply
Post Reply